chromium/components/printing/common/cloud_print_cdd_conversion.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/printing/common/cloud_print_cdd_conversion.h"

#include <stddef.h>

#include <memory>
#include <utility>

#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/printer_description.h"
#include "printing/backend/print_backend.h"
#include "printing/mojom/print.mojom.h"

printer;

namespace cloud_print {

namespace {

#if BUILDFLAG(IS_WIN)
constexpr char kIdPageOutputQuality[] = "page_output_quality";
constexpr char kDisplayNamePageOutputQuality[] = "Page output quality";
#endif  // BUILDFLAG(IS_WIN)

printer::DuplexType ToCloudDuplexType(printing::mojom::DuplexMode mode) {}

#if BUILDFLAG(IS_CHROMEOS)
printer::TypedValueVendorCapability::ValueType ToCloudValueType(
    printing::AdvancedCapability::Type type) {
  switch (type) {
    case printing::AdvancedCapability::Type::kBoolean:
      return printer::TypedValueVendorCapability::ValueType::BOOLEAN;
    case printing::AdvancedCapability::Type::kFloat:
      return printer::TypedValueVendorCapability::ValueType::FLOAT;
    case printing::AdvancedCapability::Type::kInteger:
      return printer::TypedValueVendorCapability::ValueType::INTEGER;
    case printing::AdvancedCapability::Type::kString:
      return printer::TypedValueVendorCapability::ValueType::STRING;
    default:
      NOTREACHED_IN_MIGRATION();
  }
  return printer::TypedValueVendorCapability::ValueType::STRING;
}
#endif  // BUILDFLAG(IS_CHROMEOS)

printer::Media ConvertPaperToMedia(
    const printing::PrinterSemanticCapsAndDefaults::Paper& paper) {}

printer::MediaCapability GetMediaCapabilities(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {}

printer::MediaTypeCapability GetMediaTypeCapabilities(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {}

printer::DpiCapability GetDpiCapabilities(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {}

#if BUILDFLAG(IS_CHROMEOS)
printer::VendorCapabilities GetVendorCapabilities(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {
  printer::VendorCapabilities vendor_capabilities;
  for (const auto& capability : semantic_info.advanced_capabilities) {
    std::string capability_name = capability.display_name.empty()
                                      ? capability.name
                                      : capability.display_name;
    if (capability.values.empty()) {
      vendor_capabilities.AddOption(
          printer::VendorCapability(capability.name, capability_name,
                                    printer::TypedValueVendorCapability(
                                        ToCloudValueType(capability.type))));
      continue;
    }

    printer::SelectVendorCapability select_capability;
    for (const auto& value : capability.values) {
      std::string localized_value =
          value.display_name.empty() ? value.name : value.display_name;
      select_capability.AddDefaultOption(
          printer::SelectVendorCapabilityOption(value.name, localized_value),
          value.name == capability.default_value);
    }
    vendor_capabilities.AddOption(printer::VendorCapability(
        capability.name, capability_name, std::move(select_capability)));
  }

  return vendor_capabilities;
}
#endif  // BUILDFLAG(IS_CHROMEOS)

#if BUILDFLAG(IS_WIN)
printer::SelectVendorCapability GetPageOutputQualityCapabilities(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {
  printer::SelectVendorCapability page_output_quality_capabilities;
  const std::optional<printing::PageOutputQuality>& page_output_quality =
      semantic_info.page_output_quality;
  for (const auto& attribute : page_output_quality->qualities) {
    page_output_quality_capabilities.AddDefaultOption(
        printer::SelectVendorCapabilityOption(attribute.name,
                                              attribute.display_name),
        attribute.name == page_output_quality->default_quality);
  }
  return page_output_quality_capabilities;
}
#endif  // BUILDFLAG(IS_WIN)

}  // namespace

base::Value PrinterSemanticCapsAndDefaultsToCdd(
    const printing::PrinterSemanticCapsAndDefaults& semantic_info) {}

}  // namespace cloud_print