| 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 "chrome/browser/extensions/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" |
| 11 #include "device/hid/hid_service.h" | 11 #include "device/hid/hid_service.h" |
| 12 | 12 |
| 13 using device::HidService; | 13 using device::HidService; |
| 14 using device::HidUsageAndPage; | 14 using device::HidUsageAndPage; |
| 15 | 15 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 40 device_ids_.begin(); | 40 device_ids_.begin(); |
| 41 device_iter != device_ids_.end(); | 41 device_iter != device_ids_.end(); |
| 42 ++device_iter) { | 42 ++device_iter) { |
| 43 int resource_id = device_iter->first; | 43 int resource_id = device_iter->first; |
| 44 device::HidDeviceId device_id = device_iter->second; | 44 device::HidDeviceId device_id = device_iter->second; |
| 45 device::HidDeviceInfo device_info; | 45 device::HidDeviceInfo device_info; |
| 46 | 46 |
| 47 if (hid_service->GetDeviceInfo(device_id, &device_info)) { | 47 if (hid_service->GetDeviceInfo(device_id, &device_info)) { |
| 48 if (device_info.vendor_id == vendor_id && | 48 if (device_info.vendor_id == vendor_id && |
| 49 device_info.product_id == product_id) { | 49 device_info.product_id == product_id) { |
| 50 api::hid::HidDeviceInfo api_device_info; | 50 core_api::hid::HidDeviceInfo api_device_info; |
| 51 api_device_info.device_id = resource_id; | 51 api_device_info.device_id = resource_id; |
| 52 api_device_info.vendor_id = device_info.vendor_id; | 52 api_device_info.vendor_id = device_info.vendor_id; |
| 53 api_device_info.product_id = device_info.product_id; | 53 api_device_info.product_id = device_info.product_id; |
| 54 api_device_info.max_input_report_size = | 54 api_device_info.max_input_report_size = |
| 55 device_info.max_input_report_size; | 55 device_info.max_input_report_size; |
| 56 api_device_info.max_output_report_size = | 56 api_device_info.max_output_report_size = |
| 57 device_info.max_output_report_size; | 57 device_info.max_output_report_size; |
| 58 api_device_info.max_feature_report_size = | 58 api_device_info.max_feature_report_size = |
| 59 device_info.max_feature_report_size; | 59 device_info.max_feature_report_size; |
| 60 | 60 |
| 61 for (std::vector<device::HidCollectionInfo>::const_iterator | 61 for (std::vector<device::HidCollectionInfo>::const_iterator |
| 62 collections_iter = device_info.collections.begin(); | 62 collections_iter = device_info.collections.begin(); |
| 63 collections_iter != device_info.collections.end(); | 63 collections_iter != device_info.collections.end(); |
| 64 ++collections_iter) { | 64 ++collections_iter) { |
| 65 device::HidCollectionInfo collection = *collections_iter; | 65 device::HidCollectionInfo collection = *collections_iter; |
| 66 | 66 |
| 67 // Don't expose sensitive data. | 67 // Don't expose sensitive data. |
| 68 if (collection.usage.IsProtected()) { | 68 if (collection.usage.IsProtected()) { |
| 69 continue; | 69 continue; |
| 70 } | 70 } |
| 71 | 71 |
| 72 api::hid::HidCollectionInfo* api_collection = | 72 core_api::hid::HidCollectionInfo* api_collection = |
| 73 new api::hid::HidCollectionInfo(); | 73 new core_api::hid::HidCollectionInfo(); |
| 74 api_collection->usage_page = collection.usage.usage_page; | 74 api_collection->usage_page = collection.usage.usage_page; |
| 75 api_collection->usage = collection.usage.usage; | 75 api_collection->usage = collection.usage.usage; |
| 76 | 76 |
| 77 api_collection->report_ids.resize(collection.report_ids.size()); | 77 api_collection->report_ids.resize(collection.report_ids.size()); |
| 78 std::copy(collection.report_ids.begin(), | 78 std::copy(collection.report_ids.begin(), |
| 79 collection.report_ids.end(), | 79 collection.report_ids.end(), |
| 80 api_collection->report_ids.begin()); | 80 api_collection->report_ids.begin()); |
| 81 | 81 |
| 82 api_device_info.collections.push_back( | 82 api_device_info.collections.push_back( |
| 83 make_linked_ptr(api_collection)); | 83 make_linked_ptr(api_collection)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 new_id = next_resource_id_++; | 133 new_id = next_resource_id_++; |
| 134 } | 134 } |
| 135 new_resource_ids[device_info.device_id] = new_id; | 135 new_resource_ids[device_info.device_id] = new_id; |
| 136 new_device_ids[new_id] = device_info.device_id; | 136 new_device_ids[new_id] = device_info.device_id; |
| 137 } | 137 } |
| 138 device_ids_.swap(new_device_ids); | 138 device_ids_.swap(new_device_ids); |
| 139 resource_ids_.swap(new_resource_ids); | 139 resource_ids_.swap(new_resource_ids); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace extensions | 142 } // namespace extensions |
| OLD | NEW |