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

Unified Diff: shell/application_manager/application_manager.cc

Issue 861293002: Allow external applications to register for mojo: urls (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Cleanup Created 5 years, 11 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 29d81fcfc5f466bc8c849f5d52001413189d351e..772bd99cff08c7f337fa7c08085f283d24be678c 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -117,6 +117,24 @@ void ApplicationManager::ConnectToApplication(
ServiceProviderPtr exposed_services) {
DCHECK(requested_url.is_valid());
GURL mapped_url = delegate_->ResolveMappings(requested_url);
+
+ // We check both the mapped and resolved urls for existing shell_impls because
+ // external applications can be registered for the unresolved mojo:foo urls.
+ ShellImpl* shell_impl = GetShellImpl(mapped_url);
+ if (shell_impl) {
+ ConnectToClient(shell_impl, mapped_url, requestor_url, services.Pass(),
+ exposed_services.Pass());
+ return;
+ }
+
+ GURL resolved_url = delegate_->ResolveURL(mapped_url);
+ shell_impl = GetShellImpl(resolved_url);
+ if (shell_impl) {
+ ConnectToClient(shell_impl, resolved_url, requestor_url, services.Pass(),
+ exposed_services.Pass());
+ return;
+ }
+
ApplicationLoader* loader =
GetLoaderForURL(mapped_url, DONT_INCLUDE_DEFAULT_LOADER);
if (loader) {
@@ -125,7 +143,6 @@ void ApplicationManager::ConnectToApplication(
return;
}
- GURL resolved_url = delegate_->ResolveURL(mapped_url);
loader = GetLoaderForURL(resolved_url, INCLUDE_DEFAULT_LOADER);
if (loader) {
ConnectToApplicationImpl(requested_url, resolved_url, requestor_url,
@@ -144,26 +161,26 @@ void ApplicationManager::ConnectToApplicationImpl(
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
ApplicationLoader* loader) {
- ShellImpl* shell = nullptr;
- URLToShellImplMap::const_iterator shell_it =
- url_to_shell_impl_.find(resolved_url);
- if (shell_it != url_to_shell_impl_.end()) {
- shell = shell_it->second;
- } else {
- MessagePipe pipe;
- shell =
- new ShellImpl(pipe.handle0.Pass(), this, requested_url, resolved_url);
- url_to_shell_impl_[resolved_url] = shell;
- shell->client()->Initialize(GetArgsForURL(requested_url));
-
- loader->Load(this, resolved_url, pipe.handle1.Pass(),
- base::Bind(&ApplicationManager::LoadWithContentHandler,
- weak_ptr_factory_.GetWeakPtr()));
- }
+ MessagePipe pipe;
+ ShellImpl* shell =
+ new ShellImpl(pipe.handle0.Pass(), this, requested_url, resolved_url);
+ url_to_shell_impl_[resolved_url] = shell;
+ shell->client()->Initialize(GetArgsForURL(requested_url));
+
+ loader->Load(this, resolved_url, pipe.handle1.Pass(),
+ base::Bind(&ApplicationManager::LoadWithContentHandler,
+ weak_ptr_factory_.GetWeakPtr()));
ConnectToClient(shell, resolved_url, requestor_url, services.Pass(),
exposed_services.Pass());
}
+ShellImpl* ApplicationManager::GetShellImpl(const GURL& url) {
+ const auto& shell_it = url_to_shell_impl_.find(url);
+ if (shell_it != url_to_shell_impl_.end())
+ return shell_it->second;
+ return nullptr;
+}
+
void ApplicationManager::ConnectToClient(
ShellImpl* shell_impl,
const GURL& url,

Powered by Google App Engine
This is Rietveld 408576698