Shell: Strip query string from URL when looking to apply native options.
R=qsr@chromium.org
Review URL: https://codereview.chromium.org/982903002
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc
index 11f8759..90df846 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -288,12 +288,13 @@
// library.
// TODO(vtl): (Maybe this should be done by the factory/runner?)
+ GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr);
NativeRunnerFactory::Options options;
- if (url_to_native_options_.find(fetcher->GetURL()) !=
+ if (url_to_native_options_.find(base_resolved_url) !=
url_to_native_options_.end()) {
DVLOG(2) << "Applying stored native options to resolved URL "
<< fetcher->GetURL() << " (requested URL " << requested_url << ")";
- options = url_to_native_options_[fetcher->GetURL()];
+ options = url_to_native_options_[base_resolved_url];
}
fetcher->AsPath(
@@ -393,8 +394,10 @@
void ApplicationManager::SetNativeOptionsForURL(
const NativeRunnerFactory::Options& options,
const GURL& url) {
+ DCHECK(!url.has_query()); // Precondition.
// Apply mappings and resolution to get the resolved URL.
GURL resolved_url = delegate_->ResolveURL(delegate_->ResolveMappings(url));
+ DCHECK(!resolved_url.has_query()); // Still shouldn't have query.
// TODO(vtl): We should probably also remove/disregard the query string (and
// maybe canonicalize in other ways).
DVLOG(2) << "Storing native options for resolved URL " << resolved_url
diff --git a/shell/application_manager/application_manager.h b/shell/application_manager/application_manager.h
index 38784d7..fee8cdf 100644
--- a/shell/application_manager/application_manager.h
+++ b/shell/application_manager/application_manager.h
@@ -110,9 +110,10 @@
// TODO(vtl): Maybe we should store/compare resolved URLs, like
// SetNativeOptionsForURL() below?
void SetArgsForURL(const std::vector<std::string>& args, const GURL& url);
- // These options will be used in running any native application at |url|.
- // (|url| will be mapped and resolved, and any application whose resolved URL
- // matches it will have |options| applied.)
+ // These options will be used in running any native application at |url|
+ // (which shouldn't contain a query string). (|url| will be mapped and
+ // resolved, and any application whose base resolved URL matches it will have
+ // |options| applied.)
// TODO(vtl): This may not do what's desired if the resolved URL results in an
// HTTP redirect. Really, we want options to be identified with a particular
// implementation, maybe via a signed manifest or something like that.