| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const device::HidDeviceInfo& device_info) { | 121 const device::HidDeviceInfo& device_info) { |
| 122 UsbDevicePermission::CheckParam usbParam( | 122 UsbDevicePermission::CheckParam usbParam( |
| 123 device_info.vendor_id, | 123 device_info.vendor_id, |
| 124 device_info.product_id, | 124 device_info.product_id, |
| 125 UsbDevicePermissionData::UNSPECIFIED_INTERFACE); | 125 UsbDevicePermissionData::UNSPECIFIED_INTERFACE); |
| 126 if (extension->permissions_data()->CheckAPIPermissionWithParam( | 126 if (extension->permissions_data()->CheckAPIPermissionWithParam( |
| 127 APIPermission::kUsbDevice, &usbParam)) { | 127 APIPermission::kUsbDevice, &usbParam)) { |
| 128 return true; | 128 return true; |
| 129 } | 129 } |
| 130 | 130 |
| 131 if (extension->permissions_data()->HasAPIPermission( |
| 132 APIPermission::kU2fDevices)) { |
| 133 HidDeviceFilter u2f_filter; |
| 134 u2f_filter.SetUsagePage(0xF1D0); |
| 135 if (u2f_filter.Matches(device_info)) { |
| 136 return true; |
| 137 } |
| 138 } |
| 139 |
| 131 return false; | 140 return false; |
| 132 } | 141 } |
| 133 | 142 |
| 134 void HidDeviceManager::UpdateDevices() { | 143 void HidDeviceManager::UpdateDevices() { |
| 135 thread_checker_.CalledOnValidThread(); | 144 thread_checker_.CalledOnValidThread(); |
| 136 HidService* hid_service = ExtensionsAPIClient::Get()->GetHidService(); | 145 HidService* hid_service = ExtensionsAPIClient::Get()->GetHidService(); |
| 137 DCHECK(hid_service); | 146 DCHECK(hid_service); |
| 138 | 147 |
| 139 std::vector<device::HidDeviceInfo> devices; | 148 std::vector<device::HidDeviceInfo> devices; |
| 140 hid_service->GetDevices(&devices); | 149 hid_service->GetDevices(&devices); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 new_id = next_resource_id_++; | 166 new_id = next_resource_id_++; |
| 158 } | 167 } |
| 159 new_resource_ids[device_info.device_id] = new_id; | 168 new_resource_ids[device_info.device_id] = new_id; |
| 160 new_device_ids[new_id] = device_info.device_id; | 169 new_device_ids[new_id] = device_info.device_id; |
| 161 } | 170 } |
| 162 device_ids_.swap(new_device_ids); | 171 device_ids_.swap(new_device_ids); |
| 163 resource_ids_.swap(new_resource_ids); | 172 resource_ids_.swap(new_resource_ids); |
| 164 } | 173 } |
| 165 | 174 |
| 166 } // namespace extensions | 175 } // namespace extensions |
| OLD | NEW |