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 "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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const std::vector<std::string>& v2) { | 38 const std::vector<std::string>& v2) { |
39 if (!v1.size()) | 39 if (!v1.size()) |
40 return v2; | 40 return v2; |
41 if (!v2.size()) | 41 if (!v2.size()) |
42 return v1; | 42 return v1; |
43 std::vector<std::string> result(v1); | 43 std::vector<std::string> result(v1); |
44 result.insert(result.end(), v1.begin(), v1.end()); | 44 result.insert(result.end(), v1.begin(), v1.end()); |
45 return result; | 45 return result; |
46 } | 46 } |
47 | 47 |
| 48 void AppendArgsForURL(const GURL& url, |
| 49 const std::vector<std::string>& args, |
| 50 std::vector<std::string>* target) { |
| 51 if (target->empty()) |
| 52 target->push_back(url.spec()); |
| 53 target->insert(target->end(), args.begin(), args.end()); |
| 54 } |
| 55 |
48 } // namespace | 56 } // namespace |
49 | 57 |
50 class ApplicationManager::ContentHandlerConnection { | 58 class ApplicationManager::ContentHandlerConnection { |
51 public: | 59 public: |
52 ContentHandlerConnection(ApplicationManager* manager, Identity identity) | 60 ContentHandlerConnection(ApplicationManager* manager, Identity identity) |
53 : manager_(manager), identity_(identity) { | 61 : manager_(manager), identity_(identity) { |
54 ServiceProviderPtr services; | 62 ServiceProviderPtr services; |
55 manager->ConnectToApplication(identity_.url, GURL(), | 63 manager->ConnectToApplication(identity_.url, GURL(), |
56 mojo::GetProxy(&services), nullptr, | 64 mojo::GetProxy(&services), nullptr, |
57 base::Closure()); | 65 base::Closure()); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 458 |
451 void ApplicationManager::SetLoaderForScheme( | 459 void ApplicationManager::SetLoaderForScheme( |
452 scoped_ptr<ApplicationLoader> loader, | 460 scoped_ptr<ApplicationLoader> loader, |
453 const std::string& scheme) { | 461 const std::string& scheme) { |
454 scheme_to_loader_[scheme] = loader.Pass(); | 462 scheme_to_loader_[scheme] = loader.Pass(); |
455 } | 463 } |
456 | 464 |
457 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, | 465 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, |
458 const GURL& url) { | 466 const GURL& url) { |
459 GURL base_url = GetBaseURLAndQuery(url, nullptr); | 467 GURL base_url = GetBaseURLAndQuery(url, nullptr); |
460 url_to_args_[base_url].insert(url_to_args_[base_url].end(), args.begin(), | 468 AppendArgsForURL(base_url, args, &url_to_args_[base_url]); |
461 args.end()); | |
462 GURL mapped_url = delegate_->ResolveMappings(base_url); | 469 GURL mapped_url = delegate_->ResolveMappings(base_url); |
463 DCHECK(!mapped_url.has_query()); | 470 DCHECK(!mapped_url.has_query()); |
464 if (mapped_url != url) { | 471 if (mapped_url != base_url) |
465 url_to_args_[mapped_url].insert(url_to_args_[mapped_url].end(), | 472 AppendArgsForURL(mapped_url, args, &url_to_args_[mapped_url]); |
466 args.begin(), args.end()); | |
467 } | |
468 GURL resolved_url = delegate_->ResolveMojoURL(mapped_url); | 473 GURL resolved_url = delegate_->ResolveMojoURL(mapped_url); |
469 DCHECK(!resolved_url.has_query()); | 474 DCHECK(!resolved_url.has_query()); |
470 if (resolved_url != mapped_url) { | 475 if (resolved_url != mapped_url) |
471 url_to_args_[resolved_url].insert(url_to_args_[resolved_url].end(), | 476 AppendArgsForURL(resolved_url, args, &url_to_args_[resolved_url]); |
472 args.begin(), args.end()); | |
473 } | |
474 } | 477 } |
475 | 478 |
476 NativeApplicationOptions* ApplicationManager::GetNativeApplicationOptionsForURL( | 479 NativeApplicationOptions* ApplicationManager::GetNativeApplicationOptionsForURL( |
477 const GURL& url) { | 480 const GURL& url) { |
478 DCHECK(!url.has_query()); // Precondition. | 481 DCHECK(!url.has_query()); // Precondition. |
479 // Apply mappings and resolution to get the resolved URL. | 482 // Apply mappings and resolution to get the resolved URL. |
480 GURL resolved_url = | 483 GURL resolved_url = |
481 delegate_->ResolveMojoURL(delegate_->ResolveMappings(url)); | 484 delegate_->ResolveMojoURL(delegate_->ResolveMappings(url)); |
482 // TODO(vtl): We should probably also remove/disregard the query string (and | 485 // TODO(vtl): We should probably also remove/disregard the query string (and |
483 // maybe canonicalize in other ways). | 486 // maybe canonicalize in other ways). |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 return args_it->second; | 536 return args_it->second; |
534 return std::vector<std::string>(); | 537 return std::vector<std::string>(); |
535 } | 538 } |
536 | 539 |
537 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 540 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
538 native_runners_.erase( | 541 native_runners_.erase( |
539 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 542 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
540 } | 543 } |
541 | 544 |
542 } // namespace shell | 545 } // namespace shell |
OLD | NEW |