OLD | NEW |
---|---|
(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 #ifndef COMPONENTS_MUS_PUBLIC_CPP_INPUT_DEVICES_INPUT_DEVICE_CLIENT_H_ | |
6 #define COMPONENTS_MUS_PUBLIC_CPP_INPUT_DEVICES_INPUT_DEVICE_CLIENT_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/observer_list.h" | |
12 #include "components/mus/public/interfaces/input_devices/input_devices.mojom.h" | |
13 #include "mojo/public/cpp/bindings/array.h" | |
14 #include "mojo/public/cpp/bindings/binding.h" | |
15 #include "ui/events/devices/input_device.h" | |
16 #include "ui/events/devices/input_device_event_observer.h" | |
17 #include "ui/events/devices/input_device_manager.h" | |
18 #include "ui/events/devices/touchscreen_device.h" | |
19 | |
20 namespace input_device { | |
21 | |
22 // Allows in-process client code to register as a ui:::InputDeviceEventObserver | |
23 // and get information about input-devices. InputDeviceClient itself acts as an | |
24 // InputDeviceObserverMojo and registers to get updates from InputDeviceServer. | |
25 // Essentially, InputDeviceClient forwards input-device events and caches | |
26 // input-device state. | |
27 // | |
28 // One instance of InputDeviceClient should be instantiated in each process that | |
29 // doesn't have a DeviceDataManager. The Mojo app should call Connect() with the | |
30 // mojo shell connector to register as an observer with mus. Client code should | |
31 // use InputDeviceManager and doesn't need to be aware it's not dealing with | |
32 // DeviceDataManager directly. | |
33 class InputDeviceClient : public mojom::InputDeviceObserverMojo, | |
34 public ui::InputDeviceManager { | |
35 public: | |
36 InputDeviceClient(); | |
37 ~InputDeviceClient() override; | |
38 | |
39 // Connects to mojo:mus as an observer on InputDeviceServer to receive input | |
40 // device updates. | |
41 void Connect(mojom::InputDeviceServerPtr server); | |
42 | |
43 // mojom::InputDeviceObserverMojo: | |
sadrul
2016/06/07 03:39:26
Make these overrides private (or protected) to cla
kylechar
2016/06/07 16:36:41
Done.
| |
44 void OnKeyboardDeviceConfigurationChanged( | |
45 mojo::Array<ui::InputDevice> devices) override; | |
46 void OnTouchscreenDeviceConfigurationChanged( | |
47 mojo::Array<ui::TouchscreenDevice> devices) override; | |
48 void OnMouseDeviceConfigurationChanged( | |
49 mojo::Array<ui::InputDevice> devices) override; | |
50 void OnTouchpadDeviceConfigurationChanged( | |
51 mojo::Array<ui::InputDevice> devices) override; | |
52 void OnDeviceListsComplete() override; | |
53 | |
54 // ui::InputDeviceManager: | |
55 const std::vector<ui::InputDevice>& GetKeyboardDevices() const override; | |
56 const std::vector<ui::TouchscreenDevice>& GetTouchscreenDevices() | |
57 const override; | |
58 const std::vector<ui::InputDevice>& GetMouseDevices() const override; | |
59 const std::vector<ui::InputDevice>& GetTouchpadDevices() const override; | |
60 | |
61 bool AreDeviceListsComplete() const override; | |
62 bool AreTouchscreensEnabled() const override; | |
63 | |
64 void AddObserver(ui::InputDeviceEventObserver* observer) override; | |
65 void RemoveObserver(ui::InputDeviceEventObserver* observer) override; | |
66 | |
67 private: | |
68 mojo::Binding<mojom::InputDeviceObserverMojo> binding_; | |
69 | |
70 // Holds the list of input devices and signal that we have received the lists | |
71 // after initialization. | |
72 std::vector<ui::InputDevice> keyboard_devices_; | |
73 std::vector<ui::TouchscreenDevice> touchscreen_devices_; | |
74 std::vector<ui::InputDevice> mouse_devices_; | |
75 std::vector<ui::InputDevice> touchpad_devices_; | |
76 bool device_lists_complete_ = false; | |
77 | |
78 // List of observers in this process. | |
79 base::ObserverList<ui::InputDeviceEventObserver> observers_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(InputDeviceClient); | |
82 }; | |
83 | |
84 } // namespace input_device | |
85 | |
86 #endif // COMPONENTS_MUS_PUBLIC_CPP_INPUT_DEVICES_INPUT_DEVICE_CLIENT_H_ | |
OLD | NEW |