// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use the <code>chrome.usbPrivate</code> API to interact with connected USB
// devices. This API provides private extensions to the <code>chrome.usb</code>
// API which should only be available to trusted pages.
namespace usbPrivate {

  dictionary DeviceInfo {
    long vendorId;  // idVendor from the device
    long productId;  // idProduct from the device

    // Vendor and product names from an internal database.
    DOMString? vendorName;
    DOMString? productName;

    // iManufacturer, iProduct and iSerial strings from the device.
    DOMString? manufacturerString;
    DOMString? productString;
    DOMString? serialString;
  };

  callback GetDevicesCallback = void (long[] deviceIds);
  callback GetDeviceInfoCallback = void (DeviceInfo deviceInfo);

  interface Functions {
    // Lists USB devices matching any of the given filters.
    // |filters|: The properties to search for on target devices.
    // |callback|: Invoked with a list of device IDs on complete.
    static void getDevices(usb.DeviceFilter[] filters,
                           GetDevicesCallback callback);

    // Gets basic display information about a device.
    // |deviceId|: The device ID (from |getDevices|).
    // |callback|: Invoked with |DeviceInfo| from the device.
    static void getDeviceInfo(long deviceId, GetDeviceInfoCallback callback);
  };
};