Skip to content

Commit

Permalink
LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH)
Browse files Browse the repository at this point in the history
The change is mostly mechanical replacing defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH) and GN variable is_chromeos with is_ash. Only the insertion of "//build:chromeos_buildflags" into appropriate deps in BUILD.gn is done semi-manualy. The change should not change the behaviour of any build.

This is in preparation to switching lacros build from target_os=linux to target_os=chromeos so that lacros does not include any additional code due the switch.

Please note that any new defined(OS_CHROMEOS) and is_chromeos introduced to should be consistent with the new meaning.

Please refer to this short document http://go/lacros-replace-chromeos-macro-with-ash for full context.

Bug: 1052397
Change-Id: Ic12afd68af4bb6b1eec07c66918db951eb08aab8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494281
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820531}
  • Loading branch information
Yuta Hijikata authored and Commit Bot committed Oct 24, 2020
1 parent 3ec07e8 commit 6b9c17c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 19 deletions.
8 changes: 7 additions & 1 deletion pdf/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if (enable_pdf) {
deps = [
":internal",
"//base",
"//build:chromeos_buildflags",
"//ui/gfx/geometry",
]
}
Expand Down Expand Up @@ -63,7 +64,10 @@ if (enable_pdf) {

public = [ "pdf_features.h" ]

deps = [ "//base" ]
deps = [
"//base",
"//build:chromeos_buildflags",
]
}

source_set("internal") {
Expand Down Expand Up @@ -143,6 +147,7 @@ if (enable_pdf) {
":ppapi_migration",
"//base",
"//base:i18n",
"//build:chromeos_buildflags",
"//gin",
"//net",
"//pdf/pdfium/fuzzers",
Expand Down Expand Up @@ -232,6 +237,7 @@ if (enable_pdf) {
":internal",
":ppapi_migration",
"//base",
"//build:chromeos_buildflags",
"//net",
"//ppapi/cpp:objects",
"//ppapi/cpp/private:internal_module",
Expand Down
5 changes: 3 additions & 2 deletions pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "net/base/escape.h"
#include "net/base/filename_util.h"
#include "pdf/accessibility.h"
Expand Down Expand Up @@ -1395,7 +1396,7 @@ void OutOfProcessInstance::SaveToBuffer(const std::string& token) {
message.Set(kJSDataToSave, buffer);
}
} else {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
uint32_t length = engine()->GetLoadedByteSize();
if (IsSaveDataSizeValid(length)) {
pp::VarArrayBuffer buffer(length);
Expand All @@ -1405,7 +1406,7 @@ void OutOfProcessInstance::SaveToBuffer(const std::string& token) {
}
#else
NOTREACHED();
#endif
#endif // BUILDFLAG(IS_ASH)
}

PostMessage(message);
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <utility>

#include "build/chromeos_buildflags.h"
#include "pdf/pdf_engine.h"
#include "pdf/pdf_init.h"
#include "ui/gfx/geometry/rect.h"
Expand Down Expand Up @@ -35,13 +36,13 @@ class ScopedSdkInitializer {

} // namespace

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
std::vector<uint8_t> CreateFlattenedPdf(
base::span<const uint8_t> input_buffer) {
ScopedSdkInitializer scoped_sdk_initializer(/*enable_v8=*/false);
return PDFEngineExports::Get()->CreateFlattenedPdf(input_buffer);
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

#if defined(OS_WIN)
bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/optional.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"

#if defined(OS_WIN)
#include <windows.h>
Expand All @@ -30,12 +31,12 @@ class SizeF;

namespace chrome_pdf {

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Create a flattened PDF document from an existing PDF document.
// |input_buffer| is the buffer that contains the entire PDF document to be
// flattened.
std::vector<uint8_t> CreateFlattenedPdf(base::span<const uint8_t> input_buffer);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

#if defined(OS_WIN)
// Printing modes - type to convert PDF to for printing. See PDFium's
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdf_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "pdf/document_layout.h"
#include "ppapi/c/dev/pp_cursor_type_dev.h"
#include "ppapi/c/dev/ppp_printing_dev.h"
Expand Down Expand Up @@ -534,11 +535,11 @@ class PDFEngineExports {

static PDFEngineExports* Get();

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// See the definition of CreateFlattenedPdf in pdf.cc for details.
virtual std::vector<uint8_t> CreateFlattenedPdf(
base::span<const uint8_t> input_buffer) = 0;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

#if defined(OS_WIN)
// See the definition of RenderPDFPageToDC in pdf.cc for details.
Expand Down
6 changes: 4 additions & 2 deletions pdf/pdf_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "pdf/pdf_features.h"

#include "build/chromeos_buildflags.h"

namespace chrome_pdf {
namespace features {

Expand All @@ -27,11 +29,11 @@ const base::Feature kPDFViewerUpdate = {"PDFViewerUpdate",
base::FEATURE_DISABLED_BY_DEFAULT};

const base::Feature kSaveEditedPDFForm = {"SaveEditedPDFForm",
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
};

const base::Feature kTabAcrossPDFAnnotations = {
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdfium/pdfium_engine_exports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/no_destructor.h"
#include "base/numerics/safe_conversions.h"
#include "base/optional.h"
#include "build/chromeos_buildflags.h"
#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
#include "pdf/pdfium/pdfium_print.h"
Expand Down Expand Up @@ -226,15 +227,15 @@ PDFiumEngineExports::PDFiumEngineExports() {}

PDFiumEngineExports::~PDFiumEngineExports() {}

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
std::vector<uint8_t> PDFiumEngineExports::CreateFlattenedPdf(
base::span<const uint8_t> input_buffer) {
ScopedFPDFDocument doc = LoadPdfData(input_buffer);
if (!doc)
return std::vector<uint8_t>();
return PDFiumPrint::CreateFlattenedPdf(std::move(doc));
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

#if defined(OS_WIN)
bool PDFiumEngineExports::RenderPDFPageToDC(
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdfium/pdfium_engine_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "pdf/pdf_engine.h"

namespace chrome_pdf {
Expand All @@ -21,10 +22,10 @@ class PDFiumEngineExports : public PDFEngineExports {
~PDFiumEngineExports() override;

// PDFEngineExports:
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
std::vector<uint8_t> CreateFlattenedPdf(
base::span<const uint8_t> input_buffer) override;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)
#if defined(OS_WIN)
bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
int page_number,
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdfium/pdfium_print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>

#include "base/strings/string_number_conversions.h"
#include "build/chromeos_buildflags.h"
#include "pdf/pdf_transform.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_read.h"
Expand Down Expand Up @@ -271,14 +272,14 @@ PDFiumPrint::PDFiumPrint(PDFiumEngine* engine) : engine_(engine) {}

PDFiumPrint::~PDFiumPrint() = default;

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// static
std::vector<uint8_t> PDFiumPrint::CreateFlattenedPdf(ScopedFPDFDocument doc) {
if (!FlattenPrintData(doc.get()))
return std::vector<uint8_t>();
return ConvertDocToBuffer(std::move(doc));
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

// static
std::vector<uint32_t> PDFiumPrint::GetPageNumbersFromPrintPageNumberRange(
Expand Down
5 changes: 3 additions & 2 deletions pdf/pdfium/pdfium_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h"
#include "third_party/pdfium/public/fpdfview.h"

Expand All @@ -31,12 +32,12 @@ class PDFiumPrint {
PDFiumPrint& operator=(const PDFiumPrint&) = delete;
~PDFiumPrint();

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_ASH)
// Flattens the |doc|.
// On success, returns the flattened version of |doc| as a vector.
// On failure, returns an empty vector.
static std::vector<uint8_t> CreateFlattenedPdf(ScopedFPDFDocument doc);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_ASH)

static std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange(
const PP_PrintPageNumberRange_Dev* page_ranges,
Expand Down

0 comments on commit 6b9c17c

Please sign in to comment.