local_printer.mojom 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. // Copyright 2021 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. module crosapi.mojom;
  5. import "mojo/public/mojom/base/time.mojom";
  6. import "printing/backend/mojom/print_backend.mojom";
  7. import "printing/mojom/print.mojom";
  8. import "ui/gfx/geometry/mojom/geometry.mojom";
  9. import "url/mojom/url.mojom";
  10. // This structure holds basic information about a printer.
  11. // It corresponds to the LocalDestinationInfo object in
  12. // chrome/browser/resources/print_preview/data/local_parsers.js.
  13. [Stable]
  14. struct LocalDestinationInfo {
  15. // Printer id.
  16. string id@0;
  17. // Printer display name.
  18. string name@1;
  19. // Printer description.
  20. string description@2;
  21. // Whether or not the printer is configured through a policy.
  22. // Corresponds to the cupsEnterprisePrinter field of the js
  23. // LocalDestinationInfo object.
  24. bool configured_via_policy@3;
  25. // The GURL class cannot be used as it does not support the ipp/ipps scheme.
  26. [MinVersion=3] string? uri@4;
  27. };
  28. // A container for the results of a printer status query. A printer status
  29. // query can return multiple errors so PrinterStatus contains multiple
  30. // StatusReasons. This struct corresponds to the PrinterStatus object in
  31. // chrome/browser/resources/print_preview/data/printer_status_cros.js.
  32. [Stable]
  33. struct PrinterStatus {
  34. // Printer id.
  35. string printer_id@0;
  36. // Timestamp is set when the Status object is created.
  37. mojo_base.mojom.Time timestamp@1;
  38. // Status reasons lists warnings and errors encountered by the
  39. // printer such as low on ink or out of paper.
  40. array<StatusReason> status_reasons@2;
  41. };
  42. // StatusReason is a combination of a reason, which describes the state of a
  43. // printer, and a severity, which is the level of seriousness of that state.
  44. // The Reason and Severity enum types are also used by the CupsPrinterStatus
  45. // object in chromeos/printing/cups_printer_status.h.
  46. [Stable]
  47. struct StatusReason {
  48. // Reason describes the state of the printer.
  49. // It is used by the CupsPrinterStatus class
  50. // (chromeos/printing/cups_printer_status.h).
  51. Reason reason@0;
  52. // Severity is the level of seriousness of a printer state.
  53. // It is also used by the CupsPrinterStatus class.
  54. Severity severity@1;
  55. // See chrome/browser/chromeos/printing/cups_printer_status_creator.cc
  56. // for information about the mapping (many to one) of
  57. // printing::PrinterStatus::PrinterReason::Reason (UMA histogram) values
  58. // which correspond to IPP printer-state-reasons (rfc2911#section-4.4.12)
  59. // to the Reason enum below. kNoError is a reserved value that is unused
  60. // by the PrinterStatus object.
  61. [Stable, Extensible]
  62. enum Reason {
  63. [Default] kUnknownReason,
  64. kDeviceError,
  65. kDoorOpen,
  66. kLowOnInk,
  67. kLowOnPaper,
  68. kNoError, // reserved
  69. kOutOfInk,
  70. kOutOfPaper,
  71. kOutputAreaAlmostFull,
  72. kOutputFull,
  73. kPaperJam,
  74. kPaused,
  75. kPrinterQueueFull,
  76. kPrinterUnreachable,
  77. kStopped,
  78. kTrayMissing,
  79. };
  80. [Stable, Extensible]
  81. enum Severity {
  82. [Default] kUnknownSeverity,
  83. kReport,
  84. kWarning,
  85. kError,
  86. };
  87. };
  88. // This structure is a subset of the PrintJobInfo message in
  89. // chrome/browser/chromeos/printing/history/print_job_info.proto.
  90. [Stable]
  91. struct PrintJob {
  92. // Printer id.
  93. string device_name@0;
  94. // The title of the document which was printed.
  95. string title@1;
  96. // Print job ID (used to check job status in CUPS).
  97. uint32 job_id@2;
  98. // The number of pages in the document.
  99. uint32 page_count@3;
  100. // Source showing which component initiated the print job.
  101. Source source@4;
  102. // ID of source. Should be empty if source is PRINT_PREVIEW or ARC.
  103. string source_id@5;
  104. // Converted to a print_job_info.proto ColorMode enum via
  105. // printing::IsColorModelSelected().
  106. printing.mojom.ColorModel color_mode@6;
  107. // The requested duplex mode.
  108. DuplexMode duplex_mode@7;
  109. // Size in microns of the media used for printing.
  110. gfx.mojom.Size media_size@8;
  111. // Vendor-provided ID, e.g. "iso_a3_297x420mm" or "na_index-3x5_3x5in".
  112. // Possible values are values of "media" IPP attribute and can be found on
  113. // https://www.iana.org/assignments/ipp-registrations/ipp-registrations.xhtml.
  114. string media_vendor_id@9;
  115. // The requested number of copies.
  116. uint32 copies@10;
  117. // A subset of DuplexMode in printing/mojom/print.mojom.
  118. // kUnknownDuplexMode has been removed to match the proto version
  119. // in chrome/browser/chromeos/printing/history/print_job_info.proto.
  120. [Stable, Extensible]
  121. enum DuplexMode {
  122. [Default] kSimplex,
  123. kLongEdge,
  124. kShortEdge,
  125. };
  126. // Used in chrome/browser/printing/print_job.h.
  127. // TODO(b/184986771): Rename to kUnknown, kPrintPreview, etc.
  128. [Stable, Extensible]
  129. enum Source {
  130. [Default] UNKNOWN = -1,
  131. PRINT_PREVIEW,
  132. ARC,
  133. EXTENSION,
  134. PRINT_PREVIEW_INCOGNITO,
  135. };
  136. };
  137. // This structure corresponds to the chromeos::PrintServersConfig struct
  138. // in chrome/browser/chromeos/printing/print_servers_manager.h.
  139. [Stable]
  140. struct PrintServersConfig {
  141. ServerPrintersFetchingMode fetching_mode@0;
  142. array<PrintServer> print_servers@1;
  143. // Used in chrome/browser/chromeos/printing/print_servers_policy_provider.h.
  144. [Stable, Extensible]
  145. enum ServerPrintersFetchingMode {
  146. // Use the first 16 print servers.
  147. [Default] kStandard,
  148. // Use print servers selected via ChoosePrintServers().
  149. kSingleServerOnly,
  150. };
  151. };
  152. [Stable]
  153. struct PrintServer {
  154. string id@0;
  155. url.mojom.Url url@1;
  156. string name@2;
  157. };
  158. [Stable]
  159. struct CapabilitiesResponse {
  160. // Basic information about the printer.
  161. LocalDestinationInfo basic_info@0;
  162. // Whether or not the protocol is secure (e.g. ipps).
  163. bool has_secure_protocol@1;
  164. // Printer capabilities and defaults corresponding to the
  165. // PrinterSemanticCapsAndDefaults class in printing/backend/print_backend.h.
  166. printing.mojom.PrinterSemanticCapsAndDefaults? capabilities@2;
  167. // The fields below are no longer used.
  168. // Bitmask of allowed color modes corresponding to the ColorModeRestriction
  169. // enum in printing/backend/printing_restrictions.h.
  170. uint32 allowed_color_modes_deprecated@3;
  171. // Bitmask of allowed duplex modes.
  172. uint32 allowed_duplex_modes_deprecated@4;
  173. uint32 allowed_pin_modes_deprecated_version_0@5;
  174. [MinVersion=1] printing.mojom.PinModeRestriction allowed_pin_modes_deprecated_version_1@9;
  175. printing.mojom.ColorModeRestriction default_color_mode_deprecated@6;
  176. printing.mojom.DuplexModeRestriction default_duplex_mode_deprecated@7;
  177. printing.mojom.PinModeRestriction default_pin_mode_deprecated@8;
  178. };
  179. // Global print policies that are not printer specific.
  180. [Stable]
  181. struct Policies {
  182. // The allowed value for the 'Headers and footers' checkbox, in Print Preview.
  183. OptionalBool print_header_footer_allowed@0;
  184. // The default value for the 'Headers and footers' checkbox, in Print Preview.
  185. OptionalBool print_header_footer_default@1;
  186. // A pref holding the allowed background graphics printing modes.
  187. BackgroundGraphicsModeRestriction allowed_background_graphics_modes@2;
  188. // A pref holding the default background graphics mode.
  189. BackgroundGraphicsModeRestriction background_graphics_default@3;
  190. // A pref holding the default paper size.
  191. gfx.mojom.Size? paper_size_default@4;
  192. // Indicates how many sheets is allowed to use for a single print job.
  193. uint32 max_sheets_allowed@5;
  194. bool max_sheets_allowed_has_value@6;
  195. // Bitmask of allowed color modes corresponding to the ColorModeRestriction
  196. // enum in printing/backend/printing_restrictions.h.
  197. [MinVersion=1] uint32 allowed_color_modes@7;
  198. // Bitmask of allowed duplex modes.
  199. [MinVersion=1] uint32 allowed_duplex_modes@8;
  200. [MinVersion=1] printing.mojom.PinModeRestriction allowed_pin_modes@9;
  201. [MinVersion=1] printing.mojom.ColorModeRestriction default_color_mode@10;
  202. [MinVersion=1] printing.mojom.DuplexModeRestriction default_duplex_mode@11;
  203. [MinVersion=1] printing.mojom.PinModeRestriction default_pin_mode@12;
  204. [MinVersion=2] OptionalBool default_print_pdf_as_image@13;
  205. // Allowed background graphics modes.
  206. // This is used in pref file and should never change.
  207. // Corresponds to enum class BackgroundGraphicsModeRestriction in
  208. // printing/backend/printing_restrictions.h.
  209. [Stable, Extensible]
  210. enum BackgroundGraphicsModeRestriction {
  211. [Default] kUnset = 0,
  212. kEnabled = 1,
  213. kDisabled = 2,
  214. };
  215. [Stable]
  216. enum OptionalBool {
  217. kUnset,
  218. kFalse,
  219. kTrue,
  220. };
  221. };
  222. // This interface is used to notify Lacros about print server events.
  223. [Stable, Uuid="39885b28-cbc6-4878-834f-b0902d8e6fbf"]
  224. interface PrintServerObserver {
  225. // Runs when the print server configuration is updated, e.g.
  226. // a new print server is added or discovered.
  227. OnPrintServersChanged@0(PrintServersConfig config);
  228. // Runs when printers have been fetched from a print server.
  229. // Lacros calls LocalPrinter::GetPrinters to update the printer list
  230. // each time this notification is received.
  231. OnServerPrintersChanged@1();
  232. };
  233. // Corresponds to functions in CupsPrintJobManager::Observer
  234. // (chrome/browser/chromeos/printing/cups_print_job_manager.h).
  235. [Stable, Extensible]
  236. enum PrintJobStatus {
  237. [Default] kUnknown, // reserved
  238. kCreated,
  239. kStarted,
  240. kUpdated,
  241. kSuspended,
  242. kResumed,
  243. kDone,
  244. kError,
  245. kCancelled,
  246. };
  247. // This interface is used to notify Lacros about print job events.
  248. [Stable, Uuid="a372ba50-7409-4c16-86b9-47a1725947d0"]
  249. interface PrintJobObserver {
  250. // Runs when the status of a print job changes.
  251. OnPrintJobUpdate@0(string printer_id, uint32 job_id, PrintJobStatus status);
  252. };
  253. // Used to specify which source(s) to observe print jobs from.
  254. [Stable, Extensible]
  255. enum PrintJobSource {
  256. [Default] kAny, // reserved
  257. kExtension,
  258. };
  259. // This interface is used to query information about local printers
  260. // associated with the current Ash profile that can be used for
  261. // printing from Lacros.
  262. [Stable, Uuid="81aea7f5-a52b-4f88-8037-951f3c174f1e"]
  263. interface LocalPrinter {
  264. // Gets a list of printers. An empty array is returned on error.
  265. GetPrinters@0() => (array<LocalDestinationInfo> printers);
  266. // Gets capabilities for a printer as a CapabilitiesResponse object.
  267. // See chrome/browser/resources/print_preview/native_layer.js for a
  268. // detailed description of the CapabilitiesResponse object as well as
  269. // chrome/browser/resources/print_preview/data/ for descriptions of
  270. // the various sub-objects (such as the Cloud Device Description object).
  271. // The capabilities field (CapabilitiesResponse.capabilities) is null on
  272. // error. If the printer does not exist, null is returned.
  273. GetCapability@1(string printer_id) => (CapabilitiesResponse? capabilities);
  274. // Gets the PPD license url for a printer.
  275. // An empty url is returned if no such url exists.
  276. GetEulaUrl@2(string printer_id) => (url.mojom.Url url);
  277. // Gets the current status of a printer.
  278. // Note: this method queries the printer directly instead of via CUPS.
  279. // It may take several seconds for the printer to respond.
  280. GetStatus@3(string printer_id) => (PrinterStatus status);
  281. // Opens a system print settings window.
  282. ShowSystemPrintSettings@4() => ();
  283. // Adds a new print job to the ash print job manager.
  284. CreatePrintJob@5(PrintJob job) => ();
  285. // Cancels a print job. Forwards to CancelPrintJob() in
  286. // ash/webui/print_management/mojom/printing_manager.mojom.
  287. [MinVersion=3]
  288. CancelPrintJob@12(string printer_id, uint32 job_id) => (bool attempted);
  289. // Gets print server information.
  290. GetPrintServersConfig@6() => (PrintServersConfig config);
  291. // Selects print servers to query printers from.
  292. // Invalid print server IDs are ignored.
  293. // This function does nothing if the print server scaling feature
  294. // is disabled or the fetching mode is not kSingleServerOnly.
  295. ChoosePrintServers@7(array<string> print_server_ids) => ();
  296. // Adds a print server observer.
  297. AddPrintServerObserver@8(pending_remote<PrintServerObserver> observer) => ();
  298. // Gets print policies.
  299. GetPolicies@9() => (Policies policies);
  300. // Checks if |kPrintingSendUsernameAndFilenameEnabled| is enabled for the
  301. // current Ash profile. Returns the profile's corresponding username if pref
  302. // enabled.
  303. [MinVersion=1]
  304. GetUsernamePerPolicy@10() => (string? username);
  305. // Gets list of printers types included in the deny list policy.
  306. [MinVersion=2]
  307. GetPrinterTypeDenyList@11() => (array<printing.mojom.PrinterType> deny_list);
  308. // Adds a print job observer for print jobs from source `source`.
  309. [MinVersion=3]
  310. AddPrintJobObserver@13(
  311. pending_remote<PrintJobObserver> observer,
  312. PrintJobSource source) => ();
  313. };