OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/launcher/launch_instance.h" | 5 #include "services/ui/launcher/launch_instance.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
11 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/c/system/main.h" |
12 #include "mojo/public/cpp/application/application_connection.h" | 12 #include "mojo/public/cpp/application/application_connection.h" |
13 #include "mojo/public/cpp/application/application_impl.h" | 13 #include "mojo/public/cpp/application/application_impl.h" |
| 14 #include "mojo/public/cpp/application/connect.h" |
14 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" | 15 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" |
15 #include "services/ui/launcher/launcher_view_tree.h" | 16 #include "services/ui/launcher/launcher_view_tree.h" |
16 | 17 |
17 namespace launcher { | 18 namespace launcher { |
18 | 19 |
19 LaunchInstance::LaunchInstance(mojo::ApplicationImpl* app_impl, | 20 LaunchInstance::LaunchInstance(mojo::ApplicationImpl* app_impl, |
20 const std::string& app_url, | 21 const std::string& app_url, |
21 const base::Closure& shutdown_callback) | 22 const base::Closure& shutdown_callback) |
22 : app_impl_(app_impl), | 23 : app_impl_(app_impl), |
23 app_url_(app_url), | 24 app_url_(app_url), |
24 shutdown_callback_(shutdown_callback), | 25 shutdown_callback_(shutdown_callback), |
25 viewport_event_dispatcher_binding_(this) {} | 26 viewport_event_dispatcher_binding_(this) {} |
26 | 27 |
27 LaunchInstance::~LaunchInstance() {} | 28 LaunchInstance::~LaunchInstance() {} |
28 | 29 |
29 void LaunchInstance::Launch() { | 30 void LaunchInstance::Launch() { |
30 DVLOG(1) << "Launching " << app_url_; | 31 DVLOG(1) << "Launching " << app_url_; |
31 TRACE_EVENT0("launcher", __func__); | 32 TRACE_EVENT0("launcher", __func__); |
32 | 33 |
33 app_impl_->ConnectToServiceDeprecated("mojo:compositor_service", | 34 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", |
34 &compositor_); | 35 GetProxy(&compositor_)); |
35 compositor_.set_connection_error_handler(base::Bind( | 36 compositor_.set_connection_error_handler(base::Bind( |
36 &LaunchInstance::OnCompositorConnectionError, base::Unretained(this))); | 37 &LaunchInstance::OnCompositorConnectionError, base::Unretained(this))); |
37 | 38 |
38 app_impl_->ConnectToServiceDeprecated("mojo:view_manager_service", | 39 mojo::ConnectToService(app_impl_->shell(), "mojo:view_manager_service", |
39 &view_manager_); | 40 GetProxy(&view_manager_)); |
40 view_manager_.set_connection_error_handler(base::Bind( | 41 view_manager_.set_connection_error_handler(base::Bind( |
41 &LaunchInstance::OnViewManagerConnectionError, base::Unretained(this))); | 42 &LaunchInstance::OnViewManagerConnectionError, base::Unretained(this))); |
42 | 43 |
43 InitViewport(); | 44 InitViewport(); |
44 | 45 |
45 mojo::ui::ViewProviderPtr client_view_provider; | 46 mojo::ui::ViewProviderPtr client_view_provider; |
46 app_impl_->ConnectToServiceDeprecated(app_url_, &client_view_provider); | 47 mojo::ConnectToService(app_impl_->shell(), app_url_, |
| 48 GetProxy(&client_view_provider)); |
47 | 49 |
48 client_view_provider->CreateView(mojo::GetProxy(&client_view_owner_), nullptr, | 50 client_view_provider->CreateView(GetProxy(&client_view_owner_), nullptr, |
49 nullptr); | 51 nullptr); |
50 } | 52 } |
51 | 53 |
52 void LaunchInstance::OnCompositorConnectionError() { | 54 void LaunchInstance::OnCompositorConnectionError() { |
53 LOG(ERROR) << "Exiting due to compositor connection error."; | 55 LOG(ERROR) << "Exiting due to compositor connection error."; |
54 shutdown_callback_.Run(); | 56 shutdown_callback_.Run(); |
55 } | 57 } |
56 | 58 |
57 void LaunchInstance::OnViewManagerConnectionError() { | 59 void LaunchInstance::OnViewManagerConnectionError() { |
58 LOG(ERROR) << "Exiting due to view manager connection error."; | 60 LOG(ERROR) << "Exiting due to view manager connection error."; |
59 shutdown_callback_.Run(); | 61 shutdown_callback_.Run(); |
60 } | 62 } |
61 | 63 |
62 void LaunchInstance::InitViewport() { | 64 void LaunchInstance::InitViewport() { |
63 app_impl_->ConnectToServiceDeprecated("mojo:native_viewport_service", | 65 mojo::ConnectToService(app_impl_->shell(), "mojo:native_viewport_service", |
64 &viewport_); | 66 GetProxy(&viewport_)); |
65 viewport_.set_connection_error_handler(base::Bind( | 67 viewport_.set_connection_error_handler(base::Bind( |
66 &LaunchInstance::OnViewportConnectionError, base::Unretained(this))); | 68 &LaunchInstance::OnViewportConnectionError, base::Unretained(this))); |
67 | 69 |
68 mojo::NativeViewportEventDispatcherPtr dispatcher; | 70 mojo::NativeViewportEventDispatcherPtr dispatcher; |
69 viewport_event_dispatcher_binding_.Bind(GetProxy(&dispatcher)); | 71 viewport_event_dispatcher_binding_.Bind(GetProxy(&dispatcher)); |
70 viewport_->SetEventDispatcher(dispatcher.Pass()); | 72 viewport_->SetEventDispatcher(dispatcher.Pass()); |
71 | 73 |
72 // Match the Nexus 5 aspect ratio initially. | 74 // Match the Nexus 5 aspect ratio initially. |
73 auto size = mojo::Size::New(); | 75 auto size = mojo::Size::New(); |
74 size->width = 320; | 76 size->width = 320; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 115 } |
114 | 116 |
115 void LaunchInstance::OnEvent(mojo::EventPtr event, | 117 void LaunchInstance::OnEvent(mojo::EventPtr event, |
116 const mojo::Callback<void()>& callback) { | 118 const mojo::Callback<void()>& callback) { |
117 if (view_tree_) | 119 if (view_tree_) |
118 view_tree_->DispatchEvent(event.Pass()); | 120 view_tree_->DispatchEvent(event.Pass()); |
119 callback.Run(); | 121 callback.Run(); |
120 } | 122 } |
121 | 123 |
122 } // namespace launcher | 124 } // namespace launcher |
OLD | NEW |