Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / api / printer_provider.idl
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.
4
5 // This API exposes events used by print manager to query printers controlled
6 // by extensions, to query capabilities of them and to submit print jobs to
7 // these printers.
8 namespace printerProvider {
9   // Error codes used by providing extensions in response to requests.
10   enum PrintError {
11     // Operation completed successfully.
12     OK,
13
14     // General failure.
15     FAILED,
16
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,
21
22     // Document is invalid. For example, data may be corrupted or the format is
23     // incompatible with the Extension.
24     INVALID_DATA
25   };
26
27   // Printer description for $(ref:onGetPrintersRequested) event.
28   dictionary PrinterInfo {
29     // Unique ID of printer.
30     DOMString id;
31
32     // Human readable display name of printer.
33     DOMString name;
34
35     // Human readable description of printer.
36     DOMString? description;
37   };
38
39   // Parameters of $(ref:onPrintRequested).
40   dictionary PrintJob {
41     // ID of the printer to submit the job.
42     DOMString printerId;
43
44     // print ticket in CJT format described at
45     // https://developers.google.com/cloud-print/docs/cdd#cjt
46     object ticket;
47
48     // Content type of the document. Supported formats are "application/pdf" and
49     // "image/pwg-raster".
50     DOMString contentType;
51
52     // Buffer with document to printer. Format must match |contentType|.
53     ArrayBuffer document;
54   };
55
56   callback PrintersCallback = void(PrinterInfo[] printerInfo);
57   callback CapabilitiesCallback = void(object capabilities);
58   callback PrintCallback = void(PrintError result);
59
60   interface Events {
61     // Event fired when print manager requests printers provided by extension.
62     // |resultCallback| : callback to return printer list. Every listener must
63     // call callback exactly once.
64     static void onGetPrintersRequested(PrintersCallback resultCallback);
65
66     // Event fired when print manager requests printer capabilities.
67     // |printerId| : unique ID of the printer.
68     // |resultCallback| : callback to return device capabilities in CDD format
69     // as described at https://developers.google.com/cloud-print/docs/cdd#cdd.
70     // The receiving listener must call callback exectly once.
71     static void onGetCapabilityRequested(DOMString printerId,
72                                          CapabilitiesCallback resultCallback);
73
74     // Event fired when print manager requests printing.
75     // |printJob| : parameters of printing request.
76     static void onPrintRequested(PrintJob printJob,
77                                  PrintCallback resultCallback);
78   };
79 };
80