File: printing_manager.mojom

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (170 lines) | stat: -rw-r--r-- 6,065 bytes parent folder | download | duplicates (7)
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
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module chromeos.printing.printing_manager.mojom;

import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "url/mojom/url.mojom";

// Enumeration of print job status.
enum PrintJobCompletionStatus {
  kFailed,
  kCanceled,
  kPrinted
};

// Enumeration of all the possible printer error codes. The order of these enums
// must match that of chrome/browser/chromeos/printing/printer_error_codes.h
enum PrinterErrorCode {
  kNoError,
  kPaperJam,
  kOutOfPaper,
  kOutOfInk,
  kDoorOpen,
  kPrinterUnreachable,
  kTrayMissing,
  kOutputFull,
  kStopped,
  kFilterFailed,
  kUnknownError,
  kClientUnauthorized,
  kExpiredCertificate,
};

// Contains information about a completed print job. Completed print jobs are
// stored to the local database. Information of this struct includes the
// completion status and error code associated with the print job. This struct
// is null for active print jobs, i.e. jobs that are currently being printed and
// are not stored in the local database.
struct CompletedPrintJobInfo {
  // Corresponds to the status of the print job after it has completed.
  PrintJobCompletionStatus completion_status;
};

// Enumeration of ongoing print job status.
enum ActivePrintJobState {
  // Print job is currently being printed.
  kStarted,

  // The print job's document is considered finished to the printer.
  // This includes successful, failed, and cancelled print jobs.
  kDocumentDone,
};

// Contains all relevant information in regards to an active print job i.e. one
// that is current being printed.
struct ActivePrintJobInfo {
  // Number of current printed pages.
  uint32 printed_pages;

  // Current state of the print job.
  ActivePrintJobState active_state;
};

// Contains all the information in regards to a print job. Information is
// provided by the printer. Printer details, i.e. name and uri, can be edited
// via print settings.
struct PrintJobInfo {
  // Unique identifier for a particular print job.
  string id;

  // Title of the print job. Usually the name of the printed file.
  mojo_base.mojom.String16 title;

  // Time of when the print job was requested.
  mojo_base.mojom.Time creation_time;

  // Number of pages requested to print.
  uint32 number_of_pages;

  // Printer GUID.
  string printer_id;

  // The printer destination the print job was sent to.
  mojo_base.mojom.String16 printer_name;

  // The URI of the printer the print job was requested to.
  url.mojom.Url printer_uri;

  // Corresponds to the error code reported by the printer.
  PrinterErrorCode printer_error_code;

  // Information of a completed print job. Null struct if the print job is
  // currently being printed.
  CompletedPrintJobInfo? completed_info;

  // Contains information relevant to an active print job. Null struct if
  // the print job is from the local database.
  ActivePrintJobInfo? active_print_job_info;
};

// Observer interface that sends remote updates to the print management app UI
// receiver.
interface PrintJobsObserver {
  // Notifies that the local print job database has been cleared.
  OnAllPrintJobsDeleted();

  // Notifies that an ongoing print job has been updated.
  OnPrintJobUpdate(PrintJobInfo print_job);
};

// Provides APIs to retrieve print metadata information. This API is exposed
// only to the Print Management App (chrome://print-management). Interfaces are
// implemented by a browser service. Interacts with PrintHistory API to retrieve
// print job metadatas.
interface PrintingMetadataProvider {
  // Takes in a remote so that the implementer binds it and send notifications
  // to the receiver in the print management app. This is to set up automatic
  // updates from the browser process to the renderer process.
  // (print management app UI). This is guaranteed to not send remote updates
  // to disconnected receivers.
  ObservePrintJobs(pending_remote<PrintJobsObserver> observer) => ();

  // Returns an array of PrintJobInfo. This is the main function to retrieve
  // the print history of a device.
  GetPrintJobs() => (array<PrintJobInfo> print_jobs);

  // Deletes all print jobs tracked on this device. Returns true if deleting all
  // print jobs was successful. Returns false if there was an error with
  // retrieving the print jobs to delete in this device.
  DeleteAllPrintJobs() => (bool success);

  // Cancels an ongoing print job keyed by PrintJobInfo.id.
  // This is a best effort attempt as there is no guarantee that we can cancel
  // a print job. Returns true if cancelling the print job was attempted.
  // Returns false if cancelling the print job was not attempted.
  CancelPrintJob(string id) => (bool attempted_cancel);

  // Returns true if the user is allowed to delete their own print job history
  // (default value is true for non-managed users).
  GetDeletePrintJobHistoryAllowedByPolicy() => (bool is_allowed_by_policy);

  // Returns the database expiration period of the print job metadata in days.
  GetPrintJobHistoryExpirationPeriod() => (
      int16 expiration_period_in_days,
      bool is_from_policy);
};

// Enum used in metrics, represents the element in Print Management interactived
// with to open Printer settings.
enum LaunchSource {
  // Button displayed in Print Management when there are no print jobs.
  kEmptyStateButton,

  // Button displayed in Print Management when there are ongoing or historical
  // print jobs.
  kHeaderButton,
};

// Provides services needed by the Print Management UI. Implemented in the
// browser process and called by the Print Management SWA (a renderer process).
interface PrintManagementHandler {
  // Opens OS Settings to the Printer settings subpage. `source` parameter
  // used to help record users' action.
  LaunchPrinterSettings(LaunchSource source);

  // Record the length of time in milliseconds for a print jobs request.
  RecordGetPrintJobsRequestDuration(uint32 duration);
};