// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "services/device/public/mojom/usb_device.mojom";
import "services/device/public/mojom/usb_enumeration_options.mojom";
import "services/device/public/mojom/usb_manager_client.mojom";
struct WebUsbRequestDeviceOptions {
array<device.mojom.UsbDeviceFilter> filters;
array<device.mojom.UsbDeviceFilter> exclusion_filters;
};
// This is a parallel interface with UsbDeviceManager aimed to handle extra work
// such as permission checking, chooser showing, etc. in browser.
// WebUsbServiceImpl in //chrome/browser/usb will implement this interface, and
// it will be used by webusb module in //third_party/blink/renderer/modules/.
interface WebUsbService {
// Retrieves information about all devices available.
GetDevices() => (array<device.mojom.UsbDeviceInfo> results);
// Requests a device by guid.
GetDevice(string guid,
pending_receiver<device.mojom.UsbDevice> device_receiver);
// Get permission from user to use a device.
//
// A chooser dialog is displayed with a list of connected devices. The
// list is filtered to contain only the ones that match |options->filters|
// and exclude |options->exclusion_filters|.
//
// |result| is the device that user grants permission to use.
GetPermission(WebUsbRequestDeviceOptions options)
=> (device.mojom.UsbDeviceInfo? result);
// Attempts to revoke the permission to the device by guid.
// It will fail silently if the permission cannot be revoked.
ForgetDevice(string guid) => ();
// Sets the client for this WebUsbService.
SetClient(
pending_associated_remote<device.mojom.UsbDeviceManagerClient> client);
};