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