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/devices/device_data_manager.h" | 5 #include "ui/events/devices/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/devices/input_device_event_observer.h" | 10 #include "ui/events/devices/input_device_event_observer.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void DeviceDataManager::OnTouchscreenDevicesUpdated( | 125 void DeviceDataManager::OnTouchscreenDevicesUpdated( |
126 const std::vector<TouchscreenDevice>& devices) { | 126 const std::vector<TouchscreenDevice>& devices) { |
127 if (devices.size() == touchscreen_devices_.size() && | 127 if (devices.size() == touchscreen_devices_.size() && |
128 std::equal(devices.begin(), | 128 std::equal(devices.begin(), |
129 devices.end(), | 129 devices.end(), |
130 touchscreen_devices_.begin(), | 130 touchscreen_devices_.begin(), |
131 InputDeviceEquals)) { | 131 InputDeviceEquals)) { |
132 return; | 132 return; |
133 } | 133 } |
134 touchscreen_devices_ = devices; | 134 touchscreen_devices_ = devices; |
135 FOR_EACH_OBSERVER(InputDeviceEventObserver, | 135 NotifyObserversTouchscreenDeviceConfigurationChanged(); |
136 observers_, | |
137 OnTouchscreenDeviceConfigurationChanged()); | |
138 } | 136 } |
139 | 137 |
140 void DeviceDataManager::OnKeyboardDevicesUpdated( | 138 void DeviceDataManager::OnKeyboardDevicesUpdated( |
141 const std::vector<KeyboardDevice>& devices) { | 139 const std::vector<KeyboardDevice>& devices) { |
142 if (devices.size() == keyboard_devices_.size() && | 140 if (devices.size() == keyboard_devices_.size() && |
143 std::equal(devices.begin(), | 141 std::equal(devices.begin(), |
144 devices.end(), | 142 devices.end(), |
145 keyboard_devices_.begin(), | 143 keyboard_devices_.begin(), |
146 InputDeviceEquals)) { | 144 InputDeviceEquals)) { |
147 return; | 145 return; |
148 } | 146 } |
149 keyboard_devices_ = devices; | 147 keyboard_devices_ = devices; |
150 FOR_EACH_OBSERVER(InputDeviceEventObserver, | 148 NotifyObserversKeyboardDeviceConfigurationChanged(); |
151 observers_, | |
152 OnKeyboardDeviceConfigurationChanged()); | |
153 } | 149 } |
154 | 150 |
155 void DeviceDataManager::OnMouseDevicesUpdated( | 151 void DeviceDataManager::OnMouseDevicesUpdated( |
156 const std::vector<InputDevice>& devices) { | 152 const std::vector<InputDevice>& devices) { |
157 if (devices.size() == mouse_devices_.size() && | 153 if (devices.size() == mouse_devices_.size() && |
158 std::equal(devices.begin(), | 154 std::equal(devices.begin(), |
159 devices.end(), | 155 devices.end(), |
160 mouse_devices_.begin(), | 156 mouse_devices_.begin(), |
161 InputDeviceEquals)) { | 157 InputDeviceEquals)) { |
162 return; | 158 return; |
163 } | 159 } |
164 mouse_devices_ = devices; | 160 mouse_devices_ = devices; |
165 FOR_EACH_OBSERVER(InputDeviceEventObserver, | 161 NotifyObserversMouseDeviceConfigurationChanged(); |
166 observers_, | |
167 OnMouseDeviceConfigurationChanged()); | |
168 } | 162 } |
169 | 163 |
170 void DeviceDataManager::OnTouchpadDevicesUpdated( | 164 void DeviceDataManager::OnTouchpadDevicesUpdated( |
171 const std::vector<InputDevice>& devices) { | 165 const std::vector<InputDevice>& devices) { |
172 if (devices.size() == touchpad_devices_.size() && | 166 if (devices.size() == touchpad_devices_.size() && |
173 std::equal(devices.begin(), | 167 std::equal(devices.begin(), |
174 devices.end(), | 168 devices.end(), |
175 touchpad_devices_.begin(), | 169 touchpad_devices_.begin(), |
176 InputDeviceEquals)) { | 170 InputDeviceEquals)) { |
177 return; | 171 return; |
178 } | 172 } |
179 touchpad_devices_ = devices; | 173 touchpad_devices_ = devices; |
180 FOR_EACH_OBSERVER(InputDeviceEventObserver, | 174 NotifyObserversTouchpadDeviceConfigurationChanged(); |
181 observers_, | |
182 OnTouchpadDeviceConfigurationChanged()); | |
183 } | 175 } |
184 | 176 |
185 void DeviceDataManager::OnDeviceListsComplete() { | 177 void DeviceDataManager::OnDeviceListsComplete() { |
186 if (!device_lists_complete_) { | 178 if (!device_lists_complete_) { |
187 device_lists_complete_ = true; | 179 device_lists_complete_ = true; |
188 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, | 180 NotifyObserversDeviceListsComplete(); |
189 OnDeviceListsComplete()); | |
190 } | 181 } |
191 } | 182 } |
192 | 183 |
| 184 void DeviceDataManager::NotifyObserversTouchscreenDeviceConfigurationChanged() { |
| 185 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, |
| 186 OnTouchscreenDeviceConfigurationChanged()); |
| 187 } |
| 188 |
| 189 void DeviceDataManager::NotifyObserversKeyboardDeviceConfigurationChanged() { |
| 190 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, |
| 191 OnKeyboardDeviceConfigurationChanged()); |
| 192 } |
| 193 |
| 194 void DeviceDataManager::NotifyObserversMouseDeviceConfigurationChanged() { |
| 195 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, |
| 196 OnMouseDeviceConfigurationChanged()); |
| 197 } |
| 198 |
| 199 void DeviceDataManager::NotifyObserversTouchpadDeviceConfigurationChanged() { |
| 200 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, |
| 201 OnTouchpadDeviceConfigurationChanged()); |
| 202 } |
| 203 |
| 204 void DeviceDataManager::NotifyObserversDeviceListsComplete() { |
| 205 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, |
| 206 OnDeviceListsComplete()); |
| 207 } |
| 208 |
193 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { | 209 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |
194 observers_.AddObserver(observer); | 210 observers_.AddObserver(observer); |
195 } | 211 } |
196 | 212 |
197 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { | 213 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { |
198 observers_.RemoveObserver(observer); | 214 observers_.RemoveObserver(observer); |
199 } | 215 } |
200 | 216 |
201 } // namespace ui | 217 } // namespace ui |
OLD | NEW |