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 "shell/application_manager/application_manager.h" | 5 #include "shell/application_manager/application_manager.h" |
6 | 6 |
7 #include <stdio.h> | |
8 | |
9 #include "base/bind.h" | 7 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 9 #include "base/logging.h" |
12 #include "base/macros.h" | 10 #include "base/macros.h" |
13 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
14 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
15 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
16 #include "mojo/public/cpp/bindings/error_handler.h" | 14 #include "mojo/public/cpp/bindings/error_handler.h" |
17 #include "mojo/public/interfaces/application/shell.mojom.h" | 15 #include "mojo/public/interfaces/application/shell.mojom.h" |
18 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | 16 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" |
19 #include "shell/application_manager/fetcher.h" | 17 #include "shell/application_manager/fetcher.h" |
20 #include "shell/application_manager/local_fetcher.h" | 18 #include "shell/application_manager/local_fetcher.h" |
21 #include "shell/application_manager/network_fetcher.h" | 19 #include "shell/application_manager/network_fetcher.h" |
22 | 20 |
23 namespace mojo { | 21 namespace mojo { |
| 22 namespace shell { |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 // Used by TestAPI. | 26 // Used by TestAPI. |
28 bool has_created_instance = false; | 27 bool has_created_instance = false; |
29 | 28 |
30 GURL StripQueryFromURL(const GURL& url) { | 29 GURL StripQueryFromURL(const GURL& url) { |
31 GURL::Replacements repl; | 30 GURL::Replacements repl; |
32 repl.SetQueryStr(""); | 31 repl.SetQueryStr(""); |
33 std::string result = url.ReplaceComponents(repl).spec(); | 32 std::string result = url.ReplaceComponents(repl).spec(); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 const GURL& content_handler_url) { | 357 const GURL& content_handler_url) { |
359 DCHECK(content_handler_url.is_valid()) | 358 DCHECK(content_handler_url.is_valid()) |
360 << "Content handler URL is invalid for mime type " << mime_type; | 359 << "Content handler URL is invalid for mime type " << mime_type; |
361 mime_type_to_url_[mime_type] = content_handler_url; | 360 mime_type_to_url_[mime_type] = content_handler_url; |
362 } | 361 } |
363 | 362 |
364 void ApplicationManager::LoadWithContentHandler( | 363 void ApplicationManager::LoadWithContentHandler( |
365 const GURL& content_handler_url, | 364 const GURL& content_handler_url, |
366 InterfaceRequest<Application> application_request, | 365 InterfaceRequest<Application> application_request, |
367 URLResponsePtr url_response) { | 366 URLResponsePtr url_response) { |
368 ContentHandlerConnection* connection = NULL; | 367 ContentHandlerConnection* connection = nullptr; |
369 URLToContentHandlerMap::iterator iter = | 368 URLToContentHandlerMap::iterator iter = |
370 url_to_content_handler_.find(content_handler_url); | 369 url_to_content_handler_.find(content_handler_url); |
371 if (iter != url_to_content_handler_.end()) { | 370 if (iter != url_to_content_handler_.end()) { |
372 connection = iter->second; | 371 connection = iter->second; |
373 } else { | 372 } else { |
374 connection = new ContentHandlerConnection(this, content_handler_url); | 373 connection = new ContentHandlerConnection(this, content_handler_url); |
375 url_to_content_handler_[content_handler_url] = connection; | 374 url_to_content_handler_[content_handler_url] = connection; |
376 } | 375 } |
377 | 376 |
378 connection->content_handler()->StartApplication(application_request.Pass(), | 377 connection->content_handler()->StartApplication(application_request.Pass(), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 url_to_native_options_[resolved_url] = options; | 412 url_to_native_options_[resolved_url] = options; |
414 } | 413 } |
415 | 414 |
416 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { | 415 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { |
417 auto url_it = url_to_loader_.find(StripQueryFromURL(url)); | 416 auto url_it = url_to_loader_.find(StripQueryFromURL(url)); |
418 if (url_it != url_to_loader_.end()) | 417 if (url_it != url_to_loader_.end()) |
419 return url_it->second; | 418 return url_it->second; |
420 auto scheme_it = scheme_to_loader_.find(url.scheme()); | 419 auto scheme_it = scheme_to_loader_.find(url.scheme()); |
421 if (scheme_it != scheme_to_loader_.end()) | 420 if (scheme_it != scheme_to_loader_.end()) |
422 return scheme_it->second; | 421 return scheme_it->second; |
423 return NULL; | 422 return nullptr; |
424 } | 423 } |
425 | 424 |
426 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { | 425 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { |
427 // Called from ~ShellImpl, so we do not need to call Destroy here. | 426 // Called from ~ShellImpl, so we do not need to call Destroy here. |
428 const GURL url = shell_impl->url(); | 427 const GURL url = shell_impl->url(); |
429 const GURL requested_url = shell_impl->requested_url(); | 428 const GURL requested_url = shell_impl->requested_url(); |
430 // Remove the shell. | 429 // Remove the shell. |
431 URLToShellImplMap::iterator it = url_to_shell_impl_.find(url); | 430 URLToShellImplMap::iterator it = url_to_shell_impl_.find(url); |
432 DCHECK(it != url_to_shell_impl_.end()); | 431 DCHECK(it != url_to_shell_impl_.end()); |
433 delete it->second; | 432 delete it->second; |
(...skipping 26 matching lines...) Expand all Loading... |
460 if (args_it != url_to_args_.end()) | 459 if (args_it != url_to_args_.end()) |
461 return Array<String>::From(args_it->second); | 460 return Array<String>::From(args_it->second); |
462 return Array<String>(); | 461 return Array<String>(); |
463 } | 462 } |
464 | 463 |
465 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 464 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
466 native_runners_.erase( | 465 native_runners_.erase( |
467 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 466 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
468 } | 467 } |
469 | 468 |
| 469 } // namespace shell |
470 } // namespace mojo | 470 } // namespace mojo |
OLD | NEW |