Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: shell/application_manager/application_manager.cc

Issue 1467263002: Fix URL duplication when SetArgsForURL is called mutliple times. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | shell/application_manager/application_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/application_manager/application_manager.cc
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc
index 4f4af48b18b238827e997972fe3d2195cb8c5a11..8453f1c180fd875020114ecccb4b679943e4eeec 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -45,6 +45,14 @@ std::vector<std::string> Concatenate(const std::vector<std::string>& v1,
return result;
}
+void AppendArgsForURL(const GURL& url,
+ const std::vector<std::string>& args,
+ std::vector<std::string>* target) {
+ if (target->empty())
+ target->push_back(url.spec());
+ target->insert(target->end(), args.begin(), args.end());
+}
+
} // namespace
class ApplicationManager::ContentHandlerConnection {
@@ -457,20 +465,15 @@ void ApplicationManager::SetLoaderForScheme(
void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args,
const GURL& url) {
GURL base_url = GetBaseURLAndQuery(url, nullptr);
- url_to_args_[base_url].insert(url_to_args_[base_url].end(), args.begin(),
- args.end());
+ AppendArgsForURL(base_url, args, &url_to_args_[base_url]);
GURL mapped_url = delegate_->ResolveMappings(base_url);
DCHECK(!mapped_url.has_query());
- if (mapped_url != url) {
- url_to_args_[mapped_url].insert(url_to_args_[mapped_url].end(),
- args.begin(), args.end());
- }
+ if (mapped_url != base_url)
+ AppendArgsForURL(mapped_url, args, &url_to_args_[mapped_url]);
GURL resolved_url = delegate_->ResolveMojoURL(mapped_url);
DCHECK(!resolved_url.has_query());
- if (resolved_url != mapped_url) {
- url_to_args_[resolved_url].insert(url_to_args_[resolved_url].end(),
- args.begin(), args.end());
- }
+ if (resolved_url != mapped_url)
+ AppendArgsForURL(resolved_url, args, &url_to_args_[resolved_url]);
}
NativeApplicationOptions* ApplicationManager::GetNativeApplicationOptionsForURL(
« no previous file with comments | « no previous file | shell/application_manager/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698