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

Side by Side Diff: components/mus/public/cpp/input_devices/input_device_client.cc

Issue 1992443002: Add Mojo IPC based input-device service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_ddm
Patch Set: Fixes for comments. Created 4 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/mus/public/cpp/input_devices/input_device_client.h"
6
7 #include "base/logging.h"
8
9 namespace input_device {
10
11 InputDeviceClient::InputDeviceClient() : binding_(this) {
12 InputDeviceManager::SetInstance(this);
13 }
14
15 InputDeviceClient::~InputDeviceClient() {
16 InputDeviceManager::ClearInstance();
17 }
18
19 void InputDeviceClient::Connect(mojom::InputDeviceServerPtr server) {
20 DCHECK(server.is_bound());
21
22 // Add this class as an observer via Mojo IPC.
23 server->AddObserver(binding_.CreateInterfacePtrAndBind());
24 binding_.set_connection_error_handler([]() {
25 DLOG(ERROR) << "InputDeviceClient failed to bind observer pipe.";
sadrul 2016/06/08 16:31:09 Note: the failure can happen after bind succeeds.
kylechar 2016/06/08 18:13:16 What's the idiomatic way to log connection errors
26 });
27 }
28
29 void InputDeviceClient::OnKeyboardDeviceConfigurationChanged(
30 mojo::Array<ui::InputDevice> devices) {
31 keyboard_devices_ = devices.To<std::vector<ui::InputDevice>>();
32 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
33 OnKeyboardDeviceConfigurationChanged());
34 }
35
36 void InputDeviceClient::OnTouchscreenDeviceConfigurationChanged(
37 mojo::Array<ui::TouchscreenDevice> devices) {
38 touchscreen_devices_ = devices.To<std::vector<ui::TouchscreenDevice>>();
39 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
40 OnTouchscreenDeviceConfigurationChanged());
41 }
42
43 void InputDeviceClient::OnMouseDeviceConfigurationChanged(
44 mojo::Array<ui::InputDevice> devices) {
45 mouse_devices_ = devices.To<std::vector<ui::InputDevice>>();
46 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
47 OnMouseDeviceConfigurationChanged());
48 }
49
50 void InputDeviceClient::OnTouchpadDeviceConfigurationChanged(
51 mojo::Array<ui::InputDevice> devices) {
52 touchpad_devices_ = devices.To<std::vector<ui::InputDevice>>();
53 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
54 OnTouchpadDeviceConfigurationChanged());
55 }
56
57 void InputDeviceClient::OnDeviceListsComplete() {
58 if (!device_lists_complete_) {
59 device_lists_complete_ = true;
60 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
61 OnDeviceListsComplete());
62 }
63 }
64
65 void InputDeviceClient::AddObserver(ui::InputDeviceEventObserver* observer) {
66 observers_.AddObserver(observer);
67 }
68
69 void InputDeviceClient::RemoveObserver(ui::InputDeviceEventObserver* observer) {
70 observers_.RemoveObserver(observer);
71 }
72
73 const std::vector<ui::InputDevice>& InputDeviceClient::GetKeyboardDevices()
74 const {
75 return keyboard_devices_;
76 }
77
78 const std::vector<ui::TouchscreenDevice>&
79 InputDeviceClient::GetTouchscreenDevices() const {
80 return touchscreen_devices_;
81 }
82
83 const std::vector<ui::InputDevice>& InputDeviceClient::GetMouseDevices() const {
84 return mouse_devices_;
85 }
86
87 const std::vector<ui::InputDevice>& InputDeviceClient::GetTouchpadDevices()
88 const {
89 return touchpad_devices_;
90 }
91
92 bool InputDeviceClient::AreDeviceListsComplete() const {
93 return device_lists_complete_;
94 }
95
96 bool InputDeviceClient::AreTouchscreensEnabled() const {
97 // TODO(kylechar): This obviously isn't right. We either need to pass this
98 // state around or modify the interface.
99 return true;
100 }
101
102 } // namespace input_device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698