Skip to content

Commit

Permalink
LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_CHROMEOS_ASH)
Browse files Browse the repository at this point in the history
The change is mostly mechanical replacing defined(OS_CHROMEOS) with
BUILDFLAG(IS_CHROMEOS_ASH) and GN variable is_chromeos with
is_chromeos_ash with some special cases (For those cases please
refer to http://go/lacros-macros).

The patch is made in preparation to switching lacros build from
target_os=linux to target_os=chromeos. This will prevent lacros from
changing behaviour after the switch.

Bug: 1052397
Change-Id: Iad750ef52b3a42cc0339e8e6fdb682c4cf397b16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550844
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Wei Li <weili@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833996}
  • Loading branch information
Yuta Hijikata authored and Chromium LUCI CQ committed Dec 5, 2020
1 parent 9b5d9de commit 34c1b55
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 86 deletions.
17 changes: 9 additions & 8 deletions printing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/sysroot.gni")
import("//build/config/ui.gni")
Expand All @@ -14,7 +15,7 @@ if (is_mac) {
if (is_android) {
import("//build/config/android/rules.gni")
}
if (use_cups && is_chromeos) {
if (use_cups && is_chromeos_ash) {
import("//printing/backend/tools/code_generator.gni")
}

Expand All @@ -28,7 +29,7 @@ if ((enable_basic_printing && is_win) || enable_print_preview) {
# Enable the CUPS IPP printing backend.
# TODO(crbug.com/226176): Remove this after CUPS PPD API calls are removed.
declare_args() {
use_cups_ipp = use_cups && !is_linux
use_cups_ipp = use_cups && !(is_linux || is_chromeos_lacros)
}

# Several targets want to include this header file. We separate it out
Expand All @@ -37,7 +38,7 @@ source_set("printing_export") {
sources = [ "printing_export.h" ]
}

if (use_cups_ipp && is_chromeos) {
if (use_cups_ipp && is_chromeos_ash) {
ipp_handler_map_path = "$target_gen_dir/backend/ipp_handler_map.cc"

ipp_code_generate("ipp_handlers_generate") {
Expand Down Expand Up @@ -125,7 +126,7 @@ component("printing") {
]
}

if (is_chromeos) {
if (is_chromeos_ash) {
defines += [ "PRINT_BACKEND_AVAILABLE" ]

sources += [
Expand All @@ -136,7 +137,7 @@ component("printing") {
]
}

if (is_linux) {
if (is_linux || is_chromeos_lacros) {
sources += [
"printed_document_linux.cc",
"printing_context_linux.cc",
Expand Down Expand Up @@ -239,7 +240,7 @@ component("printing") {
]
}

if (is_chromeos) {
if (is_chromeos_ash) {
deps += [ ":ipp_handlers_generate" ]

sources += [
Expand Down Expand Up @@ -272,7 +273,7 @@ component("printing") {
}
}

if (use_cups_ipp || is_chromeos) {
if (use_cups_ipp || is_chromeos_ash) {
sources += [
"printer_query_result.h",
"printer_status.cc",
Expand Down Expand Up @@ -381,7 +382,7 @@ test("printing_unittests") {
sources += [ "backend/cups_ipp_helper_unittest.cc" ]
}

if (is_chromeos) {
if (is_chromeos_ash) {
sources += [ "printing_context_chromeos_unittest.cc" ]
} else {
sources += [
Expand Down
4 changes: 2 additions & 2 deletions printing/backend/cups_ipp_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,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 BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)

constexpr char kIppDocumentAttributes[] =
"document-creation-attributes"; // PWG 5100.5
Expand All @@ -35,6 +35,6 @@ constexpr char kPinEncryptionNone[] = "none";
constexpr char kOptionFalse[] = "false";
constexpr char kOptionTrue[] = "true";

#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

} // namespace printing
4 changes: 2 additions & 2 deletions printing/backend/cups_ipp_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PRINTING_EXPORT extern const char kIppPinEncryption[];
PRINTING_EXPORT extern const char kCollated[];
PRINTING_EXPORT extern const char kUncollated[];

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)

PRINTING_EXPORT extern const char kIppDocumentAttributes[];
PRINTING_EXPORT extern const char kIppJobAttributes[];
Expand All @@ -35,7 +35,7 @@ PRINTING_EXPORT extern const char kPinEncryptionNone[];
PRINTING_EXPORT extern const char kOptionFalse[];
PRINTING_EXPORT extern const char kOptionTrue[];

#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

} // namespace printing

Expand Down
16 changes: 8 additions & 8 deletions printing/backend/cups_ipp_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
#include "printing/printing_utils.h"
#include "printing/units.h"

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_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 // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

namespace printing {

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr int kPinMinimumLength = 4;
#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

namespace {

Expand Down Expand Up @@ -256,7 +256,7 @@ bool CollateDefault(const CupsOptionProvider& printer) {
return name && !base::StringPiece(name).compare(kCollated);
}

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool PinSupported(const CupsOptionProvider& printer) {
ipp_attribute_t* attr = printer.GetSupportedOptionValues(kIppPin);
if (!attr)
Expand Down Expand Up @@ -311,7 +311,7 @@ void ExtractAdvancedCapabilities(const CupsOptionProvider& printer,
attr_count += AddAttributes(printer, kIppDocumentAttributes, options);
base::UmaHistogramCounts1000("Printing.CUPS.IppAttributesCount", attr_count);
}
#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

} // namespace

Expand All @@ -334,11 +334,11 @@ void CapsAndDefaultsFromPrinter(const CupsOptionProvider& printer,
printer_info->default_paper = DefaultPaper(printer);
printer_info->papers = SupportedPapers(printer);

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
printer_info->pin_supported = PinSupported(printer);
if (base::FeatureList::IsEnabled(printing::features::kAdvancedPpdAttributes))
ExtractAdvancedCapabilities(printer, printer_info);
#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

ExtractCopies(printer, printer_info);
ExtractColor(printer, printer_info);
Expand Down
4 changes: 2 additions & 2 deletions printing/backend/cups_ipp_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ TEST_F(PrintBackendCupsIppHelperTest, OmitPapersWithSpecialVendorIds) {
"iso b0")));
}

#if BUILDFLAG(IS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PrintBackendCupsIppHelperTest, PinSupported) {
printer_->SetSupportedOptions("job-password", MakeInteger(ipp_, 4));
printer_->SetSupportedOptions("job-password-encryption",
Expand Down Expand Up @@ -364,6 +364,6 @@ TEST_F(PrintBackendCupsIppHelperTest, AdvancedCaps) {
EXPECT_EQ(3u, caps.advanced_capabilities[5].values.size());
histograms.ExpectUniqueSample("Printing.CUPS.IppAttributesCount", 5, 1);
}
#endif // BUILDFLAG(IS_ASH)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

} // namespace printing
8 changes: 6 additions & 2 deletions printing/backend/mojom/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chromeos/ui_mode.gni")
import("//mojo/public/tools/bindings/mojom.gni")

mojom("mojom") {
Expand Down Expand Up @@ -30,11 +31,14 @@ mojom("mojom") {
]
traits_sources = [ "print_backend_mojom_traits.cc" ]
traits_headers = [ "print_backend_mojom_traits.h" ]
traits_deps = [ "//printing:printing" ]
traits_deps = [
"//build:chromeos_buildflags",
"//printing:printing",
]
},
]

if (is_chromeos) {
if (is_chromeos_ash) {
cpp_typemaps += [
{
types = [
Expand Down
17 changes: 9 additions & 8 deletions printing/backend/mojom/print_backend_mojom_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <map>

#include "base/logging.h"
#include "build/chromeos_buildflags.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"

Expand Down Expand Up @@ -38,7 +39,7 @@ struct less<::printing::PrinterSemanticCapsAndDefaults::Paper> {
}
};

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
template <>
struct less<::printing::AdvancedCapability> {
bool operator()(const ::printing::AdvancedCapability& lhs,
Expand All @@ -48,7 +49,7 @@ struct less<::printing::AdvancedCapability> {
return lhs.display_name < rhs.display_name;
}
};
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

} // namespace std

Expand Down Expand Up @@ -114,7 +115,7 @@ bool StructTraits<printing::mojom::PaperDataView,
data.ReadVendorId(&out->vendor_id) && data.ReadSizeUm(&out->size_um);
}

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// static
printing::mojom::AdvancedCapabilityType
EnumTraits<printing::mojom::AdvancedCapabilityType,
Expand Down Expand Up @@ -176,7 +177,7 @@ bool StructTraits<printing::mojom::AdvancedCapabilityDataView,
data.ReadDefaultValue(&out->default_value) &&
data.ReadValues(&out->values);
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

// static
bool StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
Expand All @@ -200,11 +201,11 @@ bool StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
return false;
}

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
out->pin_supported = data.pin_supported();
if (!data.ReadAdvancedCapabilities(&out->advanced_capabilities))
return false;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

// Extra validity checks.

Expand Down Expand Up @@ -247,15 +248,15 @@ bool StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
return false;
}

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
DuplicateChecker<printing::AdvancedCapability>
advanced_capabilities_dup_checker;
if (advanced_capabilities_dup_checker.HasDuplicates(
out->advanced_capabilities)) {
DLOG(ERROR) << "Duplicate advanced_capabilities detected.";
return false;
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

return true;
}
Expand Down
9 changes: 5 additions & 4 deletions printing/backend/mojom/print_backend_mojom_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>
#include <vector>

#include "build/chromeos_buildflags.h"
#include "printing/backend/mojom/print_backend.mojom-shared.h"
#include "printing/backend/print_backend.h"
#include "printing/mojom/print.mojom.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ struct StructTraits<printing::mojom::PaperDataView,
printing::PrinterSemanticCapsAndDefaults::Paper* out);
};

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
template <>
struct EnumTraits<printing::mojom::AdvancedCapabilityType,
::printing::AdvancedCapability::Type> {
Expand Down Expand Up @@ -114,7 +115,7 @@ struct StructTraits<printing::mojom::AdvancedCapabilityDataView,
static bool Read(printing::mojom::AdvancedCapabilityDataView data,
::printing::AdvancedCapability* out);
};
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

template <>
struct StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
Expand Down Expand Up @@ -174,15 +175,15 @@ struct StructTraits<printing::mojom::PrinterSemanticCapsAndDefaultsDataView,
return p.default_dpi;
}

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
static bool pin_supported(const printing::PrinterSemanticCapsAndDefaults& p) {
return p.pin_supported;
}
static const printing::AdvancedCapabilities& advanced_capabilities(
const printing::PrinterSemanticCapsAndDefaults& p) {
return p.advanced_capabilities;
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

static bool Read(printing::mojom::PrinterSemanticCapsAndDefaultsDataView data,
printing::PrinterSemanticCapsAndDefaults* out);
Expand Down
Loading

0 comments on commit 34c1b55

Please sign in to comment.