OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "chrome/browser/chromeos/device_hierarchy_observer.h" | 10 #include "chrome/browser/chromeos/device_hierarchy_observer.h" |
| 11 #include "ui/events/devices/input_device_event_observer.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 namespace system { | 14 namespace system { |
14 | 15 |
15 class PointerDeviceObserver : public DeviceHierarchyObserver { | 16 class PointerDeviceObserver : public DeviceHierarchyObserver, |
| 17 public ui::InputDeviceEventObserver { |
16 public: | 18 public: |
17 PointerDeviceObserver(); | 19 PointerDeviceObserver(); |
18 ~PointerDeviceObserver() override; | 20 ~PointerDeviceObserver() override; |
19 | 21 |
20 // Start observing device hierarchy. | 22 // Start observing device hierarchy. |
21 void Init(); | 23 void Init(); |
22 | 24 |
23 // Check for presence of devices. | 25 // Check for presence of devices. |
24 void CheckDevices(); | 26 void CheckDevices(); |
25 | 27 |
26 class Observer { | 28 class Observer { |
27 public: | 29 public: |
28 virtual void TouchpadExists(bool exists) = 0; | 30 virtual void TouchpadExists(bool exists) = 0; |
29 virtual void MouseExists(bool exists) = 0; | 31 virtual void MouseExists(bool exists) = 0; |
30 | 32 |
31 protected: | 33 protected: |
32 Observer() {} | 34 Observer() {} |
33 virtual ~Observer(); | 35 virtual ~Observer(); |
34 }; | 36 }; |
35 void AddObserver(Observer* observer); | 37 void AddObserver(Observer* observer); |
36 void RemoveObserver(Observer* observer); | 38 void RemoveObserver(Observer* observer); |
37 | 39 |
38 private: | 40 private: |
39 // DeviceHierarchyObserver implementation. | 41 // DeviceHierarchyObserver: |
40 void DeviceHierarchyChanged() override; | 42 void DeviceHierarchyChanged() override; |
41 void DeviceAdded(int device_id) override {} | 43 void DeviceAdded(int device_id) override {} |
42 void DeviceRemoved(int device_id) override {} | 44 void DeviceRemoved(int device_id) override {} |
43 | 45 |
| 46 // InputDeviceEventObserver: |
| 47 void OnTouchscreenDeviceConfigurationChanged() override {} |
| 48 void OnKeyboardDeviceConfigurationChanged() override {} |
| 49 void OnMouseDeviceConfigurationChanged() override; |
| 50 void OnTouchpadDeviceConfigurationChanged() override; |
| 51 |
44 // Check for pointer devices. | 52 // Check for pointer devices. |
45 void CheckTouchpadExists(); | 53 void CheckTouchpadExists(); |
46 void CheckMouseExists(); | 54 void CheckMouseExists(); |
47 | 55 |
48 // Callback for pointer device checks. | 56 // Callback for pointer device checks. |
49 void OnTouchpadExists(bool exists); | 57 void OnTouchpadExists(bool exists); |
50 void OnMouseExists(bool exists); | 58 void OnMouseExists(bool exists); |
51 | 59 |
52 ObserverList<Observer> observers_; | 60 ObserverList<Observer> observers_; |
53 | 61 |
54 base::WeakPtrFactory<PointerDeviceObserver> weak_factory_; | 62 base::WeakPtrFactory<PointerDeviceObserver> weak_factory_; |
55 | 63 |
56 DISALLOW_COPY_AND_ASSIGN(PointerDeviceObserver); | 64 DISALLOW_COPY_AND_ASSIGN(PointerDeviceObserver); |
57 }; | 65 }; |
58 | 66 |
59 } // namespace system | 67 } // namespace system |
60 } // namespace chromeos | 68 } // namespace chromeos |
61 | 69 |
62 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ | 70 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ |
OLD | NEW |