// 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 "device/bluetooth/public/mojom/uuid.mojom"; import "mojo/public/mojom/base/unguessable_token.mojom"; import "services/device/public/mojom/serial.mojom"; struct SerialPortInfo { // Opaque identifier for this port. mojo_base.mojom.UnguessableToken token; // USB device properties. uint16 usb_vendor_id; bool has_usb_vendor_id = false; uint16 usb_product_id; bool has_usb_product_id = false; // Bluetooth service class UUID if the port is from a Bluetooth device. bluetooth.mojom.UUID? bluetooth_service_class_id; // True if the serial port was connected when the SerialPortInfo was returned // from the SerialService. SerialServiceClients are notified on port connected // state changes. // // A wired serial port is considered connected if it is physically attached // to the system. // // A wireless serial port is considered connected if the wireless device // hosting the port has any active connections to the system. bool connected; }; struct SerialPortFilter { // USB or Bluetooth device vendor and product IDs. uint32 vendor_id; bool has_vendor_id; uint16 product_id; bool has_product_id; // Bluetooth service class UUID. bluetooth.mojom.UUID? bluetooth_service_class_id; }; // This interface must be provided by the browser process in order for the // renderer process to implement the navigator.serial API. interface SerialService { // Sets the client which will receive notifications of events from this // service, such as when ports are added and removed from the system. SetClient(pending_remote client); // Retrieves information about all ports available to this client. GetPorts() => (array ports); // Requests permission to access a port. RequestPort(array filters, array allowed_bluetooth_service_class_ids) => (SerialPortInfo? port); // Opens the port represented by |token| using |options| and returns a // connection to it in |port|. OpenPort(mojo_base.mojom.UnguessableToken token, device.mojom.SerialConnectionOptions options, pending_remote client) => (pending_remote? port); // Attempts to revoke the permission to the device by |token|. // It will fail silently if the permission cannot be revoked. ForgetPort(mojo_base.mojom.UnguessableToken token) => (); }; // Client interface for receiving events from SerialService. interface SerialServiceClient { // Called when a port described by |port_info| is connected or disconnected. OnPortConnectedStateChanged(SerialPortInfo port_info); };