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 "extensions/browser/api/hid/hid_device_manager.h" | 5 #include "extensions/browser/api/hid/hid_device_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 u2f_filter.SetUsagePage(0xF1D0); | 136 u2f_filter.SetUsagePage(0xF1D0); |
137 if (u2f_filter.Matches(device_info)) { | 137 if (u2f_filter.Matches(device_info)) { |
138 return true; | 138 return true; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 return false; | 142 return false; |
143 } | 143 } |
144 | 144 |
145 void HidDeviceManager::UpdateDevices() { | 145 void HidDeviceManager::UpdateDevices() { |
146 thread_checker_.CalledOnValidThread(); | 146 DCHECK(thread_checker_.CalledOnValidThread()); |
147 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); | 147 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); |
148 DCHECK(hid_service); | 148 DCHECK(hid_service); |
149 | 149 |
150 std::vector<device::HidDeviceInfo> devices; | 150 std::vector<device::HidDeviceInfo> devices; |
151 hid_service->GetDevices(&devices); | 151 hid_service->GetDevices(&devices); |
152 | 152 |
153 // Build an updated bidi mapping between resource ID and underlying device ID. | 153 // Build an updated bidi mapping between resource ID and underlying device ID. |
154 DeviceIdToResourceIdMap new_resource_ids; | 154 DeviceIdToResourceIdMap new_resource_ids; |
155 ResourceIdToDeviceIdMap new_device_ids; | 155 ResourceIdToDeviceIdMap new_device_ids; |
156 for (std::vector<device::HidDeviceInfo>::const_iterator iter = | 156 for (std::vector<device::HidDeviceInfo>::const_iterator iter = |
(...skipping 11 matching lines...) Expand all Loading... |
168 new_id = next_resource_id_++; | 168 new_id = next_resource_id_++; |
169 } | 169 } |
170 new_resource_ids[device_info.device_id] = new_id; | 170 new_resource_ids[device_info.device_id] = new_id; |
171 new_device_ids[new_id] = device_info.device_id; | 171 new_device_ids[new_id] = device_info.device_id; |
172 } | 172 } |
173 device_ids_.swap(new_device_ids); | 173 device_ids_.swap(new_device_ids); |
174 resource_ids_.swap(new_resource_ids); | 174 resource_ids_.swap(new_resource_ids); |
175 } | 175 } |
176 | 176 |
177 } // namespace extensions | 177 } // namespace extensions |
OLD | NEW |