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 "components/mus/mus_app.h" | 5 #include "components/mus/mus_app.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/mus/clipboard/clipboard_impl.h" |
15 #include "components/mus/common/switches.h" | 16 #include "components/mus/common/switches.h" |
16 #include "components/mus/gles2/gpu_impl.h" | 17 #include "components/mus/gles2/gpu_impl.h" |
17 #include "components/mus/ws/display.h" | 18 #include "components/mus/ws/display.h" |
18 #include "components/mus/ws/display_binding.h" | 19 #include "components/mus/ws/display_binding.h" |
19 #include "components/mus/ws/display_manager.h" | 20 #include "components/mus/ws/display_manager.h" |
20 #include "components/mus/ws/platform_screen.h" | 21 #include "components/mus/ws/platform_screen.h" |
21 #include "components/mus/ws/user_display_manager.h" | 22 #include "components/mus/ws/user_display_manager.h" |
22 #include "components/mus/ws/window_server.h" | 23 #include "components/mus/ws/window_server.h" |
23 #include "components/mus/ws/window_server_test_impl.h" | 24 #include "components/mus/ws/window_server_test_impl.h" |
24 #include "components/mus/ws/window_tree.h" | 25 #include "components/mus/ws/window_tree.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 63 |
63 } // namespace | 64 } // namespace |
64 | 65 |
65 // TODO(sky): this is a pretty typical pattern, make it easier to do. | 66 // TODO(sky): this is a pretty typical pattern, make it easier to do. |
66 struct MusApp::PendingRequest { | 67 struct MusApp::PendingRequest { |
67 shell::Connection* connection; | 68 shell::Connection* connection; |
68 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; | 69 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; |
69 }; | 70 }; |
70 | 71 |
71 struct MusApp::UserState { | 72 struct MusApp::UserState { |
| 73 std::unique_ptr<clipboard::ClipboardImpl> clipboard; |
72 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 74 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
73 }; | 75 }; |
74 | 76 |
75 MusApp::MusApp() | 77 MusApp::MusApp() |
76 : test_config_(false), | 78 : test_config_(false), |
77 platform_screen_(ws::PlatformScreen::Create()), | 79 platform_screen_(ws::PlatformScreen::Create()), |
78 weak_ptr_factory_(this) {} | 80 weak_ptr_factory_(this) {} |
79 | 81 |
80 MusApp::~MusApp() { | 82 MusApp::~MusApp() { |
81 // Destroy |window_server_| first, since it depends on |event_source_|. | 83 // Destroy |window_server_| first, since it depends on |event_source_|. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 platform_display_init_params_.gpu_state = new GpuState(); | 180 platform_display_init_params_.gpu_state = new GpuState(); |
179 | 181 |
180 // Gpu must be running before the PlatformScreen can be initialized. | 182 // Gpu must be running before the PlatformScreen can be initialized. |
181 platform_screen_->Init(); | 183 platform_screen_->Init(); |
182 window_server_.reset( | 184 window_server_.reset( |
183 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); | 185 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); |
184 } | 186 } |
185 | 187 |
186 bool MusApp::AcceptConnection(Connection* connection) { | 188 bool MusApp::AcceptConnection(Connection* connection) { |
187 connection->AddInterface<Gpu>(this); | 189 connection->AddInterface<Gpu>(this); |
| 190 connection->AddInterface<mojom::Clipboard>(this); |
188 connection->AddInterface<mojom::DisplayManager>(this); | 191 connection->AddInterface<mojom::DisplayManager>(this); |
189 connection->AddInterface<mojom::UserAccessManager>(this); | 192 connection->AddInterface<mojom::UserAccessManager>(this); |
190 connection->AddInterface<WindowTreeHostFactory>(this); | 193 connection->AddInterface<WindowTreeHostFactory>(this); |
191 connection->AddInterface<mojom::WindowManagerFactoryService>(this); | 194 connection->AddInterface<mojom::WindowManagerFactoryService>(this); |
192 connection->AddInterface<mojom::WindowTreeFactory>(this); | 195 connection->AddInterface<mojom::WindowTreeFactory>(this); |
193 if (test_config_) | 196 if (test_config_) |
194 connection->AddInterface<WindowServerTest>(this); | 197 connection->AddInterface<WindowServerTest>(this); |
195 return true; | 198 return true; |
196 } | 199 } |
197 | 200 |
(...skipping 15 matching lines...) Expand all Loading... |
213 } | 216 } |
214 | 217 |
215 void MusApp::CreateDefaultDisplays() { | 218 void MusApp::CreateDefaultDisplays() { |
216 // An asynchronous callback will create the Displays once the physical | 219 // An asynchronous callback will create the Displays once the physical |
217 // displays are ready. | 220 // displays are ready. |
218 platform_screen_->ConfigurePhysicalDisplay(base::Bind( | 221 platform_screen_->ConfigurePhysicalDisplay(base::Bind( |
219 &MusApp::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr())); | 222 &MusApp::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr())); |
220 } | 223 } |
221 | 224 |
222 void MusApp::Create(shell::Connection* connection, | 225 void MusApp::Create(shell::Connection* connection, |
| 226 mojom::ClipboardRequest request) { |
| 227 UserState* user_state = GetUserState(connection); |
| 228 if (!user_state->clipboard) |
| 229 user_state->clipboard.reset(new clipboard::ClipboardImpl); |
| 230 user_state->clipboard->AddBinding(std::move(request)); |
| 231 } |
| 232 |
| 233 void MusApp::Create(shell::Connection* connection, |
223 mojom::DisplayManagerRequest request) { | 234 mojom::DisplayManagerRequest request) { |
224 window_server_->display_manager() | 235 window_server_->display_manager() |
225 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) | 236 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) |
226 ->AddDisplayManagerBinding(std::move(request)); | 237 ->AddDisplayManagerBinding(std::move(request)); |
227 } | 238 } |
228 | 239 |
| 240 void MusApp::Create(shell::Connection* connection, mojom::GpuRequest request) { |
| 241 DCHECK(platform_display_init_params_.gpu_state); |
| 242 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); |
| 243 } |
| 244 |
229 void MusApp::Create(shell::Connection* connection, | 245 void MusApp::Create(shell::Connection* connection, |
230 mojom::UserAccessManagerRequest request) { | 246 mojom::UserAccessManagerRequest request) { |
231 window_server_->user_id_tracker()->Bind(std::move(request)); | 247 window_server_->user_id_tracker()->Bind(std::move(request)); |
232 } | 248 } |
233 | 249 |
234 void MusApp::Create(shell::Connection* connection, | 250 void MusApp::Create(shell::Connection* connection, |
235 mojom::WindowManagerFactoryServiceRequest request) { | 251 mojom::WindowManagerFactoryServiceRequest request) { |
236 AddUserIfNecessary(connection); | 252 AddUserIfNecessary(connection); |
237 window_server_->window_manager_factory_registry()->Register( | 253 window_server_->window_manager_factory_registry()->Register( |
238 connection->GetRemoteIdentity().user_id(), std::move(request)); | 254 connection->GetRemoteIdentity().user_id(), std::move(request)); |
(...skipping 28 matching lines...) Expand all Loading... |
267 user_state->window_tree_host_factory->AddBinding(std::move(request)); | 283 user_state->window_tree_host_factory->AddBinding(std::move(request)); |
268 } | 284 } |
269 | 285 |
270 void MusApp::Create(Connection* connection, | 286 void MusApp::Create(Connection* connection, |
271 mojom::WindowServerTestRequest request) { | 287 mojom::WindowServerTestRequest request) { |
272 if (!test_config_) | 288 if (!test_config_) |
273 return; | 289 return; |
274 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); | 290 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); |
275 } | 291 } |
276 | 292 |
277 void MusApp::Create(shell::Connection* connection, mojom::GpuRequest request) { | |
278 DCHECK(platform_display_init_params_.gpu_state); | |
279 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); | |
280 } | |
281 | |
282 void MusApp::OnCreatedPhysicalDisplay(int64_t id, const gfx::Rect& bounds) { | 293 void MusApp::OnCreatedPhysicalDisplay(int64_t id, const gfx::Rect& bounds) { |
283 platform_display_init_params_.display_bounds = bounds; | 294 platform_display_init_params_.display_bounds = bounds; |
284 platform_display_init_params_.display_id = id; | 295 platform_display_init_params_.display_id = id; |
285 | 296 |
286 // Display manages its own lifetime. | 297 // Display manages its own lifetime. |
287 ws::Display* host_impl = | 298 ws::Display* host_impl = |
288 new ws::Display(window_server_.get(), platform_display_init_params_); | 299 new ws::Display(window_server_.get(), platform_display_init_params_); |
289 host_impl->Init(nullptr); | 300 host_impl->Init(nullptr); |
290 } | 301 } |
291 | 302 |
292 } // namespace mus | 303 } // namespace mus |
OLD | NEW |