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 // Use the <code>chrome.usb</code> API to interact with connected USB | 5 // Use the <code>chrome.usb</code> API to interact with connected USB |
6 // devices. This API provides access to USB operations from within the context | 6 // devices. This API provides access to USB operations from within the context |
7 // of an app. Using this API, apps can function as drivers for hardware devices. | 7 // of an app. Using this API, apps can function as drivers for hardware devices. |
8 // | 8 // |
9 // Errors generated by this API are reported by setting | 9 // Errors generated by this API are reported by setting |
10 // $(ref:runtime.lastError) and executing the function's regular callback. The | 10 // $(ref:runtime.lastError) and executing the function's regular callback. The |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 dictionary EnumerateDevicesOptions { | 180 dictionary EnumerateDevicesOptions { |
181 [deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."] | 181 [deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."] |
182 long? vendorId; | 182 long? vendorId; |
183 [deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."] | 183 [deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."] |
184 long? productId; | 184 long? productId; |
185 // A device matching any given filter will be returned. An empty filter list | 185 // A device matching any given filter will be returned. An empty filter list |
186 // will return all devices the app has permission for. | 186 // will return all devices the app has permission for. |
187 DeviceFilter[]? filters; | 187 DeviceFilter[]? filters; |
188 }; | 188 }; |
189 | 189 |
190 dictionary EnumerateDevicesAndRequestAccessOptions { | 190 dictionary EnumerateDevicesAndRequestAccessOptions { |
191 // The device vendor ID. | 191 // The device vendor ID. |
192 long vendorId; | 192 long vendorId; |
193 // The product ID. | 193 // The product ID. |
194 long productId; | 194 long productId; |
195 // The interface ID to request access to. | 195 // The interface ID to request access to. |
196 // Only available on ChromeOS. It has no effect on other platforms. | 196 // Only available on ChromeOS. It has no effect on other platforms. |
197 long? interfaceId; | 197 long? interfaceId; |
198 }; | 198 }; |
199 | 199 |
| 200 dictionary DevicePromptOptions { |
| 201 // Allow the user to select multiple devices. |
| 202 boolean? multiple; |
| 203 // Filter the list of devices presented to the user. If multiple filters are |
| 204 // provided devices matching any filter will be displayed. |
| 205 DeviceFilter[]? filters; |
| 206 }; |
| 207 |
200 callback VoidCallback = void (); | 208 callback VoidCallback = void (); |
201 callback GetDevicesCallback = void (Device[] devices); | 209 callback GetDevicesCallback = void (Device[] devices); |
202 callback RequestAccessCallback = void (boolean success); | 210 callback RequestAccessCallback = void (boolean success); |
203 callback OpenDeviceCallback = void (ConnectionHandle handle); | 211 callback OpenDeviceCallback = void (ConnectionHandle handle); |
204 callback FindDevicesCallback = void (ConnectionHandle[] handles); | 212 callback FindDevicesCallback = void (ConnectionHandle[] handles); |
205 callback GetConfigurationCallback = void (ConfigDescriptor config); | 213 callback GetConfigurationCallback = void (ConfigDescriptor config); |
206 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); | 214 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); |
207 callback CloseDeviceCallback = void (); | 215 callback CloseDeviceCallback = void (); |
208 callback TransferCallback = void (TransferResultInfo info); | 216 callback TransferCallback = void (TransferResultInfo info); |
209 callback ResetDeviceCallback = void(boolean success); | 217 callback ResetDeviceCallback = void(boolean success); |
210 | 218 |
211 interface Functions { | 219 interface Functions { |
212 // Enumerates connected USB devices. | 220 // Enumerates connected USB devices. |
213 // |options|: The properties to search for on target devices. | 221 // |options|: The properties to search for on target devices. |
214 static void getDevices(EnumerateDevicesOptions options, | 222 static void getDevices(EnumerateDevicesOptions options, |
215 GetDevicesCallback callback); | 223 GetDevicesCallback callback); |
216 | 224 |
| 225 // Presents a device picker to the user and returns the $(ref:Device)s |
| 226 // selected. |
| 227 // If the user cancels the picker devices will be empty. A user gesture |
| 228 // is required for the dialog to display. Without a user gesture, the |
| 229 // callback will run as though the user cancelled. |
| 230 // |options|: Configuration of the device picker dialog box. |
| 231 // |callback|: Invoked with a list of chosen $(ref:Device)s. |
| 232 static void getUserSelectedDevices(DevicePromptOptions options, |
| 233 GetDevicesCallback callback); |
| 234 |
217 // Requests access from the permission broker to a device claimed by | 235 // Requests access from the permission broker to a device claimed by |
218 // ChromeOS if the given interface on the device is not claimed. | 236 // ChromeOS if the given interface on the device is not claimed. |
219 // | 237 // |
220 // <b>Note:</b> This method is ChromeOS specific. Calling this method on | 238 // <b>Note:</b> This method is ChromeOS specific. Calling this method on |
221 // other platforms will fail. | 239 // other platforms will fail. |
222 // | 240 // |
223 // |device|: The $(ref:Device) to request access to. | 241 // |device|: The $(ref:Device) to request access to. |
224 // |interfaceId|: The particular interface requested. | 242 // |interfaceId|: The particular interface requested. |
225 static void requestAccess(Device device, | 243 static void requestAccess(Device device, |
226 long interfaceId, | 244 long interfaceId, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // If the reset fails, the given connection handle will be closed and the | 348 // If the reset fails, the given connection handle will be closed and the |
331 // USB device will appear to be disconnected then reconnected. | 349 // USB device will appear to be disconnected then reconnected. |
332 // In this case $(ref:getDevices) or $(ref:findDevices) must be called again | 350 // In this case $(ref:getDevices) or $(ref:findDevices) must be called again |
333 // to acquire the device. | 351 // to acquire the device. |
334 // | 352 // |
335 // |handle|: A connection handle to reset. | 353 // |handle|: A connection handle to reset. |
336 static void resetDevice(ConnectionHandle handle, | 354 static void resetDevice(ConnectionHandle handle, |
337 ResetDeviceCallback callback); | 355 ResetDeviceCallback callback); |
338 }; | 356 }; |
339 }; | 357 }; |
OLD | NEW |