OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This API exposes events used by print manager to query printers controlled | 5 // The <code>chrome.printerProvider</code> API exposes events used by print |
6 // by extensions, to query capabilities of them and to submit print jobs to | 6 // manager to query printers controlled by extensions, to query their |
7 // these printers. | 7 // capabilities and to submit print jobs to these printers. |
8 namespace printerProvider { | 8 namespace printerProvider { |
9 // Error codes used by providing extensions in response to requests. | 9 // Error codes returned in response to $(ref:onPrintRequested) event. |
10 enum PrintError { | 10 enum PrintError { |
11 // Operation completed successfully. | 11 // Operation completed successfully. |
12 OK, | 12 OK, |
13 | 13 |
14 // General failure. | 14 // General failure. |
15 FAILED, | 15 FAILED, |
16 | 16 |
17 // Print ticket is invalid. For example, ticket is inconsistent with | 17 // Print ticket is invalid. For example, ticket is inconsistent with |
18 // capabilities or extension is not able to handle all settings from the | 18 // capabilities or extension is not able to handle all settings from the |
19 // ticket. | 19 // ticket. |
20 INVALID_TICKET, | 20 INVALID_TICKET, |
21 | 21 |
22 // Document is invalid. For example, data may be corrupted or the format is | 22 // Document is invalid. For example, data may be corrupted or the format is |
23 // incompatible with the Extension. | 23 // incompatible with the extension. |
24 INVALID_DATA | 24 INVALID_DATA |
25 }; | 25 }; |
26 | 26 |
27 // Printer description for $(ref:onGetPrintersRequested) event. | 27 // Printer description for $(ref:onGetPrintersRequested) event. |
28 dictionary PrinterInfo { | 28 dictionary PrinterInfo { |
29 // Unique ID of printer. | 29 // Unique printer ID. |
30 DOMString id; | 30 DOMString id; |
31 | 31 |
32 // Human readable display name of printer. | 32 // Printer's human readable name. |
33 DOMString name; | 33 DOMString name; |
34 | 34 |
35 // Human readable description of printer. | 35 // Printer's human readable description. |
36 DOMString? description; | 36 DOMString? description; |
37 }; | 37 }; |
38 | 38 |
39 // Parameters of $(ref:onPrintRequested). | 39 // Printing request parameters. Passed to $(ref:onPrintRequested) event. |
40 dictionary PrintJob { | 40 dictionary PrintJob { |
41 // ID of the printer to submit the job. | 41 // ID of the printer which should handle the job. |
42 DOMString printerId; | 42 DOMString printerId; |
43 | 43 |
44 // print ticket in CJT format described at | 44 // Print ticket in |
45 // https://developers.google.com/cloud-print/docs/cdd#cjt | 45 // <a href="https://developers.google.com/cloud-print/docs/cdd#cjt"> |
| 46 // CJT format</a>. |
46 object ticket; | 47 object ticket; |
47 | 48 |
48 // Content type of the document. Supported formats are "application/pdf" and | 49 // The document content type. Supported formats are |
49 // "image/pwg-raster". | 50 // <code>"application/pdf"</code> and <code>"image/pwg-raster"</code>. |
50 DOMString contentType; | 51 DOMString contentType; |
51 | 52 |
52 // Buffer with document to printer. Format must match |contentType|. | 53 // Buffer containing the document to print. Format must match |contentType|. |
53 ArrayBuffer document; | 54 ArrayBuffer document; |
54 }; | 55 }; |
55 | 56 |
56 callback PrintersCallback = void(PrinterInfo[] printerInfo); | 57 callback PrintersCallback = void(PrinterInfo[] printerInfo); |
| 58 |
| 59 // |capabilities|: Device capabilities in |
| 60 // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD |
| 61 // format</a>. |
57 callback CapabilitiesCallback = void(object capabilities); | 62 callback CapabilitiesCallback = void(object capabilities); |
| 63 |
58 callback PrintCallback = void(PrintError result); | 64 callback PrintCallback = void(PrintError result); |
59 | 65 |
60 interface Events { | 66 interface Events { |
61 // Event fired when print manager requests printers provided by extension. | 67 // Event fired when print manager requests printers provided by extensions. |
62 // |resultCallback| : callback to return printer list. Every listener must | 68 // |resultCallback|: Callback to return printer list. Every listener must |
63 // call callback exactly once. | 69 // call callback exactly once. |
64 static void onGetPrintersRequested(PrintersCallback resultCallback); | 70 static void onGetPrintersRequested(PrintersCallback resultCallback); |
65 | 71 |
66 // Event fired when print manager requests printer capabilities. | 72 // Event fired when print manager requests printer capabilities. |
67 // |printerId| : unique ID of the printer. | 73 // |printerId|: Unique ID of the printer whose capabilities are requested. |
68 // |resultCallback| : callback to return device capabilities in CDD format | 74 // |resultCallback|: Callback to return device capabilities in |
69 // as described at https://developers.google.com/cloud-print/docs/cdd#cdd. | 75 // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD |
| 76 // format</a>. |
70 // The receiving listener must call callback exectly once. | 77 // The receiving listener must call callback exectly once. |
71 static void onGetCapabilityRequested(DOMString printerId, | 78 static void onGetCapabilityRequested(DOMString printerId, |
72 CapabilitiesCallback resultCallback); | 79 CapabilitiesCallback resultCallback); |
73 | 80 |
74 // Event fired when print manager requests printing. | 81 // Event fired when print manager requests printing. |
75 // |printJob| : parameters of printing request. | 82 // |printJob|: The printing request parameters. |
| 83 // |resultCallback|: Callback that should be called when the printing |
| 84 // request is completed. |
76 static void onPrintRequested(PrintJob printJob, | 85 static void onPrintRequested(PrintJob printJob, |
77 PrintCallback resultCallback); | 86 PrintCallback resultCallback); |
78 }; | 87 }; |
79 }; | 88 }; |
80 | 89 |
OLD | NEW |