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

Unified Diff: shell/application_manager/application_manager.cc

Issue 1026293002: Aggregate parameters through mappings. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix androdi build Created 5 years, 9 months 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
Index: shell/application_manager/application_manager.cc
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc
index 8ffe80860d6f97e3011363cf8e6b59330a17b108..f285962ee5cc1a4cd430a82e77150e889eccf894 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -28,6 +28,17 @@ namespace {
// Used by TestAPI.
bool has_created_instance = false;
+std::vector<std::string> Concatenate(const std::vector<std::string>& v1,
+ const std::vector<std::string>& v2) {
+ if (!v1.size())
+ return v2;
+ if (!v2.size())
+ return v1;
+ std::vector<std::string> result(v1);
+ result.insert(result.end(), v1.begin(), v1.end());
+ return result;
+}
+
} // namespace
ApplicationManager::Delegate::~Delegate() {
@@ -111,6 +122,17 @@ void ApplicationManager::ConnectToApplication(
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services) {
+ ConnectToApplicationWithParameters(requested_url, requestor_url,
+ services.Pass(), exposed_services.Pass(),
+ std::vector<std::string>());
+}
+
+void ApplicationManager::ConnectToApplicationWithParameters(
+ const GURL& requested_url,
+ const GURL& requestor_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services,
+ const std::vector<std::string>& parameters) {
DCHECK(requested_url.is_valid());
// We check both the mapped and resolved urls for existing shell_impls because
@@ -129,27 +151,28 @@ void ApplicationManager::ConnectToApplication(
}
if (ConnectToApplicationWithLoader(requested_url, mapped_url, requestor_url,
- &services, &exposed_services,
+ &services, &exposed_services, parameters,
GetLoaderForURL(mapped_url))) {
return;
}
if (ConnectToApplicationWithLoader(requested_url, resolved_url, requestor_url,
- &services, &exposed_services,
+ &services, &exposed_services, parameters,
GetLoaderForURL(resolved_url))) {
return;
}
if (ConnectToApplicationWithLoader(requested_url, resolved_url, requestor_url,
- &services, &exposed_services,
+ &services, &exposed_services, parameters,
default_loader_.get())) {
return;
}
- auto callback = base::Bind(&ApplicationManager::HandleFetchCallback,
- weak_ptr_factory_.GetWeakPtr(), requested_url,
- requestor_url, base::Passed(services.Pass()),
- base::Passed(exposed_services.Pass()));
+ auto callback = base::Bind(
+ &ApplicationManager::HandleFetchCallback, weak_ptr_factory_.GetWeakPtr(),
+ requested_url, requestor_url, base::Passed(services.Pass()),
+ base::Passed(exposed_services.Pass()),
+ Concatenate(parameters, GetArgsForURL(resolved_url)));
if (resolved_url.SchemeIsFile()) {
new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr),
@@ -191,13 +214,15 @@ bool ApplicationManager::ConnectToApplicationWithLoader(
const GURL& requestor_url,
InterfaceRequest<ServiceProvider>* services,
ServiceProviderPtr* exposed_services,
+ const std::vector<std::string>& parameters,
ApplicationLoader* loader) {
if (!loader)
return false;
- loader->Load(resolved_url,
- RegisterShell(requested_url, resolved_url, requestor_url,
- services->Pass(), exposed_services->Pass()));
+ loader->Load(
+ resolved_url,
+ RegisterShell(requested_url, resolved_url, requestor_url,
+ services->Pass(), exposed_services->Pass(), parameters));
return true;
}
@@ -206,7 +231,8 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell(
const GURL& resolved_url,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) {
+ ServiceProviderPtr exposed_services,
+ const std::vector<std::string>& parameters) {
Identity app_identity(resolved_url);
ApplicationPtr application;
@@ -214,7 +240,8 @@ InterfaceRequest<Application> ApplicationManager::RegisterShell(
ShellImpl* shell =
new ShellImpl(application.Pass(), this, original_url, app_identity);
identity_to_shell_impl_[app_identity] = shell;
- shell->InitializeApplication(GetArgsForURL(original_url));
+ shell->InitializeApplication(Array<String>::From(
+ Concatenate(parameters, GetArgsForURL(app_identity.url))));
ConnectToClient(shell, resolved_url, requestor_url, services.Pass(),
exposed_services.Pass());
return application_request.Pass();
@@ -242,6 +269,7 @@ void ApplicationManager::HandleFetchCallback(
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
+ const std::vector<std::string>& parameters,
NativeRunner::CleanupBehavior cleanup_behavior,
scoped_ptr<Fetcher> fetcher) {
if (!fetcher) {
@@ -252,8 +280,9 @@ void ApplicationManager::HandleFetchCallback(
GURL redirect_url = fetcher->GetRedirectURL();
if (!redirect_url.is_empty()) {
// And around we go again... Whee!
- ConnectToApplication(redirect_url, requestor_url, services.Pass(),
- exposed_services.Pass());
+ ConnectToApplicationWithParameters(redirect_url, requestor_url,
+ services.Pass(), exposed_services.Pass(),
+ parameters);
return;
}
@@ -270,7 +299,7 @@ void ApplicationManager::HandleFetchCallback(
InterfaceRequest<Application> request(
RegisterShell(requested_url, fetcher->GetURL(), requestor_url,
- services.Pass(), exposed_services.Pass()));
+ services.Pass(), exposed_services.Pass(), parameters));
// If the response begins with a #!mojo <content-handler-url>, use it.
GURL content_handler_url;
@@ -398,7 +427,17 @@ void ApplicationManager::SetLoaderForScheme(
void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args,
const GURL& url) {
- url_to_args_[url] = args;
+ url_to_args_[url].insert(url_to_args_[url].end(), args.begin(), args.end());
+ GURL mapped_url = delegate_->ResolveMappings(url);
+ if (mapped_url != url) {
+ url_to_args_[mapped_url].insert(url_to_args_[mapped_url].end(),
+ args.begin(), args.end());
+ }
+ GURL resolved_url = delegate_->ResolveURL(mapped_url);
+ if (resolved_url != mapped_url) {
+ url_to_args_[resolved_url].insert(url_to_args_[resolved_url].end(),
+ args.begin(), args.end());
+ }
}
void ApplicationManager::SetNativeOptionsForURL(
@@ -457,11 +496,11 @@ ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName(
return pipe.handle0.Pass();
}
-Array<String> ApplicationManager::GetArgsForURL(const GURL& url) {
+std::vector<std::string> ApplicationManager::GetArgsForURL(const GURL& url) {
const auto& args_it = url_to_args_.find(url);
if (args_it != url_to_args_.end())
- return Array<String>::From(args_it->second);
- return Array<String>();
+ return args_it->second;
+ return std::vector<std::string>();
}
void ApplicationManager::CleanupRunner(NativeRunner* runner) {
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/application_manager/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698