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_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | |
6 #define COMPONENTS_MUS_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "components/mus/public/interfaces/input_devices/input_devices.mojom.h" | |
10 #include "mojo/public/cpp/bindings/binding_set.h" | |
11 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | |
12 #include "services/shell/public/cpp/connection.h" | |
13 #include "services/shell/public/cpp/interface_factory.h" | |
14 #include "ui/events/devices/device_data_manager.h" | |
15 #include "ui/events/devices/input_device_event_observer.h" | |
16 | |
17 namespace input_device { | |
18 | |
19 // Listens to DeviceDataManager for updates on input-devices and forwards those | |
20 // updates to any registered InputDeviceObserverMojo in other processes via | |
21 // Mojo IPC. The mus-ws process should will own this. | |
sadrul
2016/06/07 03:39:25
s/should//?
kylechar
2016/06/07 16:36:41
Done.
| |
22 class InputDeviceServer | |
23 : public shell::InterfaceFactory<mojom::InputDeviceServer>, | |
24 public mojom::InputDeviceServer, | |
25 public ui::InputDeviceEventObserver { | |
26 public: | |
27 InputDeviceServer(); | |
28 ~InputDeviceServer() override; | |
29 | |
30 // Registers this instance as a local observer with DeviceDataManager. | |
31 void RegisterAsObserver(); | |
32 | |
33 // Registers interface with the shell connection so remote observers can | |
34 // connect. You should have already called RegisterAsObserver() to get | |
35 // local input-device event updates. | |
36 void RegisterInterface(shell::Connection* connection); | |
37 | |
38 // mojo::InterfaceFactory<mojom::InputDeviceServer>: | |
39 void Create(shell::Connection* connection, | |
40 mojom::InputDeviceServerRequest request) override; | |
41 | |
42 // mojom::InputDeviceServer: | |
43 void AddObserver(mojom::InputDeviceObserverMojoPtr observer) override; | |
44 | |
45 // ui::InputDeviceEventObserver: | |
46 void OnKeyboardDeviceConfigurationChanged() override; | |
47 void OnTouchscreenDeviceConfigurationChanged() override; | |
48 void OnMouseDeviceConfigurationChanged() override; | |
49 void OnTouchpadDeviceConfigurationChanged() override; | |
50 void OnDeviceListsComplete() override; | |
51 | |
52 private: | |
53 // Sends the current state of input devices to new observers. | |
54 void SendInputDeviceState(mojom::InputDeviceObserverMojo* observer); | |
55 | |
56 mojo::BindingSet<mojom::InputDeviceServer> bindings_; | |
57 mojo::InterfacePtrSet<mojom::InputDeviceObserverMojo> observers_; | |
58 | |
59 // DeviceDataManager instance we are registered as an observer with. | |
60 ui::DeviceDataManager* manager_ = nullptr; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(InputDeviceServer); | |
63 }; | |
64 | |
65 } // namespace input_device | |
66 | |
67 #endif // COMPONENTS_MUS_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | |
OLD | NEW |