Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: services/ui/input_devices/input_device_server.cc

Issue 2901563002: chromeos: adds TouchDeviceServer and wires up in mushrome (Closed)
Patch Set: no temporary Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/input_devices/input_device_server.h" 5 #include "services/ui/input_devices/input_device_server.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "services/service_manager/public/cpp/bind_source_info.h" 10 #include "services/service_manager/public/cpp/bind_source_info.h"
11 #include "services/service_manager/public/cpp/binder_registry.h" 11 #include "services/service_manager/public/cpp/binder_registry.h"
12 #include "ui/events/devices/input_device.h" 12 #include "ui/events/devices/input_device.h"
13 #include "ui/events/devices/touchscreen_device.h" 13 #include "ui/events/devices/touchscreen_device.h"
14 14
15 #if defined(OS_CHROMEOS)
16 #include "services/ui/input_devices/touch_device_server.h"
17 #endif
18
15 namespace ui { 19 namespace ui {
16 20
17 InputDeviceServer::InputDeviceServer() {} 21 InputDeviceServer::InputDeviceServer() {
22 #if defined(OS_CHROMEOS)
23 touch_device_server_ = base::MakeUnique<TouchDeviceServer>();
24 #endif
25 }
18 26
19 InputDeviceServer::~InputDeviceServer() { 27 InputDeviceServer::~InputDeviceServer() {
20 if (manager_ && ui::DeviceDataManager::HasInstance()) { 28 if (manager_ && ui::DeviceDataManager::HasInstance()) {
21 manager_->RemoveObserver(this); 29 manager_->RemoveObserver(this);
22 manager_ = nullptr; 30 manager_ = nullptr;
23 } 31 }
24 } 32 }
25 33
26 void InputDeviceServer::RegisterAsObserver() { 34 void InputDeviceServer::RegisterAsObserver() {
27 if (!manager_ && ui::DeviceDataManager::HasInstance()) { 35 if (!manager_ && ui::DeviceDataManager::HasInstance()) {
28 manager_ = ui::DeviceDataManager::GetInstance(); 36 manager_ = ui::DeviceDataManager::GetInstance();
29 manager_->AddObserver(this); 37 manager_->AddObserver(this);
30 } 38 }
31 } 39 }
32 40
33 bool InputDeviceServer::IsRegisteredAsObserver() const { 41 bool InputDeviceServer::IsRegisteredAsObserver() const {
34 return manager_ != nullptr; 42 return manager_ != nullptr;
35 } 43 }
36 44
37 void InputDeviceServer::AddInterface( 45 void InputDeviceServer::AddInterface(
38 service_manager::BinderRegistry* registry) { 46 service_manager::BinderRegistry* registry) {
39 DCHECK(IsRegisteredAsObserver()); 47 DCHECK(IsRegisteredAsObserver());
40 registry->AddInterface<mojom::InputDeviceServer>( 48 registry->AddInterface<mojom::InputDeviceServer>(
41 base::Bind(&InputDeviceServer::BindInputDeviceServerRequest, 49 base::Bind(&InputDeviceServer::BindInputDeviceServerRequest,
42 base::Unretained(this))); 50 base::Unretained(this)));
51 #if defined(OS_CHROMEOS)
52 touch_device_server_->AddInterface(registry);
53 #endif
43 } 54 }
44 55
45 void InputDeviceServer::AddObserver( 56 void InputDeviceServer::AddObserver(
46 mojom::InputDeviceObserverMojoPtr observer) { 57 mojom::InputDeviceObserverMojoPtr observer) {
47 // We only want to send this message once, so we need to check to make sure 58 // We only want to send this message once, so we need to check to make sure
48 // device lists are actually complete before sending it to a new observer. 59 // device lists are actually complete before sending it to a new observer.
49 if (manager_->AreDeviceListsComplete()) 60 if (manager_->AreDeviceListsComplete())
50 SendDeviceListsComplete(observer.get()); 61 SendDeviceListsComplete(observer.get());
51 observers_.AddPtr(std::move(observer)); 62 observers_.AddPtr(std::move(observer));
52 } 63 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 manager_->GetMouseDevices(), manager_->GetTouchpadDevices()); 123 manager_->GetMouseDevices(), manager_->GetTouchpadDevices());
113 } 124 }
114 125
115 void InputDeviceServer::BindInputDeviceServerRequest( 126 void InputDeviceServer::BindInputDeviceServerRequest(
116 const service_manager::BindSourceInfo& source_info, 127 const service_manager::BindSourceInfo& source_info,
117 mojom::InputDeviceServerRequest request) { 128 mojom::InputDeviceServerRequest request) {
118 bindings_.AddBinding(this, std::move(request)); 129 bindings_.AddBinding(this, std::move(request));
119 } 130 }
120 131
121 } // namespace ui 132 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/input_devices/input_device_server.h ('k') | services/ui/input_devices/touch_device_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698