Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: chrome/browser/extensions/api/hid/hid_device_manager.cc

Issue 225513005: chrome.hid : enrich device info with Top-Level collections usages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HidUsageAndPage::Page Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/hid.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/extensions/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 int resource_id = device_iter->first; 42 int resource_id = device_iter->first;
43 device::HidDeviceId device_id = device_iter->second; 43 device::HidDeviceId device_id = device_iter->second;
44 device::HidDeviceInfo device_info; 44 device::HidDeviceInfo device_info;
45 if (hid_service->GetDeviceInfo(device_id, &device_info)) { 45 if (hid_service->GetDeviceInfo(device_id, &device_info)) {
46 if (device_info.vendor_id == vendor_id && 46 if (device_info.vendor_id == vendor_id &&
47 device_info.product_id == product_id) { 47 device_info.product_id == product_id) {
48 api::hid::HidDeviceInfo api_device_info; 48 api::hid::HidDeviceInfo api_device_info;
49 api_device_info.device_id = resource_id; 49 api_device_info.device_id = resource_id;
50 api_device_info.vendor_id = device_info.vendor_id; 50 api_device_info.vendor_id = device_info.vendor_id;
51 api_device_info.product_id = device_info.product_id; 51 api_device_info.product_id = device_info.product_id;
52 for (std::vector<device::HidUsageAndPage>::const_iterator usage_iter =
53 device_info.usages.begin();
54 usage_iter != device_info.usages.end();
55 ++usage_iter) {
56 api::hid::HidUsageAndPage* usage_and_page =
57 new api::hid::HidUsageAndPage();
58 usage_and_page->usage_page = (*usage_iter).usage_page;
59 usage_and_page->usage = (*usage_iter).usage;
60 linked_ptr<api::hid::HidUsageAndPage> usage_and_page_ptr(
61 usage_and_page);
62 api_device_info.usages.push_back(usage_and_page_ptr);
63 }
52 api_devices->Append(api_device_info.ToValue().release()); 64 api_devices->Append(api_device_info.ToValue().release());
53 } 65 }
54 } 66 }
55 } 67 }
56 return scoped_ptr<base::ListValue>(api_devices); 68 return scoped_ptr<base::ListValue>(api_devices);
57 } 69 }
58 70
59 bool HidDeviceManager::GetDeviceInfo(int resource_id, 71 bool HidDeviceManager::GetDeviceInfo(int resource_id,
60 device::HidDeviceInfo* device_info) { 72 device::HidDeviceInfo* device_info) {
61 UpdateDevices(); 73 UpdateDevices();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 new_id = next_resource_id_++; 108 new_id = next_resource_id_++;
97 } 109 }
98 new_resource_ids[device_info.device_id] = new_id; 110 new_resource_ids[device_info.device_id] = new_id;
99 new_device_ids[new_id] = device_info.device_id; 111 new_device_ids[new_id] = device_info.device_id;
100 } 112 }
101 device_ids_.swap(new_device_ids); 113 device_ids_.swap(new_device_ids);
102 resource_ids_.swap(new_resource_ids); 114 resource_ids_.swap(new_resource_ids);
103 } 115 }
104 116
105 } // namespace extensions 117 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/hid.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698