// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module crosapi.mojom;
import "mojo/public/mojom/base/ref_counted_memory.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "mojo/public/mojom/base/values.mojom";
// Status codes returned in response to a StartPrint request. It is based on
// the PrinterError enum in extensions/common/api/printer_provider.idl.
//
// LINT.IfChange(StartPrintStatus)
[Stable, Extensible]
enum StartPrintStatus {
[Default] kUnknown,
// Specifies that the operation was completed successfully.
KOk,
// Specifies that a general failure occurred.
kFailed,
// Specifies that the print ticket is invalid.
kInvalidTicket,
// Specifies that the document is invalid.
kInvalidData
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/printing/enums.xml:ExtensionPrintJobStatus)
// Interface between the Ash system and lacros browser. Implemented in Ash,
// Interface to allow lacros-chrome to register a service provider and to
// communicate with ash to report extension printers.
// Implemented by ash-chrome.
//
// Next version: 1.
// Next method id: 2.
[Stable, Uuid="def89e7c-8e4f-4718-92db-24f1329fcd29"]
interface ExtensionPrinterService {
// An ExtensionPrinterServiceProvider can register itself with
// ExtensionPrinterService, so that ExtensionPrinterService can communicate
// with the remote ExtensionPrinterServiceProvider associated with the main
// profile.
RegisterServiceProvider@0(
pending_remote<ExtensionPrinterServiceProvider> client);
// Runs when a printing extension reports printers in response to a
// DispatchGetPrintersRequest. A true value of |is_done| means no more
// printers will be reported.
PrintersAdded@1(mojo_base.mojom.UnguessableToken request_id,
mojo_base.mojom.ListValue printers, bool is_done);
};
// Implemented by lacros-chrome. Used by ash-chrome to forward printing related
// requests to lacros-chrome.
//
// Next version: 4.
// Next method id: 5.
[Stable, Uuid="74d95a4e-56e3-4fdf-8df5-62660939dc73"]
interface ExtensionPrinterServiceProvider {
// Dispatch StartGetPrinters requests to lacros from ash-chrome. The
// |request_id| will be used when reporting printers back to ash-chrome by
// lacros printing extensions.
DispatchGetPrintersRequest@0(mojo_base.mojom.UnguessableToken request_id);
// Dispatch Reset requests to lacros from ash-chrome. The extension printer
// handler keeps certain states for ongoing get printers requests. Reset
// clears the states if any to ensure only one request is active at a time.
// The extension printer handler does not support concurrent requests.
[MinVersion=1] DispatchResetRequest@1();
// Gets capabilities for an extension printer. The |destination_id| uniquely
// identifies a printer within a specific extension using both the extension
// ID and an internal printer ID.
//
// Please see extensions/common/api/printer_provider.idl for comments about
// capabilities.
[MinVersion=1] DispatchStartGetCapability@2(string destination_id)
=> (mojo_base.mojom.DictionaryValue capabilities);
// Dispatches StartPrint requests to lacros from ash-chrome. StartPrint
// submits a print job to a printer.
[MinVersion=2] DispatchStartPrint@3(
mojo_base.mojom.String16 job_title,
mojo_base.mojom.DictionaryValue settings,
mojo_base.mojom.RefCountedMemory print_data)
=> (StartPrintStatus status);
// Dispatch StartGrantPrinterAccess to the given provisional printer.
// The print handler will respond with more information about the printer
// including its non-provisional printer id.
[MinVersion=3] DispatchStartGrantPrinterAccess@4(string printer_id)
=> (mojo_base.mojom.DictionaryValue print_info);
};