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