webusb_descriptors.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_USB_WEBUSB_DESCRIPTORS_H_
  5. #define SERVICES_DEVICE_USB_WEBUSB_DESCRIPTORS_H_
  6. #include <stdint.h>
  7. #include "base/callback_forward.h"
  8. #include "base/containers/span.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. class GURL;
  12. namespace device {
  13. class UsbDeviceHandle;
  14. struct WebUsbPlatformCapabilityDescriptor {
  15. WebUsbPlatformCapabilityDescriptor();
  16. ~WebUsbPlatformCapabilityDescriptor();
  17. bool ParseFromBosDescriptor(base::span<const uint8_t> bytes);
  18. uint16_t version;
  19. uint8_t vendor_code;
  20. uint8_t landing_page_id;
  21. };
  22. bool ParseWebUsbUrlDescriptor(base::span<const uint8_t> bytes, GURL* output);
  23. void ReadWebUsbLandingPage(
  24. uint8_t vendor_code,
  25. uint8_t landing_page_id,
  26. scoped_refptr<UsbDeviceHandle> device_handle,
  27. base::OnceCallback<void(const GURL& landing_page)> callback);
  28. void ReadWebUsbCapabilityDescriptor(
  29. scoped_refptr<UsbDeviceHandle> device_handle,
  30. base::OnceCallback<void(
  31. const absl::optional<WebUsbPlatformCapabilityDescriptor>& descriptor)>
  32. callback);
  33. void ReadWebUsbDescriptors(
  34. scoped_refptr<UsbDeviceHandle> device_handle,
  35. base::OnceCallback<void(const GURL& landing_page)> callback);
  36. } // namespace device
  37. #endif // SERVICES_DEVICE_USB_WEBUSB_DESCRIPTORS_H_