| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell_impl.h" | 5 #include "shell/application_manager/shell_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "mojo/converters/url/url_type_converters.h" | 9 #include "mojo/converters/url/url_type_converters.h" |
| 10 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" | 10 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" |
| 11 #include "shell/application_manager/application_manager.h" | 11 #include "shell/application_manager/application_manager.h" |
| 12 | 12 |
| 13 using mojo::ApplicationConnector; | 13 using mojo::ApplicationConnector; |
| 14 using mojo::ApplicationPtr; | 14 using mojo::ApplicationPtr; |
| 15 using mojo::Array; | 15 using mojo::Array; |
| 16 using mojo::InterfaceRequest; | 16 using mojo::InterfaceRequest; |
| 17 using mojo::InterfaceHandle; |
| 17 using mojo::ServiceProvider; | 18 using mojo::ServiceProvider; |
| 18 using mojo::ServiceProviderPtr; | 19 using mojo::ServiceProviderPtr; |
| 19 using mojo::Shell; | 20 using mojo::Shell; |
| 20 using mojo::ShellPtr; | 21 using mojo::ShellPtr; |
| 21 using mojo::String; | 22 using mojo::String; |
| 22 | 23 |
| 23 namespace shell { | 24 namespace shell { |
| 24 | 25 |
| 25 // ShellImpl::ApplicationConnectorImpl ----------------------------------------- | 26 // ShellImpl::ApplicationConnectorImpl ----------------------------------------- |
| 26 | 27 |
| 27 ShellImpl::ApplicationConnectorImpl::ApplicationConnectorImpl(Shell* shell) | 28 ShellImpl::ApplicationConnectorImpl::ApplicationConnectorImpl(Shell* shell) |
| 28 : shell_(shell) {} | 29 : shell_(shell) {} |
| 29 | 30 |
| 30 ShellImpl::ApplicationConnectorImpl::~ApplicationConnectorImpl() {} | 31 ShellImpl::ApplicationConnectorImpl::~ApplicationConnectorImpl() {} |
| 31 | 32 |
| 32 void ShellImpl::ApplicationConnectorImpl::ConnectToApplication( | 33 void ShellImpl::ApplicationConnectorImpl::ConnectToApplication( |
| 33 const String& app_url, | 34 const String& app_url, |
| 34 InterfaceRequest<ServiceProvider> services, | 35 InterfaceRequest<ServiceProvider> services, |
| 35 ServiceProviderPtr exposed_services) { | 36 InterfaceHandle<mojo::ServiceProvider> exposed_services) { |
| 36 shell_->ConnectToApplication(app_url, std::move(services), | 37 shell_->ConnectToApplication(app_url, std::move(services), |
| 37 std::move(exposed_services)); | 38 std::move(exposed_services)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ShellImpl::ApplicationConnectorImpl::Duplicate( | 41 void ShellImpl::ApplicationConnectorImpl::Duplicate( |
| 41 InterfaceRequest<ApplicationConnector> application_connector_request) { | 42 InterfaceRequest<ApplicationConnector> application_connector_request) { |
| 42 bindings_.AddBinding(this, std::move(application_connector_request)); | 43 bindings_.AddBinding(this, std::move(application_connector_request)); |
| 43 } | 44 } |
| 44 | 45 |
| 45 // ShellImpl ------------------------------------------------------------------- | 46 // ShellImpl ------------------------------------------------------------------- |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 ShellImpl::~ShellImpl() { | 62 ShellImpl::~ShellImpl() { |
| 62 } | 63 } |
| 63 | 64 |
| 64 void ShellImpl::InitializeApplication(Array<String> args) { | 65 void ShellImpl::InitializeApplication(Array<String> args) { |
| 65 ShellPtr shell; | 66 ShellPtr shell; |
| 66 binding_.Bind(GetProxy(&shell)); | 67 binding_.Bind(GetProxy(&shell)); |
| 67 application_->Initialize(std::move(shell), std::move(args), | 68 application_->Initialize(std::move(shell), std::move(args), |
| 68 identity_.url.spec()); | 69 identity_.url.spec()); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void ShellImpl::ConnectToClient(const GURL& requested_url, | 72 void ShellImpl::ConnectToClient( |
| 72 const GURL& requestor_url, | 73 const GURL& requested_url, |
| 73 InterfaceRequest<ServiceProvider> services, | 74 const GURL& requestor_url, |
| 74 ServiceProviderPtr exposed_services) { | 75 InterfaceRequest<ServiceProvider> services, |
| 76 InterfaceHandle<ServiceProvider> exposed_services) { |
| 75 application_->AcceptConnection( | 77 application_->AcceptConnection( |
| 76 String::From(requestor_url), std::move(services), | 78 String::From(requestor_url), std::move(services), |
| 77 std::move(exposed_services), requested_url.spec()); | 79 std::move(exposed_services), requested_url.spec()); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void ShellImpl::ConnectToApplication(const String& app_url, | 82 void ShellImpl::ConnectToApplication( |
| 81 InterfaceRequest<ServiceProvider> services, | 83 const String& app_url, |
| 82 ServiceProviderPtr exposed_services) { | 84 InterfaceRequest<ServiceProvider> services, |
| 85 InterfaceHandle<mojo::ServiceProvider> exposed_services) { |
| 83 GURL app_gurl(app_url); | 86 GURL app_gurl(app_url); |
| 84 if (!app_gurl.is_valid()) { | 87 if (!app_gurl.is_valid()) { |
| 85 LOG(ERROR) << "Error: invalid URL: " << app_url; | 88 LOG(ERROR) << "Error: invalid URL: " << app_url; |
| 86 return; | 89 return; |
| 87 } | 90 } |
| 88 manager_->ConnectToApplication(app_gurl, identity_.url, std::move(services), | 91 manager_->ConnectToApplication(app_gurl, identity_.url, std::move(services), |
| 89 std::move(exposed_services), base::Closure()); | 92 std::move(exposed_services), base::Closure()); |
| 90 } | 93 } |
| 91 | 94 |
| 92 void ShellImpl::CreateApplicationConnector( | 95 void ShellImpl::CreateApplicationConnector( |
| 93 InterfaceRequest<ApplicationConnector> application_connector_request) { | 96 InterfaceRequest<ApplicationConnector> application_connector_request) { |
| 94 application_connector_impl_.Duplicate( | 97 application_connector_impl_.Duplicate( |
| 95 std::move(application_connector_request)); | 98 std::move(application_connector_request)); |
| 96 } | 99 } |
| 97 | 100 |
| 98 } // namespace shell | 101 } // namespace shell |
| OLD | NEW |