| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DEVICE_USB_WEBUSB_DESCRIPTORS_H_ | 5 #ifndef DEVICE_USB_WEBUSB_DESCRIPTORS_H_ |
| 6 #define DEVICE_USB_WEBUSB_DESCRIPTORS_H_ | 6 #define DEVICE_USB_WEBUSB_DESCRIPTORS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" |
| 11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 12 | 14 |
| 13 namespace device { | 15 namespace device { |
| 14 | 16 |
| 17 class UsbDeviceHandle; |
| 18 |
| 15 struct WebUsbFunctionSubset { | 19 struct WebUsbFunctionSubset { |
| 16 WebUsbFunctionSubset(); | 20 WebUsbFunctionSubset(); |
| 17 ~WebUsbFunctionSubset(); | 21 ~WebUsbFunctionSubset(); |
| 18 | 22 |
| 19 uint8_t first_interface; | 23 uint8_t first_interface; |
| 24 std::vector<uint8_t> origin_ids; |
| 20 std::vector<GURL> origins; | 25 std::vector<GURL> origins; |
| 21 }; | 26 }; |
| 22 | 27 |
| 23 struct WebUsbConfigurationSubset { | 28 struct WebUsbConfigurationSubset { |
| 24 WebUsbConfigurationSubset(); | 29 WebUsbConfigurationSubset(); |
| 25 ~WebUsbConfigurationSubset(); | 30 ~WebUsbConfigurationSubset(); |
| 26 | 31 |
| 27 uint8_t configuration_value; | 32 uint8_t configuration_value; |
| 33 std::vector<uint8_t> origin_ids; |
| 28 std::vector<GURL> origins; | 34 std::vector<GURL> origins; |
| 29 std::vector<WebUsbFunctionSubset> functions; | 35 std::vector<WebUsbFunctionSubset> functions; |
| 30 }; | 36 }; |
| 31 | 37 |
| 32 struct WebUsbDescriptorSet { | 38 struct WebUsbAllowedOrigins { |
| 33 WebUsbDescriptorSet(); | 39 WebUsbAllowedOrigins(); |
| 34 ~WebUsbDescriptorSet(); | 40 ~WebUsbAllowedOrigins(); |
| 35 | 41 |
| 36 bool Parse(const std::vector<uint8_t>& bytes); | 42 bool Parse(const std::vector<uint8_t>& bytes); |
| 37 | 43 |
| 44 std::vector<uint8_t> origin_ids; |
| 38 std::vector<GURL> origins; | 45 std::vector<GURL> origins; |
| 39 std::vector<WebUsbConfigurationSubset> configurations; | 46 std::vector<WebUsbConfigurationSubset> configurations; |
| 40 }; | 47 }; |
| 41 | 48 |
| 42 struct WebUsbPlatformCapabilityDescriptor { | 49 struct WebUsbPlatformCapabilityDescriptor { |
| 43 WebUsbPlatformCapabilityDescriptor(); | 50 WebUsbPlatformCapabilityDescriptor(); |
| 44 ~WebUsbPlatformCapabilityDescriptor(); | 51 ~WebUsbPlatformCapabilityDescriptor(); |
| 45 | 52 |
| 46 bool ParseFromBosDescriptor(const std::vector<uint8_t>& bytes); | 53 bool ParseFromBosDescriptor(const std::vector<uint8_t>& bytes); |
| 47 | 54 |
| 48 uint16_t version; | 55 uint16_t version; |
| 49 uint8_t vendor_code; | 56 uint8_t vendor_code; |
| 57 uint8_t landing_page_id; |
| 58 GURL landing_page; |
| 50 }; | 59 }; |
| 51 | 60 |
| 52 bool ParseWebUsbUrlDescriptor(const std::vector<uint8_t>& bytes, GURL* output); | 61 bool ParseWebUsbUrlDescriptor(const std::vector<uint8_t>& bytes, GURL* output); |
| 53 | 62 |
| 63 void ReadWebUsbDescriptors( |
| 64 scoped_refptr<UsbDeviceHandle> device_handle, |
| 65 const base::Callback<void(scoped_ptr<WebUsbAllowedOrigins> allowed_origins, |
| 66 const GURL& landing_page)>& callback); |
| 67 |
| 54 } // device | 68 } // device |
| 55 | 69 |
| 56 #endif // DEVICE_USB_WEBUSB_DESCRIPTORS_H_ | 70 #endif // DEVICE_USB_WEBUSB_DESCRIPTORS_H_ |
| OLD | NEW |