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 "mojo/converters/url/url_type_converters.h" | 7 #include "mojo/converters/url/url_type_converters.h" |
8 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" | 8 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" |
9 #include "shell/application_manager/application_manager.h" | 9 #include "shell/application_manager/application_manager.h" |
10 | 10 |
11 using mojo::ServiceProvider; | 11 using mojo::ServiceProvider; |
12 using mojo::ServiceProviderPtr; | 12 using mojo::ServiceProviderPtr; |
13 | 13 |
14 namespace shell { | 14 namespace shell { |
15 | 15 |
16 ShellImpl::ShellImpl(mojo::ApplicationPtr application, | 16 ShellImpl::ShellImpl(mojo::ApplicationPtr application, |
17 ApplicationManager* manager, | 17 ApplicationManager* manager, |
18 const Identity& identity, | 18 const Identity& identity, |
19 const base::Closure& on_application_end) | 19 const base::Closure& on_application_end) |
20 : manager_(manager), | 20 : manager_(manager), |
21 identity_(identity), | 21 identity_(identity), |
22 on_application_end_(on_application_end), | 22 on_application_end_(on_application_end), |
23 application_(application.Pass()), | 23 application_(application.Pass()), |
24 binding_(this) { | 24 binding_(this), |
| 25 application_connector_impl_(this) { |
25 binding_.set_connection_error_handler( | 26 binding_.set_connection_error_handler( |
26 [this]() { manager_->OnShellImplError(this); }); | 27 [this]() { manager_->OnShellImplError(this); }); |
27 } | 28 } |
28 | 29 |
29 ShellImpl::~ShellImpl() { | 30 ShellImpl::~ShellImpl() { |
30 } | 31 } |
31 | 32 |
32 void ShellImpl::InitializeApplication(mojo::Array<mojo::String> args) { | 33 void ShellImpl::InitializeApplication(mojo::Array<mojo::String> args) { |
33 mojo::ShellPtr shell; | 34 mojo::ShellPtr shell; |
34 binding_.Bind(mojo::GetProxy(&shell)); | 35 binding_.Bind(mojo::GetProxy(&shell)); |
35 application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec()); | 36 application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec()); |
36 } | 37 } |
37 | 38 |
38 void ShellImpl::ConnectToClient( | 39 void ShellImpl::ConnectToClient( |
39 const GURL& requested_url, | 40 const GURL& requested_url, |
40 const GURL& requestor_url, | 41 const GURL& requestor_url, |
41 mojo::InterfaceRequest<ServiceProvider> services, | 42 mojo::InterfaceRequest<ServiceProvider> services, |
42 ServiceProviderPtr exposed_services) { | 43 ServiceProviderPtr exposed_services) { |
43 application_->AcceptConnection(mojo::String::From(requestor_url), | 44 application_->AcceptConnection(mojo::String::From(requestor_url), |
44 services.Pass(), exposed_services.Pass(), | 45 services.Pass(), exposed_services.Pass(), |
45 requested_url.spec()); | 46 requested_url.spec()); |
46 } | 47 } |
47 | 48 |
48 // Shell implementation: | |
49 void ShellImpl::ConnectToApplication( | 49 void ShellImpl::ConnectToApplication( |
50 const mojo::String& app_url, | 50 const mojo::String& app_url, |
51 mojo::InterfaceRequest<ServiceProvider> services, | 51 mojo::InterfaceRequest<ServiceProvider> services, |
52 ServiceProviderPtr exposed_services) { | 52 ServiceProviderPtr exposed_services) { |
53 GURL app_gurl(app_url); | 53 GURL app_gurl(app_url); |
54 if (!app_gurl.is_valid()) { | 54 if (!app_gurl.is_valid()) { |
55 LOG(ERROR) << "Error: invalid URL: " << app_url; | 55 LOG(ERROR) << "Error: invalid URL: " << app_url; |
56 return; | 56 return; |
57 } | 57 } |
58 manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(), | 58 manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(), |
59 exposed_services.Pass(), base::Closure()); | 59 exposed_services.Pass(), base::Closure()); |
60 } | 60 } |
61 | 61 |
| 62 void ShellImpl::CreateApplicationConnector( |
| 63 mojo::InterfaceRequest<mojo::ApplicationConnector> |
| 64 application_connector_request) { |
| 65 application_connectors_.AddBinding(&application_connector_impl_, |
| 66 application_connector_request.Pass()); |
| 67 } |
| 68 |
62 } // namespace shell | 69 } // namespace shell |
OLD | NEW |