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" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 // 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. |
71 struct Service::PendingRequest { | 71 struct Service::PendingRequest { |
72 shell::Connection* connection; | 72 shell::Connection* connection; |
73 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; | 73 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; |
74 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; | 74 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; |
75 }; | 75 }; |
76 | 76 |
77 struct Service::UserState { | 77 struct Service::UserState { |
78 std::unique_ptr<clipboard::ClipboardImpl> clipboard; | |
79 std::unique_ptr<ws::AccessibilityManager> accessibility; | 78 std::unique_ptr<ws::AccessibilityManager> accessibility; |
80 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 79 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
81 }; | 80 }; |
82 | 81 |
83 Service::Service() | 82 Service::Service() |
84 : test_config_(false), | 83 : test_config_(false), |
85 // TODO(penghuang): Kludge: Use mojo command buffer when running on | 84 // TODO(penghuang): Kludge: Use mojo command buffer when running on |
86 // Windows since chrome command buffer breaks unit tests | 85 // Windows since chrome command buffer breaks unit tests |
87 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
88 use_chrome_gpu_command_buffer_(false), | 87 use_chrome_gpu_command_buffer_(false), |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (!user_state->accessibility) { | 288 if (!user_state->accessibility) { |
290 const ws::UserId& user_id = connection->GetRemoteIdentity().user_id(); | 289 const ws::UserId& user_id = connection->GetRemoteIdentity().user_id(); |
291 user_state->accessibility.reset( | 290 user_state->accessibility.reset( |
292 new ws::AccessibilityManager(window_server_.get(), user_id)); | 291 new ws::AccessibilityManager(window_server_.get(), user_id)); |
293 } | 292 } |
294 user_state->accessibility->Bind(std::move(request)); | 293 user_state->accessibility->Bind(std::move(request)); |
295 } | 294 } |
296 | 295 |
297 void Service::Create(shell::Connection* connection, | 296 void Service::Create(shell::Connection* connection, |
298 mojom::ClipboardRequest request) { | 297 mojom::ClipboardRequest request) { |
299 UserState* user_state = GetUserState(connection); | 298 const ws::UserId& user_id = connection->GetRemoteIdentity().user_id(); |
300 if (!user_state->clipboard) | 299 window_server_->GetClipboardForUser(user_id)->AddBinding(std::move(request)); |
301 user_state->clipboard.reset(new clipboard::ClipboardImpl); | |
302 user_state->clipboard->AddBinding(std::move(request)); | |
303 } | 300 } |
304 | 301 |
305 void Service::Create(shell::Connection* connection, | 302 void Service::Create(shell::Connection* connection, |
306 mojom::DisplayManagerRequest request) { | 303 mojom::DisplayManagerRequest request) { |
307 // DisplayManagerObservers generally expect there to be at least one display. | 304 // DisplayManagerObservers generally expect there to be at least one display. |
308 if (!window_server_->display_manager()->has_displays()) { | 305 if (!window_server_->display_manager()->has_displays()) { |
309 std::unique_ptr<PendingRequest> pending_request(new PendingRequest); | 306 std::unique_ptr<PendingRequest> pending_request(new PendingRequest); |
310 pending_request->connection = connection; | 307 pending_request->connection = connection; |
311 pending_request->dm_request.reset( | 308 pending_request->dm_request.reset( |
312 new mojom::DisplayManagerRequest(std::move(request))); | 309 new mojom::DisplayManagerRequest(std::move(request))); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // Display manages its own lifetime. | 391 // Display manages its own lifetime. |
395 ws::Display* host_impl = | 392 ws::Display* host_impl = |
396 new ws::Display(window_server_.get(), platform_display_init_params_); | 393 new ws::Display(window_server_.get(), platform_display_init_params_); |
397 host_impl->Init(nullptr); | 394 host_impl->Init(nullptr); |
398 | 395 |
399 if (touch_controller_) | 396 if (touch_controller_) |
400 touch_controller_->UpdateTouchTransforms(); | 397 touch_controller_->UpdateTouchTransforms(); |
401 } | 398 } |
402 | 399 |
403 } // namespace ui | 400 } // namespace ui |
OLD | NEW |