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