// 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 "chromeos/crosapi/mojom/local_printer.mojom";
import "components/printing/common/print.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "mojo/public/mojom/base/values.mojom";
import "printing/mojom/print.mojom";
import "ui/gfx/image/mojom/image.mojom";
import "url/mojom/url.mojom";
// The different print scaling options available for a document.
[Stable, Extensible]
enum ScalingType {
// No additional scaling.
[Default] kDefault = 0,
// Scale to the page size.
kFitToPage = 1,
// Scale to the paper size.
kFitToPaper = 2,
// User set scaling.
kCustom = 3,
};
// Custom margins of the document.
[Stable]
struct MarginsCustom {
// Right, left, top, bottom margins in pixels.
uint32 margin_right@0;
uint32 margin_left@1;
uint32 margin_top@2;
uint32 margin_bottom@3;
};
// Contains all fields relevant to the media size of the document.
[Stable]
struct MediaSize {
// Dimensions of the media to be printed in microns.
uint32 height_microns@0;
uint32 width_microns@1;
uint32 imageable_area_bottom_microns@2;
uint32 imageable_area_left_microns@3;
uint32 imageable_area_right_microns@4;
uint32 imageable_area_top_microns@5;
// Below are optional fields that may be set by the printer.
// Vendor ID of the printer.
mojo_base.mojom.String16? vendor_id@6;
// Name of the paper type, if customized (e.g. LETTER).
mojo_base.mojom.String16? custom_display_name@7;
// Whether this was the default setting provided by the printer.
bool? is_default@8;
// Name of the paper type (e.g. NA_LETTER).
mojo_base.mojom.String16? name@9;
};
// Params used to generate a print preview, these fields are provided by the
// print preview UI and can be modified by the user to customize their document.
[Stable]
struct PrintSettings {
// The following are settings common all print command requests.
// ID of the preview dialog.
uint32 preview_id@0;
// ID of the request, multiple print requests can happen per instance of a
// print preview.
uint32 request_id@1;
// Whether this was the first request to print.
bool is_first_request@2;
// Type of the printer.
printing.mojom.PrinterType printer_type@3;
// Margin type.
printing.mojom.MarginType margin_type@4;
// Scaling type.
ScalingType scaling_type@5;
// Whether if the print should collate.
bool collate@6;
// Number of copies
uint32 copies@7;
// The color options used for printing.
printing.mojom.ColorModel color@8;
// Duplex mode options.
printing.mojom.DuplexMode duplex@9;
// If true, print in landscape. If false, printing in portrait mode.
bool landscape@10;
// Name of the print destination.
mojo_base.mojom.String16? device_name@11;
// Scale factor used for printing.
uint32 scale_factor@12;
// Whether to rasterize the pdf, available if the print desitnation has
// rasterization support.
bool rasterize_pdf@13;
// Number of pages to print per sheet.
uint32 pages_per_sheet@14;
// Horizontal dpi of the document.
uint32 dpi_horizontal@15;
// Vertical dpi of the document.
uint32 dpi_vertical@16;
// Custom margins, potentially set by the user.
MarginsCustom margins_custom@17;
// Page range to print.
array<uint32> page_range@18;
// True if header and footer should be printed.
bool header_footer_enabled@19;
// Title of the page, only available if the header and footer are enabled.
mojo_base.mojom.String16? title@20;
// URL of the page, only available if the header and footer are enabled.
url.mojom.Url? url@21;
// Size of the media to be printed.
MediaSize media_size@22;
// Whether the background css should be included in the print.
bool should_print_backgrounds@23;
// Whether to only print a selection of the document.
bool should_print_selection_only@24;
// The following are optional fields set depending on the destination source
// and print command.
// Advance settings provided by the destination, this subset may contain
// OEM and product exclusive settings.
map<string, mojo_base.mojom.Value>? advanced_settings@25;
// Rasterization dpi of the document, only available if rasterize_pdf is true.
uint32? rasterize_pdf_dpi@26;
// Borderless printing support.
bool? borderless@27;
// Media type of the document.
mojo_base.mojom.String16? media_type@28;
// Whether the preview can be modified.
bool? preview_modifiable@29;
// Whether to send telemetry data to the printer.
bool? send_user_info@30;
// User name to be sent to the printer.
mojo_base.mojom.String16? user_name@31;
// OAuth token to be sent to the printer.
mojo_base.mojom.String16? chromeos_access_oauth_token@32;
// Pin to be sent to the printer.
mojo_base.mojom.String16? pin_value@33;
// IPP info to be sent to the printer.
array<printing.mojom.IppClientInfo>? ipp_client_info@34;
// Whether this printer was manually selected by the user.
bool? printer_manually_selected@35;
// The printer status reason shown for the selected printer at the time print
// is requested.
StatusReason.Reason? printer_status_reason@36;
// JSON formatted capabilities of the printer.
mojo_base.mojom.String16? capabilities@37;
// Whether to display the composited pdf in preview.
bool? open_pdf_in_preview@38;
// Whether the print job uses the default DPI.
bool? dpi_default@39;
// Number of pages to be printed.
uint32? page_count@40;
// Whether the system dialog should be printed.
bool? show_system_dialog@41;
};
// Delegate implemented by ash. Informs ash of webcontent-related events from
// browser (lacros or ash) to ash.
[Stable, Uuid="b098f7de-cd7b-4970-8d58-becdb32ca560"]
interface PrintPreviewCrosDelegate {
// Binds mojo client, allows ash to make calls to mojo client.
RegisterMojoClient@0(pending_remote<PrintPreviewCrosClient> client)
=> (bool success);
// Called when a webcontent requests to open a new instance of print preview.
RequestPrintPreview@1(mojo_base.mojom.UnguessableToken token,
printing.mojom.RequestPrintPreviewParams params) => (bool success);
// Called when a webcontent is done (canceled or completed) and therefore its
// print preview must be closed.
PrintPreviewDone@2(mojo_base.mojom.UnguessableToken token) => (bool success);
};
// Client interface implemented by browser (ash or lacros). Facilitates requests
// made from ash and implemented by browser.
[Stable, Uuid="d2ec732b-c29c-4959-b3a7-e7dbb3abdb13"]
interface PrintPreviewCrosClient {
// Start the process of generating a preview for the intiating source. This
// is done asynchronously. Progress of the preview generation is provided by
// mojom::PrintPreviewUI. `settings` is the print settings provided by
// the print preview UI.
GeneratePrintPreview@0(mojo_base.mojom.UnguessableToken token,
PrintSettings settings)
=> (bool success);
// Handle when the print preview dialog is closed by navigation. For
// example, closing dialog via Exit navigation button.
[MinVersion=1]HandleDialogClosed@1(mojo_base.mojom.UnguessableToken token)
=> (bool success);
};