| 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_INPUT_DEVICE_SERVICE_INPUT_DEVICE_CLIENT_H_ |
| 6 #define COMPONENTS_INPUT_DEVICE_SERVICE_INPUT_DEVICE_CLIENT_H_ |
| 7 |
| 8 #include <array> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" |
| 14 #include "components/input_device_service/input_device_service.mojom.h" |
| 15 #include "mojo/public/cpp/bindings/array.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "services/shell/public/cpp/connector.h" |
| 18 #include "ui/events/devices/input_device.h" |
| 19 #include "ui/events/devices/input_device_event_observer.h" |
| 20 #include "ui/events/devices/input_device_service.h" |
| 21 |
| 22 namespace input_device { |
| 23 |
| 24 // Listens for input device updates over Mojo IPC. Mirrors input device |
| 25 // information found in the mus-ws process. |
| 26 class InputDeviceClient : public mojom::InputDeviceObserver, |
| 27 public ui::InputDeviceService { |
| 28 public: |
| 29 InputDeviceClient(); |
| 30 ~InputDeviceClient() override; |
| 31 |
| 32 void Initialize(shell::Connector* connector); |
| 33 |
| 34 // mojom::InputDeviceObserver: |
| 35 void OnKeyboardDeviceConfigurationChanged( |
| 36 mojo::Array<ui::InputDevice> devices) override; |
| 37 void OnTouchscreenDeviceConfigurationChanged( |
| 38 mojo::Array<ui::InputDevice> devices) override; |
| 39 void OnMouseDeviceConfigurationChanged( |
| 40 mojo::Array<ui::InputDevice> devices) override; |
| 41 void OnTouchpadDeviceConfigurationChanged( |
| 42 mojo::Array<ui::InputDevice> devices) override; |
| 43 |
| 44 void AddObserver(ui::InputDeviceEventObserver* observer) override; |
| 45 void RemoveObserver(ui::InputDeviceEventObserver* observer) override; |
| 46 |
| 47 const std::vector<ui::InputDevice>& keyboard_devices() override; |
| 48 const std::vector<ui::InputDevice>& touchscreen_devices() override; |
| 49 const std::vector<ui::InputDevice>& mouse_devices() override; |
| 50 const std::vector<ui::InputDevice>& touchpad_devices() override; |
| 51 |
| 52 private: |
| 53 void RequestDeviceUpdates(); |
| 54 |
| 55 void UpdateKeyboardDevices(mojo::Array<ui::InputDevice> devices); |
| 56 void UpdateTouchscreenDevices(mojo::Array<ui::InputDevice> devices); |
| 57 void UpdateMouseDevices(mojo::Array<ui::InputDevice> devices); |
| 58 void UpdateTouchpadDevices(mojo::Array<ui::InputDevice> devices); |
| 59 |
| 60 std::vector<ui::InputDevice> keyboard_devices_; |
| 61 std::vector<ui::InputDevice> touchscreen_devices_; |
| 62 std::vector<ui::InputDevice> mouse_devices_; |
| 63 std::vector<ui::InputDevice> touchpad_devices_; |
| 64 |
| 65 mojom::InputDeviceServicePtr service_; |
| 66 mojo::Binding<mojom::InputDeviceObserver> binding_; |
| 67 |
| 68 // List of observers in this process. |
| 69 base::ObserverList<ui::InputDeviceEventObserver> observers_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(InputDeviceClient); |
| 72 }; |
| 73 |
| 74 } // namespace input_device |
| 75 |
| 76 #endif // COMPONENTS_INPUT_DEVICE_SERVICE_INPUT_DEVICE_CLIENT_H_ |
| OLD | NEW |