Commit 2f663899 authored by Yuta Hijikata's avatar Yuta Hijikata Committed by Commit Bot

LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH)

Background:
Currently lacros-chrome is built with target_os="linux" but we plan to build lacros-chrome with target_os="chromeos" going forward.
To achieve this goal, we have to replace defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH) so not to include code specific to ash-chrome in lacros-chrome.

What this does:
We are replacing existing defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH) with an
exception where is is accompanied with `|| defined(OS_LINUX)` since that
will evaluate to true for both ash-chrome and lacros-chrome.

The buildflag was introduced in http://crrev.com/c/2426071.

For more detail please read the design doc go/lacros-build-config.

Test: printing_unittests
Bug: 1052397
Change-Id: I51902ef0e963c509662576885be5602895685908
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437079Reviewed-by: default avatarSean Kau <skau@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814163}
parent bd36295f
......@@ -100,6 +100,7 @@ component("printing") {
"//base",
"//base:i18n",
"//base/third_party/dynamic_annotations",
"//build:chromeos_buildflags",
"//cc/paint",
"//printing/common",
"//printing/mojom",
......@@ -296,6 +297,7 @@ static_library("test_support") {
]
deps = [
"//base",
"//build:chromeos_buildflags",
"//skia",
"//ui/gfx",
]
......@@ -336,6 +338,7 @@ test("printing_unittests") {
deps = [
":printing",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//mojo/core/test:run_all_unittests",
"//mojo/public/cpp/test_support:test_utils",
"//printing/backend/mojom",
......
......@@ -6,6 +6,8 @@
#include <cups/cups.h>
#include "build/chromeos_buildflags.h"
namespace printing {
constexpr char kIppCollate[] = "multiple-document-handling"; // PWG 5100.19
......@@ -22,7 +24,7 @@ constexpr char kIppPinEncryption[] = "job-password-encryption"; // PWG 5100.11
constexpr char kCollated[] = "separate-documents-collated-copies";
constexpr char kUncollated[] = "separate-documents-uncollated-copies";
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
constexpr char kIppDocumentAttributes[] =
"document-creation-attributes"; // PWG 5100.5
......@@ -33,6 +35,6 @@ constexpr char kPinEncryptionNone[] = "none";
constexpr char kOptionFalse[] = "false";
constexpr char kOptionTrue[] = "true";
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
} // namespace printing
......@@ -5,6 +5,7 @@
#ifndef PRINTING_BACKEND_CUPS_IPP_CONSTANTS_H_
#define PRINTING_BACKEND_CUPS_IPP_CONSTANTS_H_
#include "build/chromeos_buildflags.h"
#include "printing/printing_export.h"
namespace printing {
......@@ -24,7 +25,7 @@ PRINTING_EXPORT extern const char kIppPinEncryption[];
PRINTING_EXPORT extern const char kCollated[];
PRINTING_EXPORT extern const char kUncollated[];
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
PRINTING_EXPORT extern const char kIppDocumentAttributes[];
PRINTING_EXPORT extern const char kIppJobAttributes[];
......@@ -34,7 +35,7 @@ PRINTING_EXPORT extern const char kPinEncryptionNone[];
PRINTING_EXPORT extern const char kOptionFalse[];
PRINTING_EXPORT extern const char kOptionTrue[];
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
} // namespace printing
......
......@@ -15,6 +15,7 @@
#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "build/chromeos_buildflags.h"
#include "printing/backend/cups_connection.h"
#include "printing/backend/cups_ipp_constants.h"
#include "printing/backend/cups_printer.h"
......@@ -23,19 +24,19 @@
#include "printing/printing_utils.h"
#include "printing/units.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
#include "base/callback.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "printing/backend/ipp_handler_map.h"
#include "printing/printing_features.h"
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
namespace printing {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
constexpr int kPinMinimumLength = 4;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
namespace {
......@@ -255,7 +256,7 @@ bool CollateDefault(const CupsOptionProvider& printer) {
return name && !base::StringPiece(name).compare(kCollated);
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
bool PinSupported(const CupsOptionProvider& printer) {
ipp_attribute_t* attr = printer.GetSupportedOptionValues(kIppPin);
if (!attr)
......@@ -310,7 +311,7 @@ void ExtractAdvancedCapabilities(const CupsOptionProvider& printer,
attr_count += AddAttributes(printer, kIppDocumentAttributes, options);
base::UmaHistogramCounts1000("Printing.CUPS.IppAttributesCount", attr_count);
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
} // namespace
......@@ -333,11 +334,11 @@ void CapsAndDefaultsFromPrinter(const CupsOptionProvider& printer,
printer_info->default_paper = DefaultPaper(printer);
printer_info->papers = SupportedPapers(printer);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
printer_info->pin_supported = PinSupported(printer);
if (base::FeatureList::IsEnabled(printing::features::kAdvancedPpdAttributes))
ExtractAdvancedCapabilities(printer, printer_info);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
ExtractCopies(printer, printer_info);
ExtractColor(printer, printer_info);
......
......@@ -13,6 +13,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/backend/cups_printer.h"
#include "printing/mojom/print.mojom.h"
#include "printing/printing_features.h"
......@@ -284,7 +285,7 @@ TEST_F(PrintBackendCupsIppHelperTest, OmitPapersWithSpecialVendorIds) {
"iso b0")));
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
TEST_F(PrintBackendCupsIppHelperTest, PinSupported) {
printer_->SetSupportedOptions("job-password", MakeInteger(ipp_, 4));
printer_->SetSupportedOptions("job-password-encryption",
......@@ -363,6 +364,6 @@ TEST_F(PrintBackendCupsIppHelperTest, AdvancedCaps) {
EXPECT_EQ(3u, caps.advanced_capabilities[5].values.size());
histograms.ExpectUniqueSample("Printing.CUPS.IppAttributesCount", 5, 1);
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
} // namespace printing
......@@ -4,6 +4,8 @@
#include "printing/backend/print_backend.h"
#include "build/chromeos_buildflags.h"
namespace {
// PrintBackend override for testing.
......@@ -19,7 +21,7 @@ PrinterBasicInfo::PrinterBasicInfo(const PrinterBasicInfo& other) = default;
PrinterBasicInfo::~PrinterBasicInfo() = default;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
AdvancedCapabilityValue::AdvancedCapabilityValue() = default;
......@@ -57,7 +59,7 @@ AdvancedCapability::AdvancedCapability(const AdvancedCapability& other) =
AdvancedCapability::~AdvancedCapability() = default;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
bool PrinterSemanticCapsAndDefaults::Paper::operator==(
const PrinterSemanticCapsAndDefaults::Paper& other) const {
......
......@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/print_job_constants.h"
#include "printing/printing_export.h"
......@@ -47,7 +48,7 @@ struct PRINTING_EXPORT PrinterBasicInfo {
using PrinterList = std::vector<PrinterBasicInfo>;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
struct PRINTING_EXPORT AdvancedCapabilityValue {
AdvancedCapabilityValue();
......@@ -95,7 +96,7 @@ struct PRINTING_EXPORT AdvancedCapability {
using AdvancedCapabilities = std::vector<AdvancedCapability>;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults {
PrinterSemanticCapsAndDefaults();
......@@ -133,10 +134,10 @@ struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults {
std::vector<gfx::Size> dpis;
gfx::Size default_dpi;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
bool pin_supported = false;
AdvancedCapabilities advanced_capabilities;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
};
struct PRINTING_EXPORT PrinterCapsAndDefaults {
......
......@@ -4,16 +4,18 @@
#include "printing/backend/printing_restrictions.h"
#include "build/chromeos_buildflags.h"
namespace printing {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
const char kAllowedColorModes[] = "allowedColorModes";
const char kAllowedDuplexModes[] = "allowedDuplexModes";
const char kAllowedPinModes[] = "allowedPinModes";
const char kDefaultColorMode[] = "defaultColorMode";
const char kDefaultDuplexMode[] = "defaultDuplexMode";
const char kDefaultPinMode[] = "defaultPinMode";
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
const char kPaperSizeName[] = "name";
const char kPaperSizeNameCustomOption[] = "custom";
......
......@@ -5,11 +5,12 @@
#ifndef PRINTING_BACKEND_PRINTING_RESTRICTIONS_H_
#define PRINTING_BACKEND_PRINTING_RESTRICTIONS_H_
#include "build/chromeos_buildflags.h"
#include "printing/printing_export.h"
namespace printing {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Allowed printing modes as a bitmask.
// This is used in pref file and should never change.
enum class ColorModeRestriction {
......@@ -45,7 +46,7 @@ PRINTING_EXPORT extern const char kAllowedPinModes[];
PRINTING_EXPORT extern const char kDefaultColorMode[];
PRINTING_EXPORT extern const char kDefaultDuplexMode[];
PRINTING_EXPORT extern const char kDefaultPinMode[];
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
// Allowed background graphics modes.
// This is used in pref file and should never change.
......
......@@ -7,9 +7,10 @@
#include "base/atomic_sequence_num.h"
#include "base/lazy_instance.h"
#include "base/notreached.h"
#include "build/chromeos_buildflags.h"
#include "printing/units.h"
#if defined(USE_CUPS) && (defined(OS_MAC) || defined(OS_CHROMEOS))
#if defined(USE_CUPS) && (defined(OS_MAC) || BUILDFLAG(IS_ASH))
#include <cups/cups.h>
#endif
......@@ -182,7 +183,7 @@ void GetColorModelForModel(mojom::ColorModel color_model,
// all ColorModel values are determinantly handled.
}
#if defined(OS_MAC) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || BUILDFLAG(IS_ASH)
std::string GetIppColorModelForModel(mojom::ColorModel color_model) {
// Accept |kUnknownColorModel| for consistency with GetColorModelForModel().
if (color_model == mojom::ColorModel::kUnknownColorModel)
......@@ -197,7 +198,7 @@ std::string GetIppColorModelForModel(mojom::ColorModel color_model) {
return is_color.value() ? CUPS_PRINT_COLOR_MODE_COLOR
: CUPS_PRINT_COLOR_MODE_MONOCHROME;
}
#endif // defined(OS_MAC) || defined(OS_CHROMEOS)
#endif // defined(OS_MAC) || BUILDFLAG(IS_ASH)
#endif // defined(USE_CUPS)
base::Optional<bool> IsColorModelSelected(mojom::ColorModel color_model) {
......@@ -280,11 +281,11 @@ void PrintSettings::Clear() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
advanced_settings_.clear();
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
send_user_info_ = false;
username_.clear();
pin_value_.clear();
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
}
void PrintSettings::SetPrinterPrintableArea(
......
......@@ -11,6 +11,7 @@
#include "base/optional.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/page_range.h"
#include "printing/page_setup.h"
......@@ -43,7 +44,7 @@ PRINTING_EXPORT void GetColorModelForModel(mojom::ColorModel color_model,
std::string* color_setting_name,
std::string* color_value);
#if defined(OS_MAC) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || BUILDFLAG(IS_ASH)
// Convert from |color_model| to a print-color-mode value from PWG 5100.13.
PRINTING_EXPORT std::string GetIppColorModelForModel(
mojom::ColorModel color_model);
......@@ -228,7 +229,7 @@ class PRINTING_EXPORT PrintSettings {
}
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
void set_send_user_info(bool send_user_info) {
send_user_info_ = send_user_info;
}
......@@ -239,7 +240,7 @@ class PRINTING_EXPORT PrintSettings {
void set_pin_value(const std::string& pin_value) { pin_value_ = pin_value; }
const std::string& pin_value() const { return pin_value_; }
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
// Cookie generator. It is used to initialize PrintedDocument with its
// associated PrintSettings, to be sure that each generated PrintedPage is
......@@ -325,7 +326,7 @@ class PRINTING_EXPORT PrintSettings {
AdvancedSettings advanced_settings_;
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Whether to send user info.
bool send_user_info_;
......
......@@ -17,6 +17,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/print_job_constants.h"
#include "printing/print_settings.h"
......@@ -221,7 +222,7 @@ std::unique_ptr<PrintSettings> PrintSettingsFromJobSettings(
}
#endif // defined(OS_CHROMEOS) || (defined(OS_LINUX) && defined(USE_CUPS))
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
bool send_user_info =
job_settings.FindBoolKey(kSettingSendUserInfo).value_or(false);
settings->set_send_user_info(send_user_info);
......@@ -234,7 +235,7 @@ std::unique_ptr<PrintSettings> PrintSettingsFromJobSettings(
const std::string* pin_value = job_settings.FindStringKey(kSettingPinValue);
if (pin_value)
settings->set_pin_value(*pin_value);
#endif
#endif // BUILDFLAG(IS_ASH)
return settings;
}
......
......@@ -7,6 +7,7 @@
#include "base/json/json_reader.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/print_settings.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -60,7 +61,7 @@ TEST(PrintSettingsConversionTest, ConversionTest) {
std::unique_ptr<PrintSettings> settings =
PrintSettingsFromJobSettings(value.value());
ASSERT_TRUE(settings);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
EXPECT_TRUE(settings->send_user_info());
EXPECT_EQ("username@domain.net", settings->username());
EXPECT_EQ("0000", settings->pin_value());
......@@ -79,7 +80,7 @@ TEST(PrintSettingsConversionTest, ConversionTest) {
#endif
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
TEST(PrintSettingsConversionTest, ConversionTest_DontSendUsername) {
base::Optional<base::Value> value = base::JSONReader::Read(kPrinterSettings);
ASSERT_TRUE(value.has_value());
......
......@@ -6,6 +6,7 @@
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -55,7 +56,7 @@ TEST(PrintSettingsTest, GetColorModelForModel) {
}
}
#if defined(OS_MAC) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || BUILDFLAG(IS_ASH)
TEST(PrintSettingsTest, GetIppColorModelForModel) {
for (int model = static_cast<int>(mojom::ColorModel::kUnknownColorModel);
model <= static_cast<int>(mojom::ColorModel::kColorModelLast); ++model) {
......@@ -63,7 +64,7 @@ TEST(PrintSettingsTest, GetIppColorModelForModel) {
.empty());
}
}
#endif // defined(OS_MAC) || defined(OS_CHROMEOS)
#endif // defined(OS_MAC) || BUILDFLAG(IS_ASH)
#endif // defined(USE_CUPS)
} // namespace printing
......@@ -5,10 +5,11 @@
#include "printing/printed_document.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/printing_context_linux.h"
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
#error "This file is not used on Android / ChromeOS"
#if defined(OS_ANDROID) || BUILDFLAG(IS_ASH)
#error "This file is not used on Android / ChromeOS ash-chrome"
#endif
namespace printing {
......
......@@ -8,6 +8,7 @@
#include "base/check.h"
#include "base/notreached.h"
#include "build/chromeos_buildflags.h"
#include "printing/page_setup.h"
#include "printing/print_job_constants.h"
#include "printing/print_settings_conversion.h"
......@@ -145,7 +146,7 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings(
job_settings.FindIntKey(kSettingPreviewPageCount).value_or(0));
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
PrintingContext::Result PrintingContext::UpdatePrintSettingsFromPOD(
std::unique_ptr<PrintSettings> job_settings) {
ResetSettings();
......
......@@ -12,6 +12,7 @@
#include "base/strings/string16.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/native_drawing_context.h"
#include "printing/print_settings.h"
......@@ -86,7 +87,7 @@ class PRINTING_EXPORT PrintingContext {
// settings information.
Result UpdatePrintSettings(base::Value job_settings);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Updates Print Settings.
Result UpdatePrintSettingsFromPOD(
std::unique_ptr<PrintSettings> job_settings);
......
......@@ -4,14 +4,16 @@
#include "printing/printing_features.h"
#include "build/chromeos_buildflags.h"
namespace printing {
namespace features {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Enables Advanced PPD Attributes.
const base::Feature kAdvancedPpdAttributes{"AdvancedPpdAttributes",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
#if defined(OS_MAC)
// Use the CUPS IPP printing backend instead of the original CUPS backend that
......
......@@ -7,6 +7,7 @@
#include "base/feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "printing/printing_export.h"
namespace printing {
......@@ -15,9 +16,9 @@ namespace features {
// The following features are declared alphabetically. The features should be
// documented with descriptions of their behaviors in the .cc file.
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
PRINTING_EXPORT extern const base::Feature kAdvancedPpdAttributes;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
#if defined(OS_MAC)
PRINTING_EXPORT extern const base::Feature kCupsIppPrintingBackend;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment