blob: ffa9b0ec89115908680e09775dcf02a1e3ba3694 [file] [log] [blame]
// Copyright 2019 The Chromium Authors
// 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", "lacros"),
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.
// Sent print job request is rejected by the user.
// 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.
// Printer was added via 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="">
// 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.
// The tray of the printer is missing. Printer still accepts print jobs.
// The printer is out of ink. Printer still accepts print jobs.
// The printer is out of paper. Printer still accepts print jobs.
// The output area of the printer (e.g. tray) is full. Printer still accepts
// print jobs.
// The printer has a paper jam. Printer still accepts print jobs.
// Some generic issue. Printer still accepts print jobs.
// The printer is stopped and doesn't print but still accepts print jobs.
// The printer is unreachable and doesn't accept print jobs.
// The SSL certificate is expired. Printer accepts jobs but they fail.
// The printer is available.
// Response for $(ref:getPrinterInfo) request.
dictionary GetPrinterInfoResponse {
// Printer capabilities in
// <a href="">
// 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.
// Print job is sent for printing.
// Print job was interrupted due to some error.
// Print job was canceled by the user or via API.
// Print job was printed without any errors.
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.
// Use the
// <a href="">
// <code>PrintingAPIExtensionsAllowlist</code></a> to bypass promting
// the user to confirm printing.
[supportsPromises] 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).
[supportsPromises] static void cancelJob(DOMString jobId,
CancelJobCallback callback);
// Returns the list of available printers on the device. This includes
// manually added, enterprise and discovered printers.
[supportsPromises] static void getPrinters(GetPrintersCallback callback);
// Returns the status and capabilities of the printer in
// <a href="">
// CDD format</a>.
// This call will fail with a runtime error if no printers with given id are
// installed.
[supportsPromises] static void getPrinterInfo(
DOMString printerId,
GetPrinterInfoCallback callback);
interface Properties {
// The maximum number of times that $(ref:submitJob) can be called per
// minute.
[value=40] 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);