// Copyright 2015 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.

// webstoreWidgetPrivate API.
// This is a private API used by the Chrome Webstore widget app on Chrome OS.
[platforms=("chromeos")]
namespace webstoreWidgetPrivate {
// The type of apps that should be shown in the Webstore widget.
enum Type {
  // Type that should be used to list printer provider apps. For this type,
  // options passed to |onShowWidget| should have |usbId| property set.
  PRINTER_PROVIDER
};

// ID for a USB device.
dictionary UsbId {
  // The USB device's vendor ID property.
  long vendorId;

  // The USB device's product ID property.
  long productId;
};

// Filter for apps that will be shown in the Webstore widget.
dictionary Options {
  // The type of apps that should be shown.
  Type type;

  // If set, only apps that have printerProvider permission and usbDevices
  // permission for USB device with the provided (vendor ID, product ID) pair.
  // Required if |type| is set to |PRINTER_PROVIDER|.
  UsbId? usbId;
};

// |result| Object containing the string assets.
callback GetStringsCallback = void(object result);

// Callback that does not take arguments.
callback SimpleCallback = void();

interface Functions {
  // Gets localized strings and initialization data.
  static void getStrings(GetStringsCallback callback);

  // Requests to install a webstore item.
  // |item_id| The id of the item to install.
  // |silentInstallation| False to show installation prompt. True not to show.
  //     Can be set to true only for a subset of installation requests.
  static void installWebstoreItem(DOMString itemId,
                                  boolean silentInstallation,
                                  SimpleCallback callback);
};

interface Events {
  // Event dispatched when a Chrome Webstore widget is requested to be shown.
  // |options|: Options describing the set of apps that should be shown in the
  //     widget.
  static void onShowWidget(Options options);
};

};
