| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } | 449 } |
| 450 | 450 |
| 451 void ApplicationManager::SetLoaderForScheme( | 451 void ApplicationManager::SetLoaderForScheme( |
| 452 scoped_ptr<ApplicationLoader> loader, | 452 scoped_ptr<ApplicationLoader> loader, |
| 453 const std::string& scheme) { | 453 const std::string& scheme) { |
| 454 scheme_to_loader_[scheme] = loader.Pass(); | 454 scheme_to_loader_[scheme] = loader.Pass(); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, | 457 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, |
| 458 const GURL& url) { | 458 const GURL& url) { |
| 459 url_to_args_[url].insert(url_to_args_[url].end(), args.begin(), args.end()); | 459 GURL base_url = GetBaseURLAndQuery(url, nullptr); |
| 460 GURL mapped_url = delegate_->ResolveMappings(url); | 460 url_to_args_[base_url].insert(url_to_args_[base_url].end(), args.begin(), |
| 461 args.end()); |
| 462 GURL mapped_url = delegate_->ResolveMappings(base_url); |
| 463 DCHECK(!mapped_url.has_query()); |
| 461 if (mapped_url != url) { | 464 if (mapped_url != url) { |
| 462 url_to_args_[mapped_url].insert(url_to_args_[mapped_url].end(), | 465 url_to_args_[mapped_url].insert(url_to_args_[mapped_url].end(), |
| 463 args.begin(), args.end()); | 466 args.begin(), args.end()); |
| 464 } | 467 } |
| 465 GURL resolved_url = delegate_->ResolveMojoURL(mapped_url); | 468 GURL resolved_url = delegate_->ResolveMojoURL(mapped_url); |
| 469 DCHECK(!resolved_url.has_query()); |
| 466 if (resolved_url != mapped_url) { | 470 if (resolved_url != mapped_url) { |
| 467 url_to_args_[resolved_url].insert(url_to_args_[resolved_url].end(), | 471 url_to_args_[resolved_url].insert(url_to_args_[resolved_url].end(), |
| 468 args.begin(), args.end()); | 472 args.begin(), args.end()); |
| 469 } | 473 } |
| 470 } | 474 } |
| 471 | 475 |
| 472 NativeApplicationOptions* ApplicationManager::GetNativeApplicationOptionsForURL( | 476 NativeApplicationOptions* ApplicationManager::GetNativeApplicationOptionsForURL( |
| 473 const GURL& url) { | 477 const GURL& url) { |
| 474 DCHECK(!url.has_query()); // Precondition. | 478 DCHECK(!url.has_query()); // Precondition. |
| 475 // Apply mappings and resolution to get the resolved URL. | 479 // Apply mappings and resolution to get the resolved URL. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 const std::string& interface_name) { | 520 const std::string& interface_name) { |
| 517 ServiceProviderPtr services; | 521 ServiceProviderPtr services; |
| 518 ConnectToApplication(application_url, GURL(), mojo::GetProxy(&services), | 522 ConnectToApplication(application_url, GURL(), mojo::GetProxy(&services), |
| 519 nullptr, base::Closure()); | 523 nullptr, base::Closure()); |
| 520 mojo::MessagePipe pipe; | 524 mojo::MessagePipe pipe; |
| 521 services->ConnectToService(interface_name, pipe.handle1.Pass()); | 525 services->ConnectToService(interface_name, pipe.handle1.Pass()); |
| 522 return pipe.handle0.Pass(); | 526 return pipe.handle0.Pass(); |
| 523 } | 527 } |
| 524 | 528 |
| 525 std::vector<std::string> ApplicationManager::GetArgsForURL(const GURL& url) { | 529 std::vector<std::string> ApplicationManager::GetArgsForURL(const GURL& url) { |
| 526 const auto& args_it = url_to_args_.find(url); | 530 GURL base_url = GetBaseURLAndQuery(url, nullptr); |
| 531 const auto& args_it = url_to_args_.find(base_url); |
| 527 if (args_it != url_to_args_.end()) | 532 if (args_it != url_to_args_.end()) |
| 528 return args_it->second; | 533 return args_it->second; |
| 529 return std::vector<std::string>(); | 534 return std::vector<std::string>(); |
| 530 } | 535 } |
| 531 | 536 |
| 532 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 537 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
| 533 native_runners_.erase( | 538 native_runners_.erase( |
| 534 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 539 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
| 535 } | 540 } |
| 536 | 541 |
| 537 } // namespace shell | 542 } // namespace shell |
| OLD | NEW |