OLD | NEW |
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 #ifndef SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | 5 #ifndef SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ |
6 #define SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | 6 #define SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
10 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 10 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
11 #include "services/service_manager/public/cpp/connection.h" | 11 #include "services/service_manager/public/cpp/connection.h" |
12 #include "services/service_manager/public/cpp/interface_factory.h" | 12 #include "services/service_manager/public/cpp/interface_factory.h" |
13 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom.
h" | 13 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom.
h" |
14 #include "ui/events/devices/device_data_manager.h" | 14 #include "ui/events/devices/device_data_manager.h" |
15 #include "ui/events/devices/input_device_event_observer.h" | 15 #include "ui/events/devices/input_device_event_observer.h" |
16 | 16 |
17 namespace shell { | 17 namespace service_manager { |
18 class InterfaceRegistry; | 18 class InterfaceRegistry; |
19 } | 19 } |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
23 // Listens to DeviceDataManager for updates on input-devices and forwards those | 23 // Listens to DeviceDataManager for updates on input-devices and forwards those |
24 // updates to any registered InputDeviceObserverMojo in other processes via | 24 // updates to any registered InputDeviceObserverMojo in other processes via |
25 // Mojo IPC. This runs in the mus-ws process. | 25 // Mojo IPC. This runs in the mus-ws process. |
26 class InputDeviceServer | 26 class InputDeviceServer |
27 : public shell::InterfaceFactory<mojom::InputDeviceServer>, | 27 : public service_manager::InterfaceFactory<mojom::InputDeviceServer>, |
28 public mojom::InputDeviceServer, | 28 public mojom::InputDeviceServer, |
29 public ui::InputDeviceEventObserver { | 29 public ui::InputDeviceEventObserver { |
30 public: | 30 public: |
31 InputDeviceServer(); | 31 InputDeviceServer(); |
32 ~InputDeviceServer() override; | 32 ~InputDeviceServer() override; |
33 | 33 |
34 // Registers this instance as a local observer with DeviceDataManager. | 34 // Registers this instance as a local observer with DeviceDataManager. |
35 void RegisterAsObserver(); | 35 void RegisterAsObserver(); |
36 bool IsRegisteredAsObserver() const; | 36 bool IsRegisteredAsObserver() const; |
37 | 37 |
38 // Adds interface with the connection registry so remote observers can | 38 // Adds interface with the connection registry so remote observers can |
39 // connect. You should have already called RegisterAsObserver() to get local | 39 // connect. You should have already called RegisterAsObserver() to get local |
40 // input-device event updates and checked it was successful by calling | 40 // input-device event updates and checked it was successful by calling |
41 // IsRegisteredAsObserver(). | 41 // IsRegisteredAsObserver(). |
42 void AddInterface(shell::InterfaceRegistry* registry); | 42 void AddInterface(service_manager::InterfaceRegistry* registry); |
43 | 43 |
44 // mojom::InputDeviceServer: | 44 // mojom::InputDeviceServer: |
45 void AddObserver(mojom::InputDeviceObserverMojoPtr observer) override; | 45 void AddObserver(mojom::InputDeviceObserverMojoPtr observer) override; |
46 | 46 |
47 // ui::InputDeviceEventObserver: | 47 // ui::InputDeviceEventObserver: |
48 void OnKeyboardDeviceConfigurationChanged() override; | 48 void OnKeyboardDeviceConfigurationChanged() override; |
49 void OnTouchscreenDeviceConfigurationChanged() override; | 49 void OnTouchscreenDeviceConfigurationChanged() override; |
50 void OnMouseDeviceConfigurationChanged() override; | 50 void OnMouseDeviceConfigurationChanged() override; |
51 void OnTouchpadDeviceConfigurationChanged() override; | 51 void OnTouchpadDeviceConfigurationChanged() override; |
52 void OnDeviceListsComplete() override; | 52 void OnDeviceListsComplete() override; |
53 void OnStylusStateChanged(StylusState state) override; | 53 void OnStylusStateChanged(StylusState state) override; |
54 | 54 |
55 private: | 55 private: |
56 // Sends the current state of all input-devices to an observer. | 56 // Sends the current state of all input-devices to an observer. |
57 void SendDeviceListsComplete(mojom::InputDeviceObserverMojo* observer); | 57 void SendDeviceListsComplete(mojom::InputDeviceObserverMojo* observer); |
58 | 58 |
59 // mojo::InterfaceFactory<mojom::InputDeviceServer>: | 59 // mojo::InterfaceFactory<mojom::InputDeviceServer>: |
60 void Create(const shell::Identity& remote_identity, | 60 void Create(const service_manager::Identity& remote_identity, |
61 mojom::InputDeviceServerRequest request) override; | 61 mojom::InputDeviceServerRequest request) override; |
62 | 62 |
63 mojo::BindingSet<mojom::InputDeviceServer> bindings_; | 63 mojo::BindingSet<mojom::InputDeviceServer> bindings_; |
64 mojo::InterfacePtrSet<mojom::InputDeviceObserverMojo> observers_; | 64 mojo::InterfacePtrSet<mojom::InputDeviceObserverMojo> observers_; |
65 | 65 |
66 // DeviceDataManager instance we are registered as an observer with. | 66 // DeviceDataManager instance we are registered as an observer with. |
67 ui::DeviceDataManager* manager_ = nullptr; | 67 ui::DeviceDataManager* manager_ = nullptr; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(InputDeviceServer); | 69 DISALLOW_COPY_AND_ASSIGN(InputDeviceServer); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace ui | 72 } // namespace ui |
73 | 73 |
74 #endif // SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ | 74 #endif // SERVICES_UI_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_ |
OLD | NEW |