chromium/printing/backend/mojom/print_backend.mojom

// 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 printing.mojom;

import "printing/mojom/print.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";

// Basic information for a specific printer.
// Corresponds to `printing::PrinterBasicInfo` in
// printing/backend/print_backend.h.
struct PrinterBasicInfo {
  string printer_name;
  string display_name;
  string printer_description;
  int32 printer_status;
  bool is_default;
  map<string, string> options;
};

// Paper used by printer semantic capabilities and defaults.
// Corresponds to `printing::PrinterSemanticCapsAndDefaults::Paper` in
// printing/backend/print_backend.h.
// For backwards compatibility, `printable_area_um` must be optional.
[Stable]
struct Paper {
  string display_name;
  string vendor_id;
  gfx.mojom.Size size_um;
  [MinVersion=1] gfx.mojom.Rect? printable_area_um;
  [MinVersion=2] int32 max_height_um;
  [MinVersion=3] bool has_borderless_variant;
};

// Media type used by printer semantic capabilities and defaults.
// Corresponds to `printing::PrinterSemanticCapsAndDefaults::MediaType` in
// printing/backend/print_backend.h.
[Stable]
struct MediaType {
  string display_name;
  string vendor_id;
};

// An advanced capability value for ChromeOS printing.
// Paper used by printer semantic capabilities and defaults.
// Corresponds to `printing::AdvancedCapabilityValue` in
// printing/backend/print_backend.h.
[Stable, EnableIf=is_chromeos]
struct AdvancedCapabilityValue {
  string name;
  string display_name;
};

// The type of the values for advanced capabilities.
// Corresponds to `printing::AdvancedCapability::Type` in
// printing/backend/print_backend.h.
[Stable, Extensible, EnableIf=is_chromeos]
enum AdvancedCapabilityType {
  [Default] kString,
  kBoolean,
  kFloat,
  kInteger,
};

// An advanced capability for ChromeOS printing.
// Corresponds to `printing::AdvancedCapability` in
// printing/backend/print_backend.h.
[Stable, EnableIf=is_chromeos]
struct AdvancedCapability {
  string name;
  string display_name;
  AdvancedCapabilityType type;
  string default_value;
  array<AdvancedCapabilityValue> values;
};

// Attributes of a Page Output Quality of XPS printer for Windows printing.
// Corresponds to `printing::PageOutpuQualityAttribute` in
// printing/backend/print_backend.h.
[Stable, EnableIf=is_win]
struct PageOutputQualityAttribute {
  string display_name;
  string name;
};

// Page Output Quality from XPS printer for Windows printing. Corresponds to
// `printing::PageOutputQuality` in printing/backend/print_backend.h.
[Stable, EnableIf=is_win]
struct PageOutputQuality {
  array<PageOutputQualityAttribute> qualities;  // No duplicates.
  string? default_quality;  // Default selection of `qualities`.
                            // Null if no default.
};

// The semantic capabilities and defaults used for a printer.
// Corresponds to `printing::PrinterSemanticCapsAndDefaults` in
// printing/backend/print_backend.h.
[Stable]
struct PrinterSemanticCapsAndDefaults {
  bool collate_capable = false;
  bool collate_default = false;
  int32 copies_max = 1;  // Valid values are only >= 1.
  array<DuplexMode> duplex_modes;
  DuplexMode duplex_default = kUnknownDuplexMode;
  bool color_changeable = false;
  bool color_default = false;
  ColorModel color_model = kUnknownColorModel;
  ColorModel bw_model = kUnknownColorModel;
  array<Paper> papers;  // Empty and duplicates allowed.
  array<Paper> user_defined_papers;
  Paper default_paper;
  array<gfx.mojom.Size> dpis;  // Duplicates allowed.
  gfx.mojom.Size default_dpi;

  [EnableIf=is_chromeos]
  bool pin_supported = false;
  [EnableIf=is_chromeos]
  array<AdvancedCapability> advanced_capabilities;

  // Null if feature flag `kReadPrinterCapabilitiesWithXps` is disabled.
  // Null if printer doesn't have this capability.
  [EnableIf=is_win, MinVersion=1]
  PageOutputQuality? page_output_quality;

  [MinVersion=2]
  array<MediaType>? media_types;  // Allowed to be empty.
  [MinVersion=2]
  MediaType? default_media_type;
};