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 /** | 5 /** |
6 * @fileoverview Interface for representing a low-level gnubby device. | 6 * @fileoverview Interface for representing a low-level gnubby device. |
7 */ | 7 */ |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 /** | 114 /** |
115 * @typedef {{ | 115 * @typedef {{ |
116 * vendorId: number, | 116 * vendorId: number, |
117 * productId: number | 117 * productId: number |
118 * }} | 118 * }} |
119 */ | 119 */ |
120 var UsbDeviceSpec; | 120 var UsbDeviceSpec; |
121 | 121 |
122 /** | 122 /** |
123 * Gets the list of USB devices permitted by this app. | 123 * Gets the list of USB devices permitted by this app. |
124 * @param {function(!Array.<!UsbDeviceSpec>)} cb Called back with a list of USB | 124 * @param {function(!Array<!UsbDeviceSpec>)} cb Called back with a list of USB |
125 * device specifiers. | 125 * device specifiers. |
126 */ | 126 */ |
127 GnubbyDevice.getPermittedUsbDevices = function(cb) { | 127 GnubbyDevice.getPermittedUsbDevices = function(cb) { |
128 chrome.permissions.getAll(function(perms) { | 128 chrome.permissions.getAll(function(perms) { |
129 if (!perms.hasOwnProperty('permissions')) { | 129 if (!perms.hasOwnProperty('permissions')) { |
130 cb([]); | 130 cb([]); |
131 return; | 131 return; |
132 } | 132 } |
133 var devs = []; | 133 var devs = []; |
134 var permissions = perms['permissions']; | 134 var permissions = perms['permissions']; |
135 for (var i = 0; i < permissions.length; i++) { | 135 for (var i = 0; i < permissions.length; i++) { |
136 var permission = permissions[i]; | 136 var permission = permissions[i]; |
137 if (typeof permission === 'object' && | 137 if (typeof permission === 'object' && |
138 permission.hasOwnProperty('usbDevices')) { | 138 permission.hasOwnProperty('usbDevices')) { |
139 for (var j = 0; j < permission['usbDevices'].length; j++) { | 139 for (var j = 0; j < permission['usbDevices'].length; j++) { |
140 var dev = permission['usbDevices'][j]; | 140 var dev = permission['usbDevices'][j]; |
141 devs.push( | 141 devs.push( |
142 {'vendorId': dev['vendorId'], 'productId': dev['productId']}); | 142 {'vendorId': dev['vendorId'], 'productId': dev['productId']}); |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 cb(devs); | 146 cb(devs); |
147 }); | 147 }); |
148 }; | 148 }; |
OLD | NEW |