OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/events/device_data_manager.h" | 5 #include "ui/events/device_data_manager.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/events/input_device_event_observer.h" |
10 #include "ui/gfx/display.h" | 11 #include "ui/gfx/display.h" |
11 #include "ui/gfx/geometry/point3_f.h" | 12 #include "ui/gfx/geometry/point3_f.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 // static | 16 // static |
16 DeviceDataManager* DeviceDataManager::instance_ = NULL; | 17 DeviceDataManager* DeviceDataManager::instance_ = NULL; |
17 | 18 |
18 DeviceDataManager::DeviceDataManager() { | 19 DeviceDataManager::DeviceDataManager() { |
19 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; | 20 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 *y = point.y(); | 102 *y = point.y(); |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { | 106 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { |
106 if (IsTouchDeviceIdValid(touch_device_id)) | 107 if (IsTouchDeviceIdValid(touch_device_id)) |
107 return touch_device_to_display_map_[touch_device_id]; | 108 return touch_device_to_display_map_[touch_device_id]; |
108 return gfx::Display::kInvalidDisplayID; | 109 return gfx::Display::kInvalidDisplayID; |
109 } | 110 } |
110 | 111 |
| 112 void DeviceDataManager::OnTouchscreenDevices( |
| 113 const std::vector<TouchscreenDevice>& devices) { |
| 114 touchscreen_devices_ = devices; |
| 115 |
| 116 FOR_EACH_OBSERVER(InputDeviceEventObserver, |
| 117 observers_, |
| 118 OnInputDeviceConfigurationChanged()); |
| 119 } |
| 120 |
| 121 std::vector<TouchscreenDevice> DeviceDataManager::GetTouchscreenDevices() |
| 122 const { |
| 123 return touchscreen_devices_; |
| 124 } |
| 125 |
| 126 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |
| 127 observers_.AddObserver(observer); |
| 128 } |
| 129 |
| 130 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { |
| 131 observers_.RemoveObserver(observer); |
| 132 } |
| 133 |
111 } // namespace ui | 134 } // namespace ui |
OLD | NEW |