| 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,
|
|
|