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

Unified Diff: shell/application_manager/application_manager.cc

Issue 951643002: Register application connections under their post-redirect URL. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 5 years, 10 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
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/application_manager/fetcher.h » ('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 52de7f8e2ec33d7b88fd64c8fe037b12e190a46d..e6beb2117a3ad85e1ae4a3765d0b3d4686acd409 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -142,13 +142,10 @@ void ApplicationManager::ConnectToApplication(
return;
}
- InterfaceRequest<Application> application_request =
- RegisterShell(requested_url, resolved_url, requestor_url, services.Pass(),
- exposed_services.Pass());
-
auto callback = base::Bind(&ApplicationManager::HandleFetchCallback,
- weak_ptr_factory_.GetWeakPtr(),
- base::Passed(application_request.Pass()));
+ weak_ptr_factory_.GetWeakPtr(), requested_url,
+ requestor_url, base::Passed(services.Pass()),
+ base::Passed(exposed_services.Pass()));
if (resolved_url.SchemeIsFile()) {
new LocalFetcher(resolved_url,
@@ -228,7 +225,10 @@ void ApplicationManager::ConnectToClient(
}
void ApplicationManager::HandleFetchCallback(
- InterfaceRequest<Application> application_request,
+ const GURL& requested_url,
+ const GURL& requestor_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services,
NativeRunner::CleanupBehavior cleanup_behavior,
scoped_ptr<Fetcher> fetcher) {
if (!fetcher) {
@@ -236,12 +236,35 @@ void ApplicationManager::HandleFetchCallback(
return;
}
+ GURL redirect_url = fetcher->GetRedirectURL();
+ if (!redirect_url.is_empty()) {
+ // And around we go again... Whee!
qsr 2015/02/26 10:41:56 Is there any advantage to try to use the url_loade
+ ConnectToApplication(redirect_url, requestor_url, services.Pass(),
+ exposed_services.Pass());
+ return;
+ }
+
+ // We already checked if the application was running before we fetched it, but
+ // it might have started while the fetch was outstanding. We don't want to
+ // have two copies of the app running, so check again.
+ //
+ // Also, it's possible the original URL was redirected to an app that is
+ // already running.
+ if (ConnectToRunningApplication(fetcher->GetURL(), requestor_url, &services,
+ &exposed_services)) {
+ return;
+ }
+
+ InterfaceRequest<Application> application_request(
+ RegisterShell(requested_url, fetcher->GetURL(), requestor_url,
+ services.Pass(), exposed_services.Pass()));
+
// If the response begins with a #!mojo <content-handler-url>, use it.
- GURL url;
+ GURL content_handler_url;
std::string shebang;
- if (fetcher->PeekContentHandler(&shebang, &url)) {
+ if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) {
LoadWithContentHandler(
- url, application_request.Pass(),
+ content_handler_url, application_request.Pass(),
fetcher->AsURLResponse(blocking_pool_,
static_cast<int>(shebang.size())));
return;
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/application_manager/fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698