summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/extensions/api/printing.idl
blob: 964c638355803561f7c2309308becebc95e23681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Copyright 2019 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.

// Use the <code>chrome.printing</code> API to send print jobs to printers
// installed on Chromebook.
[platforms=("chromeos"),
implemented_in="chrome/browser/chromeos/extensions/printing/printing_api.h"]
namespace printing {
  dictionary SubmitJobRequest {
    // The print job to be submitted.
    // The only supported content type is "application/pdf", and the CJT ticket
    // shouldn't include FitToPageTicketItem, PageRangeTicketItem,
    // ReverseOrderTicketItem and VendorTicketItem fields since they are
    // irrelevant for native printing. All other fields must be present.
    printerProvider.PrintJob job;

    // Used internally to store the blob uuid after parameter customization and
    // shouldn't be populated by the extension.
    [nodoc] DOMString? documentBlobUuid;
  };

  // The status of $(ref:submitJob) request.
  enum SubmitJobStatus {
    // Sent print job request is accepted.
    OK,

    // Sent print job request is rejected by the user.
    USER_REJECTED
  };

  // Response for $(ref:submitJob) request.
  dictionary SubmitJobResponse {
    // The status of the request.
    SubmitJobStatus status;

    // The id of created print job. This is a unique identifier among all print
    // jobs on the device. If status is not OK, jobId will be null.
    DOMString? jobId;
  };

  // The source of the printer.
  enum PrinterSource {
    // Printer was added by user.
    USER,

    // Printer was added via policy.
    POLICY
  };

  // Description of the printer.
  dictionary Printer {
    // The printer's identifier; guaranteed to be unique among printers on the
    // device.
    DOMString id;

    // The name of the printer.
    DOMString name;

    // The human-readable description of the printer.
    DOMString description;

    // The printer URI. This can be used by extensions to choose the printer for
    // the user.
    DOMString uri;

    // The source of the printer (user or policy configured).
    PrinterSource source;

    // The flag which shows whether the printer fits
    // <a href="https://chromium.org/administrators/policy-list-3#DefaultPrinterSelection">
    // DefaultPrinterSelection</a> rules.
    // Note that several printers could be flagged.
    boolean isDefault;

    // The value showing how recent the printer was used for printing from
    // Chrome. The lower the value is the more recent the printer was used. The
    // minimum value is 0. Missing value indicates that the printer wasn't used
    // recently. This value is guaranteed to be unique amongst printers.
    long? recentlyUsedRank;
  };

  // The status of the printer.
  enum PrinterStatus {
    // The door of the printer is open. Printer still accepts print jobs.
    DOOR_OPEN,

    // The tray of the printer is missing. Printer still accepts print jobs.
    TRAY_MISSING,

    // The printer is out of ink. Printer still accepts print jobs.
    OUT_OF_INK,

    // The printer is out of paper. Printer still accepts print jobs.
    OUT_OF_PAPER,

    // The output area of the printer (e.g. tray) is full. Printer still accepts
    // print jobs.
    OUTPUT_FULL,

    // The printer has a paper jam. Printer still accepts print jobs.
    PAPER_JAM,

    // Some generic issue. Printer still accepts print jobs.
    GENERIC_ISSUE,

    // The printer is stopped and doesn't print but still accepts print jobs.
    STOPPED,

    // The printer is unreachable and doesn't accept print jobs.
    UNREACHABLE,

    // The printer is available.
    AVAILABLE
  };

  // Response for $(ref:getPrinterInfo) request.
  dictionary GetPrinterInfoResponse {
    // Printer capabilities in
    // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">
    // CDD format</a>.
    // The property may be missing.
    object? capabilities;

    // The status of the printer.
    PrinterStatus status;
  };

  // Status of the print job.
  enum JobStatus {
    // Print job is received on Chrome side but was not processed yet.
    PENDING,

    // Print job is sent for printing.
    IN_PROGRESS,

    // Print job was interrupted due to some error.
    FAILED,

    // Print job was canceled by the user or via API.
    CANCELED,

    // Print job was printed without any errors.
    PRINTED
  };

  callback SubmitJobCallback = void(SubmitJobResponse response);
  callback CancelJobCallback = void();
  callback GetPrintersCallback = void(Printer[] printers);
  callback GetPrinterInfoCallback = void(GetPrinterInfoResponse response);

  interface Functions {
    // Submits the job for print.
    // If the extension is not listed in PrintingAPIExtensionsAllowlist policy,
    // the user will be prompted to accept the print job.
    static void submitJob(SubmitJobRequest request, SubmitJobCallback callback);

    // Cancels previously submitted job.
    // |jobId|: The id of the print job to cancel. This should be the same id
    // received in a $(ref:SubmitJobResponse).
    static void cancelJob(DOMString jobId, CancelJobCallback callback);

    // Returns the list of available printers on the device. This includes
    // manually added, enterprise and discovered printers.
    static void getPrinters(GetPrintersCallback callback);

    // Returns the status and capabilities of the printer in
    // <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">
    // CDD format</a>.
    // This call will fail with a runtime error if no printers with given id are
    // installed.
    static void getPrinterInfo(DOMString printerId,
                               GetPrinterInfoCallback callback);
  };

  interface Properties {
    // The maximum number of times that $(ref:submitJob) can be called per
    // minute.
    [value=20] static long MAX_SUBMIT_JOB_CALLS_PER_MINUTE();

    // The maximum number of times that $(ref:getPrinterInfo) can be called per
    // minute.
    [value=20] static long MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE();
  };

  interface Events {
    // Event fired when the status of the job is changed.
    // This is only fired for the jobs created by this extension.
    static void onJobStatusChanged(DOMString jobId, JobStatus status);
  };
};