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

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

Issue 1992443002: Add Mojo IPC based input-device service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_ddm
Patch Set: Implementation only. 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 #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_device_server.moj om.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 InputDeviceEventObserver and
23 // 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 // needs input-device information but doesn't have DeviceDataManager. The Mojo
sadrul 2016/06/10 18:01:49 each *client But I don't think this line is addin
kylechar 2016/06/10 19:29:31 Deleted that part of the comment.
30 // app should call Connect() to register as a InputDeviceObserverMojo. Client
31 // code can use InputDeviceManager and be agnostic to what is providing the
32 // input-device information.
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 // ui::InputDeviceManager:
44 const std::vector<ui::InputDevice>& GetKeyboardDevices() const override;
45 const std::vector<ui::TouchscreenDevice>& GetTouchscreenDevices()
46 const override;
47 const std::vector<ui::InputDevice>& GetMouseDevices() const override;
48 const std::vector<ui::InputDevice>& GetTouchpadDevices() const override;
49
50 bool AreDeviceListsComplete() const override;
51 bool AreTouchscreensEnabled() const override;
52
53 void AddObserver(ui::InputDeviceEventObserver* observer) override;
54 void RemoveObserver(ui::InputDeviceEventObserver* observer) override;
55
56 private:
57 // mojom::InputDeviceObserverMojo:
58 void OnKeyboardDeviceConfigurationChanged(
59 mojo::Array<ui::InputDevice> devices) override;
60 void OnTouchscreenDeviceConfigurationChanged(
61 mojo::Array<ui::TouchscreenDevice> devices) override;
62 void OnMouseDeviceConfigurationChanged(
63 mojo::Array<ui::InputDevice> devices) override;
64 void OnTouchpadDeviceConfigurationChanged(
65 mojo::Array<ui::InputDevice> devices) override;
66 void OnDeviceListsComplete(
67 mojo::Array<ui::InputDevice> keyboard_devices,
68 mojo::Array<ui::TouchscreenDevice> touchscreen_devices,
69 mojo::Array<ui::InputDevice> mouse_devices,
70 mojo::Array<ui::InputDevice> touchpad_devices) override;
71
72 mojo::Binding<mojom::InputDeviceObserverMojo> binding_;
73
74 // Holds the list of input devices and signal that we have received the lists
75 // after initialization.
76 std::vector<ui::InputDevice> keyboard_devices_;
77 std::vector<ui::TouchscreenDevice> touchscreen_devices_;
78 std::vector<ui::InputDevice> mouse_devices_;
79 std::vector<ui::InputDevice> touchpad_devices_;
80 bool device_lists_complete_ = false;
81
82 // List of in-process observers.
83 base::ObserverList<ui::InputDeviceEventObserver> observers_;
84
85 DISALLOW_COPY_AND_ASSIGN(InputDeviceClient);
86 };
87
88 } // namespace input_device
89
90 #endif // COMPONENTS_MUS_PUBLIC_CPP_INPUT_DEVICES_INPUT_DEVICE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698