| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "mojo/shell/application_manager.h" | 5 #include "mojo/shell/application_manager.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" | 
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" | 
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" | 
| 14 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 14 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 
| 15 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" | 
|  | 16 #include "mojo/shell/application_fetcher.h" | 
| 16 #include "mojo/shell/application_instance.h" | 17 #include "mojo/shell/application_instance.h" | 
| 17 #include "mojo/shell/content_handler_connection.h" | 18 #include "mojo/shell/content_handler_connection.h" | 
| 18 #include "mojo/shell/fetcher.h" | 19 #include "mojo/shell/fetcher.h" | 
| 19 #include "mojo/shell/local_fetcher.h" |  | 
| 20 #include "mojo/shell/network_fetcher.h" |  | 
| 21 #include "mojo/shell/query_util.h" | 20 #include "mojo/shell/query_util.h" | 
| 22 #include "mojo/shell/switches.h" | 21 #include "mojo/shell/switches.h" | 
| 23 #include "mojo/shell/update_fetcher.h" |  | 
| 24 | 22 | 
| 25 namespace mojo { | 23 namespace mojo { | 
| 26 namespace shell { | 24 namespace shell { | 
| 27 | 25 | 
| 28 namespace { | 26 namespace { | 
| 29 | 27 | 
| 30 // Used by TestAPI. | 28 // Used by TestAPI. | 
| 31 bool has_created_instance = false; | 29 bool has_created_instance = false; | 
| 32 | 30 | 
| 33 void OnEmptyOnConnectCallback(uint32_t content_handler_id) {} | 31 void OnEmptyOnConnectCallback(uint32_t content_handler_id) {} | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 45 bool ApplicationManager::TestAPI::HasCreatedInstance() { | 43 bool ApplicationManager::TestAPI::HasCreatedInstance() { | 
| 46   return has_created_instance; | 44   return has_created_instance; | 
| 47 } | 45 } | 
| 48 | 46 | 
| 49 bool ApplicationManager::TestAPI::HasRunningInstanceForURL( | 47 bool ApplicationManager::TestAPI::HasRunningInstanceForURL( | 
| 50     const GURL& url) const { | 48     const GURL& url) const { | 
| 51   return manager_->identity_to_instance_.find(Identity(url)) != | 49   return manager_->identity_to_instance_.find(Identity(url)) != | 
| 52          manager_->identity_to_instance_.end(); | 50          manager_->identity_to_instance_.end(); | 
| 53 } | 51 } | 
| 54 | 52 | 
| 55 ApplicationManager::ApplicationManager(Delegate* delegate) | 53 ApplicationManager::ApplicationManager(scoped_ptr<ApplicationFetcher> fetcher) | 
| 56     : delegate_(delegate), | 54     : fetcher_(fetcher.Pass()), | 
| 57       disable_cache_(false), |  | 
| 58       content_handler_id_counter_(0u), | 55       content_handler_id_counter_(0u), | 
| 59       weak_ptr_factory_(this) {} | 56       weak_ptr_factory_(this) { | 
|  | 57   fetcher_->SetApplicationManager(this); | 
|  | 58 } | 
| 60 | 59 | 
| 61 ApplicationManager::~ApplicationManager() { | 60 ApplicationManager::~ApplicationManager() { | 
| 62   URLToContentHandlerMap url_to_content_handler(url_to_content_handler_); | 61   URLToContentHandlerMap url_to_content_handler(url_to_content_handler_); | 
| 63   for (auto& pair : url_to_content_handler) | 62   for (auto& pair : url_to_content_handler) | 
| 64     pair.second->CloseConnection(); | 63     pair.second->CloseConnection(); | 
| 65   TerminateShellConnections(); | 64   TerminateShellConnections(); | 
| 66   STLDeleteValues(&url_to_loader_); | 65   STLDeleteValues(&url_to_loader_); | 
| 67   STLDeleteValues(&scheme_to_loader_); | 66   STLDeleteValues(&scheme_to_loader_); | 
| 68 } | 67 } | 
| 69 | 68 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 97     scoped_ptr<ConnectToApplicationParams> params) { | 96     scoped_ptr<ConnectToApplicationParams> params) { | 
| 98   GURL original_url = params->app_url(); | 97   GURL original_url = params->app_url(); | 
| 99   URLRequestPtr original_url_request = params->TakeAppURLRequest(); | 98   URLRequestPtr original_url_request = params->TakeAppURLRequest(); | 
| 100 | 99 | 
| 101   TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::ConnectToApplication", | 100   TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::ConnectToApplication", | 
| 102                        TRACE_EVENT_SCOPE_THREAD, "original_url", | 101                        TRACE_EVENT_SCOPE_THREAD, "original_url", | 
| 103                        original_url.spec()); | 102                        original_url.spec()); | 
| 104   DCHECK(original_url.is_valid()); | 103   DCHECK(original_url.is_valid()); | 
| 105   DCHECK(original_url_request); | 104   DCHECK(original_url_request); | 
| 106 | 105 | 
| 107   // We check both the mapped and resolved urls for existing instances because | 106   // We need to look for running instances based on both the unresolved and | 
| 108   // external applications can be registered for the unresolved mojo:foo urls. | 107   // resolved urls. | 
| 109 |  | 
| 110   GURL mapped_url = delegate_->ResolveMappings(original_url); |  | 
| 111   params->SetURLInfo(mapped_url); |  | 
| 112   if (ConnectToRunningApplication(¶ms)) | 108   if (ConnectToRunningApplication(¶ms)) | 
| 113     return; | 109     return; | 
| 114 | 110 | 
| 115   GURL resolved_url = delegate_->ResolveMojoURL(mapped_url); | 111   GURL resolved_url = fetcher_->ResolveURL(original_url); | 
| 116   params->SetURLInfo(resolved_url); | 112   params->SetURLInfo(resolved_url); | 
| 117   if (ConnectToRunningApplication(¶ms)) | 113   if (ConnectToRunningApplication(¶ms)) | 
| 118     return; | 114     return; | 
| 119 | 115 | 
| 120   // The application is not running, let's compute the parameters. | 116   // The application is not running, let's compute the parameters. | 
| 121   // NOTE: Set URL info using |original_url_request| instead of |original_url| | 117   // NOTE: Set URL info using |original_url_request| instead of |original_url| | 
| 122   // because it may contain more information (e.g., it is a POST request). | 118   // because it may contain more information (e.g., it is a POST request). | 
| 123   params->SetURLInfo(original_url_request.Pass()); | 119   params->SetURLInfo(original_url_request.Pass()); | 
| 124   if (ConnectToApplicationWithLoader(¶ms, mapped_url, | 120   ApplicationLoader* loader = GetLoaderForURL(resolved_url); | 
| 125                                      GetLoaderForURL(mapped_url))) { | 121   if (loader) { | 
|  | 122     ConnectToApplicationWithLoader(¶ms, resolved_url, loader); | 
| 126     return; | 123     return; | 
| 127   } | 124   } | 
| 128 | 125 | 
| 129   if (ConnectToApplicationWithLoader(¶ms, resolved_url, |  | 
| 130                                      GetLoaderForURL(resolved_url))) { |  | 
| 131     return; |  | 
| 132   } |  | 
| 133 |  | 
| 134   if (ConnectToApplicationWithLoader(¶ms, resolved_url, |  | 
| 135                                      default_loader_.get())) { |  | 
| 136     return; |  | 
| 137   } |  | 
| 138 |  | 
| 139   original_url_request = params->TakeAppURLRequest(); | 126   original_url_request = params->TakeAppURLRequest(); | 
| 140   auto callback = | 127   auto callback = | 
| 141       base::Bind(&ApplicationManager::HandleFetchCallback, | 128       base::Bind(&ApplicationManager::HandleFetchCallback, | 
| 142                  weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms)); | 129                  weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms)); | 
| 143 | 130   fetcher_->FetchRequest(original_url_request.Pass(), callback); | 
| 144   if (delegate_->CreateFetcher( |  | 
| 145           resolved_url, |  | 
| 146           base::Bind(callback, NativeApplicationCleanup::DONT_DELETE))) { |  | 
| 147     return; |  | 
| 148   } |  | 
| 149 |  | 
| 150   if (resolved_url.SchemeIsFile()) { |  | 
| 151     // LocalFetcher uses the network service to infer MIME types from URLs. |  | 
| 152     // Skip this for mojo URLs to avoid recursively loading the network service. |  | 
| 153     if (!network_service_ && !original_url.SchemeIs("mojo")) |  | 
| 154       ConnectToService(GURL("mojo:network_service"), &network_service_); |  | 
| 155     new LocalFetcher( |  | 
| 156         network_service_.get(), resolved_url, |  | 
| 157         GetBaseURLAndQuery(resolved_url, nullptr), |  | 
| 158         base::Bind(callback, NativeApplicationCleanup::DONT_DELETE)); |  | 
| 159     return; |  | 
| 160   } |  | 
| 161 |  | 
| 162   if (mapped_url.SchemeIs("mojo") && |  | 
| 163       base::CommandLine::ForCurrentProcess()->HasSwitch( |  | 
| 164           switches::kUseUpdater)) { |  | 
| 165     ConnectToService(GURL("mojo:updater"), &updater_); |  | 
| 166     new UpdateFetcher( |  | 
| 167         mapped_url, updater_.get(), |  | 
| 168         base::Bind(callback, NativeApplicationCleanup::DONT_DELETE)); |  | 
| 169     return; |  | 
| 170   } |  | 
| 171 |  | 
| 172   if (!url_loader_factory_) |  | 
| 173     ConnectToService(GURL("mojo:network_service"), &url_loader_factory_); |  | 
| 174 |  | 
| 175   const NativeApplicationCleanup cleanup = |  | 
| 176       base::CommandLine::ForCurrentProcess()->HasSwitch( |  | 
| 177           switches::kDontDeleteOnDownload) |  | 
| 178           ? NativeApplicationCleanup::DONT_DELETE |  | 
| 179           : NativeApplicationCleanup::DELETE; |  | 
| 180 |  | 
| 181   if (original_url.SchemeIs("mojo")) { |  | 
| 182     // Use the resolved mojo URL in the request to support origin mapping, etc. |  | 
| 183     URLRequestPtr resolved_url_request(URLRequest::New()); |  | 
| 184     resolved_url_request->url = resolved_url.spec(); |  | 
| 185     new NetworkFetcher(disable_cache_, resolved_url_request.Pass(), |  | 
| 186                        url_loader_factory_.get(), |  | 
| 187                        base::Bind(callback, cleanup)); |  | 
| 188     return; |  | 
| 189   } |  | 
| 190 |  | 
| 191   new NetworkFetcher(disable_cache_, original_url_request.Pass(), |  | 
| 192                      url_loader_factory_.get(), base::Bind(callback, cleanup)); |  | 
| 193 } | 131 } | 
| 194 | 132 | 
| 195 bool ApplicationManager::ConnectToRunningApplication( | 133 bool ApplicationManager::ConnectToRunningApplication( | 
| 196     scoped_ptr<ConnectToApplicationParams>* params) { | 134     scoped_ptr<ConnectToApplicationParams>* params) { | 
| 197   ApplicationInstance* instance = GetApplicationInstance( | 135   ApplicationInstance* instance = GetApplicationInstance( | 
| 198       Identity((*params)->app_url(), (*params)->qualifier())); | 136       Identity((*params)->app_url(), (*params)->qualifier())); | 
| 199   if (!instance) | 137   if (!instance) | 
| 200     return false; | 138     return false; | 
| 201 | 139 | 
| 202   instance->ConnectToClient(params->Pass()); | 140   instance->ConnectToClient(params->Pass()); | 
| 203   return true; | 141   return true; | 
| 204 } | 142 } | 
| 205 | 143 | 
| 206 bool ApplicationManager::ConnectToApplicationWithLoader( | 144 void ApplicationManager::ConnectToApplicationWithLoader( | 
| 207     scoped_ptr<ConnectToApplicationParams>* params, | 145     scoped_ptr<ConnectToApplicationParams>* params, | 
| 208     const GURL& resolved_url, | 146     const GURL& resolved_url, | 
| 209     ApplicationLoader* loader) { | 147     ApplicationLoader* loader) { | 
| 210   if (!loader) |  | 
| 211     return false; |  | 
| 212 |  | 
| 213   if (!(*params)->app_url().SchemeIs("mojo")) | 148   if (!(*params)->app_url().SchemeIs("mojo")) | 
| 214     (*params)->SetURLInfo(resolved_url); | 149     (*params)->SetURLInfo(resolved_url); | 
| 215 | 150 | 
| 216   loader->Load(resolved_url, RegisterInstance(params->Pass(), nullptr)); | 151   loader->Load(resolved_url, RegisterInstance(params->Pass(), nullptr)); | 
| 217   return true; |  | 
| 218 } | 152 } | 
| 219 | 153 | 
| 220 InterfaceRequest<Application> ApplicationManager::RegisterInstance( | 154 InterfaceRequest<Application> ApplicationManager::RegisterInstance( | 
| 221     scoped_ptr<ConnectToApplicationParams> params, | 155     scoped_ptr<ConnectToApplicationParams> params, | 
| 222     ApplicationInstance** resulting_instance) { | 156     ApplicationInstance** resulting_instance) { | 
| 223   Identity app_identity(params->app_url(), params->qualifier()); | 157   Identity app_identity(params->app_url(), params->qualifier()); | 
| 224 | 158 | 
| 225   ApplicationPtr application; | 159   ApplicationPtr application; | 
| 226   InterfaceRequest<Application> application_request = GetProxy(&application); | 160   InterfaceRequest<Application> application_request = GetProxy(&application); | 
| 227   ApplicationInstance* instance = new ApplicationInstance( | 161   ApplicationInstance* instance = new ApplicationInstance( | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 241 ApplicationInstance* ApplicationManager::GetApplicationInstance( | 175 ApplicationInstance* ApplicationManager::GetApplicationInstance( | 
| 242     const Identity& identity) const { | 176     const Identity& identity) const { | 
| 243   const auto& instance_it = identity_to_instance_.find(identity); | 177   const auto& instance_it = identity_to_instance_.find(identity); | 
| 244   if (instance_it != identity_to_instance_.end()) | 178   if (instance_it != identity_to_instance_.end()) | 
| 245     return instance_it->second; | 179     return instance_it->second; | 
| 246   return nullptr; | 180   return nullptr; | 
| 247 } | 181 } | 
| 248 | 182 | 
| 249 void ApplicationManager::HandleFetchCallback( | 183 void ApplicationManager::HandleFetchCallback( | 
| 250     scoped_ptr<ConnectToApplicationParams> params, | 184     scoped_ptr<ConnectToApplicationParams> params, | 
| 251     NativeApplicationCleanup cleanup, |  | 
| 252     scoped_ptr<Fetcher> fetcher) { | 185     scoped_ptr<Fetcher> fetcher) { | 
| 253   if (!fetcher) { | 186   if (!fetcher) { | 
| 254     // Network error. Drop |params| to tell the requestor. | 187     // Network error. Drop |params| to tell the requestor. | 
| 255     params->connect_callback().Run(Shell::kInvalidContentHandlerID); | 188     params->connect_callback().Run(Shell::kInvalidContentHandlerID); | 
| 256     return; | 189     return; | 
| 257   } | 190   } | 
| 258 | 191 | 
| 259   GURL redirect_url = fetcher->GetRedirectURL(); | 192   GURL redirect_url = fetcher->GetRedirectURL(); | 
| 260   if (!redirect_url.is_empty()) { | 193   if (!redirect_url.is_empty()) { | 
| 261     // And around we go again... Whee! | 194     // And around we go again... Whee! | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 293   params->set_connect_callback(EmptyConnectCallback()); | 226   params->set_connect_callback(EmptyConnectCallback()); | 
| 294   ApplicationInstance* app = nullptr; | 227   ApplicationInstance* app = nullptr; | 
| 295   InterfaceRequest<Application> request(RegisterInstance(params.Pass(), &app)); | 228   InterfaceRequest<Application> request(RegisterInstance(params.Pass(), &app)); | 
| 296 | 229 | 
| 297   // For resources that are loaded with content handlers, we group app instances | 230   // For resources that are loaded with content handlers, we group app instances | 
| 298   // by site. | 231   // by site. | 
| 299 | 232 | 
| 300   // If the response begins with a #!mojo <content-handler-url>, use it. | 233   // If the response begins with a #!mojo <content-handler-url>, use it. | 
| 301   GURL content_handler_url; | 234   GURL content_handler_url; | 
| 302   std::string shebang; | 235   std::string shebang; | 
|  | 236   // TODO(beng): it seems like some delegate should/would want to have a say in | 
|  | 237   //             configuring the qualifier also. | 
| 303   bool enable_multi_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | 238   bool enable_multi_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 304       switches::kEnableMultiprocess); | 239       switches::kEnableMultiprocess); | 
| 305 | 240 | 
| 306   if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { | 241   if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { | 
| 307     URLResponsePtr response(fetcher->AsURLResponse( | 242     URLResponsePtr response(fetcher->AsURLResponse( | 
| 308         blocking_pool_, static_cast<int>(shebang.size()))); | 243         blocking_pool_, static_cast<int>(shebang.size()))); | 
| 309     std::string site = | 244     std::string site = | 
| 310         enable_multi_process ? response->site.To<std::string>() : std::string(); | 245         enable_multi_process ? response->site.To<std::string>() : std::string(); | 
| 311     LoadWithContentHandler(originator_identity, originator_filter, | 246     LoadWithContentHandler(originator_identity, originator_filter, | 
| 312                            content_handler_url, site, filter, connect_callback, | 247                            content_handler_url, site, filter, connect_callback, | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 378     else if (app_url == GURL("mojo://html_viewer/")) | 313     else if (app_url == GURL("mojo://html_viewer/")) | 
| 379       start_sandboxed = true; | 314       start_sandboxed = true; | 
| 380   } | 315   } | 
| 381 | 316 | 
| 382   connect_callback.Run(Shell::kInvalidContentHandlerID); | 317   connect_callback.Run(Shell::kInvalidContentHandlerID); | 
| 383 | 318 | 
| 384   fetcher->AsPath(blocking_pool_, | 319   fetcher->AsPath(blocking_pool_, | 
| 385                   base::Bind(&ApplicationManager::RunNativeApplication, | 320                   base::Bind(&ApplicationManager::RunNativeApplication, | 
| 386                              weak_ptr_factory_.GetWeakPtr(), | 321                              weak_ptr_factory_.GetWeakPtr(), | 
| 387                              base::Passed(request.Pass()), start_sandboxed, | 322                              base::Passed(request.Pass()), start_sandboxed, | 
| 388                              options, cleanup, base::Passed(fetcher.Pass()))); | 323                              options, base::Passed(fetcher.Pass()))); | 
| 389 } | 324 } | 
| 390 | 325 | 
| 391 void ApplicationManager::RunNativeApplication( | 326 void ApplicationManager::RunNativeApplication( | 
| 392     InterfaceRequest<Application> application_request, | 327     InterfaceRequest<Application> application_request, | 
| 393     bool start_sandboxed, | 328     bool start_sandboxed, | 
| 394     const NativeRunnerFactory::Options& options, | 329     const NativeRunnerFactory::Options& options, | 
| 395     NativeApplicationCleanup cleanup, |  | 
| 396     scoped_ptr<Fetcher> fetcher, | 330     scoped_ptr<Fetcher> fetcher, | 
| 397     const base::FilePath& path, | 331     const base::FilePath& path, | 
| 398     bool path_exists) { | 332     bool path_exists) { | 
| 399   // We only passed fetcher to keep it alive. Done with it now. | 333   // We only passed fetcher to keep it alive. Done with it now. | 
| 400   fetcher.reset(); | 334   fetcher.reset(); | 
| 401 | 335 | 
| 402   DCHECK(application_request.is_pending()); | 336   DCHECK(application_request.is_pending()); | 
| 403 | 337 | 
| 404   if (!path_exists) { | 338   if (!path_exists) { | 
| 405     LOG(ERROR) << "Library not started because library path '" << path.value() | 339     LOG(ERROR) << "Library not started because library path '" << path.value() | 
| 406                << "' does not exist."; | 340                << "' does not exist."; | 
| 407     return; | 341     return; | 
| 408   } | 342   } | 
| 409 | 343 | 
| 410   TRACE_EVENT1("mojo_shell", "ApplicationManager::RunNativeApplication", "path", | 344   TRACE_EVENT1("mojo_shell", "ApplicationManager::RunNativeApplication", "path", | 
| 411                path.AsUTF8Unsafe()); | 345                path.AsUTF8Unsafe()); | 
| 412   NativeRunner* runner = native_runner_factory_->Create(options).release(); | 346   NativeRunner* runner = native_runner_factory_->Create(options).release(); | 
| 413   native_runners_.push_back(runner); | 347   native_runners_.push_back(runner); | 
| 414   runner->Start(path, start_sandboxed, cleanup, application_request.Pass(), | 348   runner->Start(path, start_sandboxed, NativeApplicationCleanup::DONT_DELETE, | 
|  | 349                 application_request.Pass(), | 
| 415                 base::Bind(&ApplicationManager::CleanupRunner, | 350                 base::Bind(&ApplicationManager::CleanupRunner, | 
| 416                            weak_ptr_factory_.GetWeakPtr(), runner)); | 351                            weak_ptr_factory_.GetWeakPtr(), runner)); | 
| 417 } | 352 } | 
| 418 | 353 | 
| 419 void ApplicationManager::RegisterContentHandler( | 354 void ApplicationManager::RegisterContentHandler( | 
| 420     const std::string& mime_type, | 355     const std::string& mime_type, | 
| 421     const GURL& content_handler_url) { | 356     const GURL& content_handler_url) { | 
| 422   DCHECK(content_handler_url.is_valid()) | 357   DCHECK(content_handler_url.is_valid()) | 
| 423       << "Content handler URL is invalid for mime type " << mime_type; | 358       << "Content handler URL is invalid for mime type " << mime_type; | 
| 424   mime_type_to_url_[mime_type] = content_handler_url; | 359   mime_type_to_url_[mime_type] = content_handler_url; | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 477   if (it != scheme_to_loader_.end()) | 412   if (it != scheme_to_loader_.end()) | 
| 478     delete it->second; | 413     delete it->second; | 
| 479   scheme_to_loader_[scheme] = loader.release(); | 414   scheme_to_loader_[scheme] = loader.release(); | 
| 480 } | 415 } | 
| 481 | 416 | 
| 482 void ApplicationManager::SetNativeOptionsForURL( | 417 void ApplicationManager::SetNativeOptionsForURL( | 
| 483     const NativeRunnerFactory::Options& options, | 418     const NativeRunnerFactory::Options& options, | 
| 484     const GURL& url) { | 419     const GURL& url) { | 
| 485   DCHECK(!url.has_query());  // Precondition. | 420   DCHECK(!url.has_query());  // Precondition. | 
| 486   // Apply mappings and resolution to get the resolved URL. | 421   // Apply mappings and resolution to get the resolved URL. | 
| 487   GURL resolved_url = | 422   GURL resolved_url = fetcher_->ResolveURL(url); | 
| 488       delegate_->ResolveMojoURL(delegate_->ResolveMappings(url)); |  | 
| 489   DCHECK(!resolved_url.has_query());  // Still shouldn't have query. | 423   DCHECK(!resolved_url.has_query());  // Still shouldn't have query. | 
| 490   // TODO(vtl): We should probably also remove/disregard the query string (and | 424   // TODO(vtl): We should probably also remove/disregard the query string (and | 
| 491   // maybe canonicalize in other ways). | 425   // maybe canonicalize in other ways). | 
| 492   DVLOG(2) << "Storing native options for resolved URL " << resolved_url | 426   DVLOG(2) << "Storing native options for resolved URL " << resolved_url | 
| 493            << " (original URL " << url << ")"; | 427            << " (original URL " << url << ")"; | 
| 494   url_to_native_options_[resolved_url] = options; | 428   url_to_native_options_[resolved_url] = options; | 
| 495 } | 429 } | 
| 496 | 430 | 
| 497 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { | 431 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { | 
| 498   auto url_it = url_to_loader_.find(GetBaseURLAndQuery(url, nullptr)); | 432   auto url_it = url_to_loader_.find(GetBaseURLAndQuery(url, nullptr)); | 
| 499   if (url_it != url_to_loader_.end()) | 433   if (url_it != url_to_loader_.end()) | 
| 500     return url_it->second; | 434     return url_it->second; | 
| 501   auto scheme_it = scheme_to_loader_.find(url.scheme()); | 435   auto scheme_it = scheme_to_loader_.find(url.scheme()); | 
| 502   if (scheme_it != scheme_to_loader_.end()) | 436   if (scheme_it != scheme_to_loader_.end()) | 
| 503     return scheme_it->second; | 437     return scheme_it->second; | 
| 504   return nullptr; | 438   return default_loader_.get(); | 
| 505 } | 439 } | 
| 506 | 440 | 
| 507 void ApplicationManager::OnApplicationInstanceError( | 441 void ApplicationManager::OnApplicationInstanceError( | 
| 508     ApplicationInstance* instance) { | 442     ApplicationInstance* instance) { | 
| 509   // Called from ~ApplicationInstance, so we do not need to call Destroy here. | 443   // Called from ~ApplicationInstance, so we do not need to call Destroy here. | 
| 510   const Identity identity = instance->identity(); | 444   const Identity identity = instance->identity(); | 
| 511   base::Closure on_application_end = instance->on_application_end(); | 445   base::Closure on_application_end = instance->on_application_end(); | 
| 512   // Remove the shell. | 446   // Remove the shell. | 
| 513   auto it = identity_to_instance_.find(identity); | 447   auto it = identity_to_instance_.find(identity); | 
| 514   DCHECK(it != identity_to_instance_.end()); | 448   DCHECK(it != identity_to_instance_.end()); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 546   services->ConnectToService(interface_name, pipe.handle1.Pass()); | 480   services->ConnectToService(interface_name, pipe.handle1.Pass()); | 
| 547   return pipe.handle0.Pass(); | 481   return pipe.handle0.Pass(); | 
| 548 } | 482 } | 
| 549 | 483 | 
| 550 Shell::ConnectToApplicationCallback EmptyConnectCallback() { | 484 Shell::ConnectToApplicationCallback EmptyConnectCallback() { | 
| 551   return base::Bind(&OnEmptyOnConnectCallback); | 485   return base::Bind(&OnEmptyOnConnectCallback); | 
| 552 } | 486 } | 
| 553 | 487 | 
| 554 }  // namespace shell | 488 }  // namespace shell | 
| 555 }  // namespace mojo | 489 }  // namespace mojo | 
| OLD | NEW | 
|---|