Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / extensions / common / api / printer_provider.idl
blob3de58fa051e43423399f4895b1adb9edc637f668
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The <code>chrome.printerProvider</code> API exposes events used by print
6 // manager to query printers controlled by extensions, to query their
7 // capabilities and to submit print jobs to these printers.
8 namespace printerProvider {
9 // Error codes returned in response to $(ref:onPrintRequested) event.
10 enum PrintError {
11 // Operation completed successfully.
12 OK,
14 // General failure.
15 FAILED,
17 // Print ticket is invalid. For example, ticket is inconsistent with
18 // capabilities or extension is not able to handle all settings from the
19 // ticket.
20 INVALID_TICKET,
22 // Document is invalid. For example, data may be corrupted or the format is
23 // incompatible with the extension.
24 INVALID_DATA
27 // Printer description for $(ref:onGetPrintersRequested) event.
28 dictionary PrinterInfo {
29 // Unique printer ID.
30 DOMString id;
32 // Printer's human readable name.
33 DOMString name;
35 // Printer's human readable description.
36 DOMString? description;
39 // Printing request parameters. Passed to $(ref:onPrintRequested) event.
40 dictionary PrintJob {
41 // ID of the printer which should handle the job.
42 DOMString printerId;
44 // The print job title.
45 DOMString title;
47 // Print ticket in
48 // <a href="https://developers.google.com/cloud-print/docs/cdd#cjt">
49 // CJT format</a>.
50 object ticket;
52 // The document content type. Supported formats are
53 // <code>"application/pdf"</code> and <code>"image/pwg-raster"</code>.
54 DOMString contentType;
56 // Blob containing the document data to print. Format must match
57 // |contentType|.
58 [instanceOf=Blob] object document;
61 callback PrintersCallback = void(PrinterInfo[] printerInfo);
63 callback PrinterInfoCallback = void(optional PrinterInfo printerInfo);
65 // |capabilities|: Device capabilities in
66 // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
67 // format</a>.
68 callback CapabilitiesCallback = void(object capabilities);
70 callback PrintCallback = void(PrintError result);
72 interface Events {
73 // Event fired when print manager requests printers provided by extensions.
74 // |resultCallback|: Callback to return printer list. Every listener must
75 // call callback exactly once.
76 static void onGetPrintersRequested(PrintersCallback resultCallback);
78 // Event fired when print manager requests information about a USB device
79 // that may be a printer.
80 // <p><em>Note:</em> An application should not rely on this event being
81 // fired more than once per device. If a connected device is supported it
82 // should be returned in the $(ref:onGetPrintersRequested) event.</p>
83 // |device|: The USB device.
84 // |resultCallback|: Callback to return printer info. The receiving listener
85 // must call callback exactly once. If the parameter to this callback is
86 // undefined that indicates that the application has determined that the
87 // device is not supported.
88 static void onGetUsbPrinterInfoRequested(
89 usb.Device device,
90 PrinterInfoCallback resultCallback);
92 // Event fired when print manager requests printer capabilities.
93 // |printerId|: Unique ID of the printer whose capabilities are requested.
94 // |resultCallback|: Callback to return device capabilities in
95 // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
96 // format</a>.
97 // The receiving listener must call callback exectly once.
98 static void onGetCapabilityRequested(DOMString printerId,
99 CapabilitiesCallback resultCallback);
101 // Event fired when print manager requests printing.
102 // |printJob|: The printing request parameters.
103 // |resultCallback|: Callback that should be called when the printing
104 // request is completed.
105 static void onPrintRequested(PrintJob printJob,
106 PrintCallback resultCallback);