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 "services/ui/service.h" | 5 #include "services/ui/service.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 "mojo/public/c/system/main.h" | 15 #include "mojo/public/c/system/main.h" |
16 #include "services/catalog/public/cpp/resource_loader.h" | 16 #include "services/catalog/public/cpp/resource_loader.h" |
17 #include "services/shell/public/cpp/connection.h" | 17 #include "services/shell/public/cpp/connection.h" |
18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
19 #include "services/tracing/public/cpp/tracing_impl.h" | 19 #include "services/tracing/public/cpp/tracing_impl.h" |
20 #include "services/ui/clipboard/clipboard_impl.h" | 20 #include "services/ui/clipboard/clipboard_impl.h" |
21 #include "services/ui/common/switches.h" | 21 #include "services/ui/common/switches.h" |
22 #include "services/ui/gles2/gpu_impl.h" | 22 #include "services/ui/gles2/gpu_impl.h" |
23 #include "services/ui/gpu/gpu_service_impl.h" | 23 #include "services/ui/gpu/gpu_service_impl.h" |
24 #include "services/ui/gpu/gpu_service_mus.h" | 24 #include "services/ui/gpu/gpu_service_mus.h" |
| 25 #include "services/ui/ws/accessibility_manager.h" |
25 #include "services/ui/ws/display.h" | 26 #include "services/ui/ws/display.h" |
26 #include "services/ui/ws/display_binding.h" | 27 #include "services/ui/ws/display_binding.h" |
27 #include "services/ui/ws/display_manager.h" | 28 #include "services/ui/ws/display_manager.h" |
28 #include "services/ui/ws/platform_screen.h" | 29 #include "services/ui/ws/platform_screen.h" |
29 #include "services/ui/ws/user_activity_monitor.h" | 30 #include "services/ui/ws/user_activity_monitor.h" |
30 #include "services/ui/ws/user_display_manager.h" | 31 #include "services/ui/ws/user_display_manager.h" |
31 #include "services/ui/ws/window_server.h" | 32 #include "services/ui/ws/window_server.h" |
32 #include "services/ui/ws/window_server_test_impl.h" | 33 #include "services/ui/ws/window_server_test_impl.h" |
33 #include "services/ui/ws/window_tree.h" | 34 #include "services/ui/ws/window_tree.h" |
34 #include "services/ui/ws/window_tree_binding.h" | 35 #include "services/ui/ws/window_tree_binding.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 // TODO(sky): this is a pretty typical pattern, make it easier to do. | 70 // TODO(sky): this is a pretty typical pattern, make it easier to do. |
70 struct Service::PendingRequest { | 71 struct Service::PendingRequest { |
71 shell::Connection* connection; | 72 shell::Connection* connection; |
72 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; | 73 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; |
73 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; | 74 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; |
74 }; | 75 }; |
75 | 76 |
76 struct Service::UserState { | 77 struct Service::UserState { |
77 std::unique_ptr<clipboard::ClipboardImpl> clipboard; | 78 std::unique_ptr<clipboard::ClipboardImpl> clipboard; |
| 79 std::unique_ptr<ws::AccessibilityManager> accessibility; |
78 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 80 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
79 }; | 81 }; |
80 | 82 |
81 Service::Service() | 83 Service::Service() |
82 : test_config_(false), | 84 : test_config_(false), |
83 // TODO(penghuang): Kludge: Use mojo command buffer when running on | 85 // TODO(penghuang): Kludge: Use mojo command buffer when running on |
84 // Windows since chrome command buffer breaks unit tests | 86 // Windows since chrome command buffer breaks unit tests |
85 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
86 use_chrome_gpu_command_buffer_(false), | 88 use_chrome_gpu_command_buffer_(false), |
87 #else | 89 #else |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); | 219 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); |
218 | 220 |
219 // DeviceDataManager must be initialized before TouchController. On non-Linux | 221 // DeviceDataManager must be initialized before TouchController. On non-Linux |
220 // platforms there is no DeviceDataManager so don't create touch controller. | 222 // platforms there is no DeviceDataManager so don't create touch controller. |
221 if (ui::DeviceDataManager::HasInstance()) | 223 if (ui::DeviceDataManager::HasInstance()) |
222 touch_controller_.reset( | 224 touch_controller_.reset( |
223 new ws::TouchController(window_server_->display_manager())); | 225 new ws::TouchController(window_server_->display_manager())); |
224 } | 226 } |
225 | 227 |
226 bool Service::OnConnect(Connection* connection) { | 228 bool Service::OnConnect(Connection* connection) { |
| 229 connection->AddInterface<mojom::AccessibilityManager>(this); |
227 connection->AddInterface<mojom::Clipboard>(this); | 230 connection->AddInterface<mojom::Clipboard>(this); |
228 connection->AddInterface<mojom::DisplayManager>(this); | 231 connection->AddInterface<mojom::DisplayManager>(this); |
229 connection->AddInterface<mojom::UserAccessManager>(this); | 232 connection->AddInterface<mojom::UserAccessManager>(this); |
230 connection->AddInterface<mojom::UserActivityMonitor>(this); | 233 connection->AddInterface<mojom::UserActivityMonitor>(this); |
231 connection->AddInterface<WindowTreeHostFactory>(this); | 234 connection->AddInterface<WindowTreeHostFactory>(this); |
232 connection->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); | 235 connection->AddInterface<mojom::WindowManagerWindowTreeFactory>(this); |
233 connection->AddInterface<mojom::WindowTreeFactory>(this); | 236 connection->AddInterface<mojom::WindowTreeFactory>(this); |
234 if (test_config_) | 237 if (test_config_) |
235 connection->AddInterface<WindowServerTest>(this); | 238 connection->AddInterface<WindowServerTest>(this); |
236 | 239 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 277 } |
275 | 278 |
276 void Service::CreateDefaultDisplays() { | 279 void Service::CreateDefaultDisplays() { |
277 // An asynchronous callback will create the Displays once the physical | 280 // An asynchronous callback will create the Displays once the physical |
278 // displays are ready. | 281 // displays are ready. |
279 platform_screen_->ConfigurePhysicalDisplay(base::Bind( | 282 platform_screen_->ConfigurePhysicalDisplay(base::Bind( |
280 &Service::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr())); | 283 &Service::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr())); |
281 } | 284 } |
282 | 285 |
283 void Service::Create(shell::Connection* connection, | 286 void Service::Create(shell::Connection* connection, |
| 287 mojom::AccessibilityManagerRequest request) { |
| 288 UserState* user_state = GetUserState(connection); |
| 289 if (!user_state->accessibility) { |
| 290 user_state->accessibility.reset( |
| 291 new ws::AccessibilityManager(window_server_.get())); |
| 292 } |
| 293 user_state->accessibility->Bind(std::move(request)); |
| 294 } |
| 295 |
| 296 void Service::Create(shell::Connection* connection, |
284 mojom::ClipboardRequest request) { | 297 mojom::ClipboardRequest request) { |
285 UserState* user_state = GetUserState(connection); | 298 UserState* user_state = GetUserState(connection); |
286 if (!user_state->clipboard) | 299 if (!user_state->clipboard) |
287 user_state->clipboard.reset(new clipboard::ClipboardImpl); | 300 user_state->clipboard.reset(new clipboard::ClipboardImpl); |
288 user_state->clipboard->AddBinding(std::move(request)); | 301 user_state->clipboard->AddBinding(std::move(request)); |
289 } | 302 } |
290 | 303 |
291 void Service::Create(shell::Connection* connection, | 304 void Service::Create(shell::Connection* connection, |
292 mojom::DisplayManagerRequest request) { | 305 mojom::DisplayManagerRequest request) { |
293 // DisplayManagerObservers generally expect there to be at least one display. | 306 // DisplayManagerObservers generally expect there to be at least one display. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // Display manages its own lifetime. | 393 // Display manages its own lifetime. |
381 ws::Display* host_impl = | 394 ws::Display* host_impl = |
382 new ws::Display(window_server_.get(), platform_display_init_params_); | 395 new ws::Display(window_server_.get(), platform_display_init_params_); |
383 host_impl->Init(nullptr); | 396 host_impl->Init(nullptr); |
384 | 397 |
385 if (touch_controller_) | 398 if (touch_controller_) |
386 touch_controller_->UpdateTouchTransforms(); | 399 touch_controller_->UpdateTouchTransforms(); |
387 } | 400 } |
388 | 401 |
389 } // namespace ui | 402 } // namespace ui |
OLD | NEW |