// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.printerProvider</code> API exposes events used by print
// manager to query printers controlled by extensions, to query their
// capabilities and to submit print jobs to these printers.
namespace printerProvider {
// Error codes returned in response to $(ref:onPrintRequested) event.
enum PrintError {
// Specifies that the operation was completed successfully.
OK,
// Specifies that a general failure occured.
FAILED,
// Specifies that the print ticket is invalid. For example, the ticket is
// inconsistent with some capabilities, or the extension is not able to
// handle all settings from the ticket.
INVALID_TICKET,
// Specifies that the document is invalid. For example, data may be
// corrupted or the format is incompatible with the extension.
INVALID_DATA
};
// Printer description for $(ref:onGetPrintersRequested) event.
dictionary PrinterInfo {
// Unique printer ID.
DOMString id;
// Printer's human readable name.
DOMString name;
// Printer's human readable description.
DOMString? description;
};
// Printing request parameters. Passed to $(ref:onPrintRequested) event.
[noinline_doc] dictionary PrintJob {
// ID of the printer which should handle the job.
DOMString printerId;
// The print job title.
DOMString title;
// Print ticket in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cjt">
// CJT format</a>.
// <aside class="aside flow bg-state-info-bg color-state-info-text">
// <div class="flow">The CJT reference is marked as deprecated. It is
// deprecated for Google Cloud Print only. is not deprecated for
// ChromeOS printing.
// </div>
// </aside>
object ticket;
// The document content type. Supported formats are
// <code>"application/pdf"</code> and <code>"image/pwg-raster"</code>.
DOMString contentType;
// Blob containing the document data to print. Format must match
// |contentType|.
[instanceOf=Blob] object document;
};
callback PrintersCallback = void(PrinterInfo[] printerInfo);
callback PrinterInfoCallback = void(optional PrinterInfo printerInfo);
// |capabilities|: Device capabilities in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
// format</a>.
callback CapabilitiesCallback = void(object capabilities);
callback PrintCallback = void(PrintError result);
interface Events {
// Event fired when print manager requests printers provided by extensions.
// |resultCallback|: Callback to return printer list. Every listener must
// call callback exactly once.
static void onGetPrintersRequested(PrintersCallback resultCallback);
// Event fired when print manager requests information about a USB device
// that may be a printer.
// <p><em>Note:</em> An application should not rely on this event being
// fired more than once per device. If a connected device is supported it
// should be returned in the $(ref:onGetPrintersRequested) event.</p>
// |device|: The USB device.
// |resultCallback|: Callback to return printer info. The receiving listener
// must call callback exactly once. If the parameter to this callback is
// undefined that indicates that the application has determined that the
// device is not supported.
static void onGetUsbPrinterInfoRequested(
usb.Device device,
PrinterInfoCallback resultCallback);
// Event fired when print manager requests printer capabilities.
// |printerId|: Unique ID of the printer whose capabilities are requested.
// |resultCallback|: Callback to return device capabilities in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
// format</a>.
// The receiving listener must call callback exectly once.
static void onGetCapabilityRequested(DOMString printerId,
CapabilitiesCallback resultCallback);
// Event fired when print manager requests printing.
// |printJob|: The printing request parameters.
// |resultCallback|: Callback that should be called when the printing
// request is completed.
static void onPrintRequested(PrintJob printJob,
PrintCallback resultCallback);
};
};