# 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.
import("//build/buildflag_header.gni")
import("//build/config/features.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//services/screen_ai/buildflags/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("//third_party/pdfium/pdfium.gni")
import("//tools/grit/repack.gni")
import("//v8/gni/v8.gni")
if (is_ios) {
import("//build/config/ios/bundle_data_from_filelist.gni")
}
# Generate a buildflag header for compile-time checking of PDF support.
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"ENABLE_INK=$enable_ink",
"ENABLE_PDF_INK2=$enable_pdf_ink2",
"ENABLE_PDF=$enable_pdf",
]
}
if (enable_pdf) {
config("strict") {
configs = [ "//build/config/compiler:wexit_time_destructors" ]
}
config("pdfium_includes") {
include_dirs = [ "//third_party/pdfium" ]
}
static_library("pdf") {
sources = [ "pdf.cc" ]
configs += [ ":strict" ]
public = [ "pdf.h" ]
public_deps = []
deps = [
":features",
":internal",
"//base",
"//build:chromeos_buildflags",
"//services/screen_ai/buildflags",
"//ui/gfx/geometry",
]
if (enable_screen_ai_service) {
public_deps = [ ":pdf_progressive_searchifier" ]
}
}
source_set("features") {
sources = [ "pdf_features.cc" ]
configs += [ ":strict" ]
public = [ "pdf_features.h" ]
public_deps = [ ":buildflags" ]
deps = [
"//base",
"//build:chromeos_buildflags",
]
}
source_set("internal") {
visibility = [ ":*" ]
sources = [
"accessibility.cc",
"accessibility.h",
"document_attachment_info.cc",
"document_attachment_info.h",
"document_layout.cc",
"document_layout.h",
"document_metadata.cc",
"document_metadata.h",
"draw_utils/coordinates.cc",
"draw_utils/coordinates.h",
"draw_utils/shadow.cc",
"draw_utils/shadow.h",
"input_utils.cc",
"input_utils.h",
"metrics_handler.cc",
"metrics_handler.h",
"page_orientation.cc",
"page_orientation.h",
"paint_aggregator.cc",
"paint_aggregator.h",
"paint_manager.cc",
"paint_manager.h",
"paint_ready_rect.cc",
"paint_ready_rect.h",
"parsed_params.cc",
"parsed_params.h",
"pdf_init.cc",
"pdf_init.h",
"pdf_transform.cc",
"pdf_transform.h",
"pdf_utils/dates.cc",
"pdf_utils/dates.h",
"pdfium/pdfium_api_string_buffer_adapter.cc",
"pdfium/pdfium_api_string_buffer_adapter.h",
"pdfium/pdfium_document.cc",
"pdfium/pdfium_document.h",
"pdfium/pdfium_document_metadata.cc",
"pdfium/pdfium_document_metadata.h",
"pdfium/pdfium_engine.cc",
"pdfium/pdfium_engine.h",
"pdfium/pdfium_engine_client.h",
"pdfium/pdfium_engine_exports.cc",
"pdfium/pdfium_engine_exports.h",
"pdfium/pdfium_form_filler.cc",
"pdfium/pdfium_form_filler.h",
"pdfium/pdfium_mem_buffer_file_write.cc",
"pdfium/pdfium_mem_buffer_file_write.h",
"pdfium/pdfium_ocr.cc",
"pdfium/pdfium_ocr.h",
"pdfium/pdfium_page.cc",
"pdfium/pdfium_page.h",
"pdfium/pdfium_permissions.cc",
"pdfium/pdfium_permissions.h",
"pdfium/pdfium_print.cc",
"pdfium/pdfium_print.h",
"pdfium/pdfium_range.cc",
"pdfium/pdfium_range.h",
"pdfium/pdfium_unsupported_features.cc",
"pdfium/pdfium_unsupported_features.h",
"preview_mode_client.cc",
"preview_mode_client.h",
"ui/document_properties.cc",
"ui/document_properties.h",
"ui/file_name.cc",
"ui/file_name.h",
"ui/thumbnail.cc",
"ui/thumbnail.h",
]
public_configs = [ ":pdfium_includes" ]
configs += [ ":strict" ]
public_deps = [
"//printing/mojom",
"//skia",
"//v8",
]
deps = [
":accessibility",
":buildflags",
":content_restriction",
":features",
"//base",
"//base:i18n",
"//build:chromeos_buildflags",
"//components/strings",
"//gin",
"//pdf/loader",
"//printing",
"//services/screen_ai/buildflags",
"//third_party/blink/public:blink_headers",
"//third_party/blink/public/common:headers",
"//third_party/icu",
"//third_party/pdfium",
"//ui/base",
"//ui/base/cursor/mojom:cursor_type",
"//ui/events:events_base",
"//ui/events/blink",
"//ui/gfx/codec",
"//ui/gfx/range",
]
if (is_linux || is_chromeos) {
sources += [
"pdfium/pdfium_font_helpers.cc",
"pdfium/pdfium_font_helpers.h",
"pdfium/pdfium_font_linux.cc",
"pdfium/pdfium_font_linux.h",
]
deps += [ "//components/services/font/public/cpp" ]
}
if (is_win) {
sources += [
"pdfium/pdfium_font_helpers.cc",
"pdfium/pdfium_font_helpers.h",
"pdfium/pdfium_font_win.cc",
"pdfium/pdfium_font_win.h",
]
deps += [ "//third_party/re2" ]
}
if (is_chromeos) {
sources += [
"flatten_pdf_result.cc",
"flatten_pdf_result.h",
]
}
if (enable_pdf_ink2) {
sources += [
"draw_utils/page_boundary_intersect.cc",
"draw_utils/page_boundary_intersect.h",
"pdf_ink_brush.cc",
"pdf_ink_brush.h",
"pdf_ink_cursor.cc",
"pdf_ink_cursor.h",
"pdf_ink_module.cc",
"pdf_ink_module.h",
"pdf_ink_transform.cc",
"pdf_ink_transform.h",
"pdf_ink_undo_redo_model.cc",
"pdf_ink_undo_redo_model.h",
]
public_deps += [ "//pdf/ink" ]
}
if (enable_screen_ai_service) {
sources += [
"pdfium/pdfium_searchify.cc",
"pdfium/pdfium_searchify.h",
"pdfium/pdfium_searchify_font.cc",
"pdfium/pdfium_searchify_font.h",
]
public_deps += [ "//services/screen_ai/public/mojom" ]
deps += [ ":pdf_progressive_searchifier" ]
}
}
if (enable_screen_ai_service) {
source_set("pdf_progressive_searchifier") {
public = [ "pdf_progressive_searchifier.h" ]
public_deps = [
"//services/screen_ai/public/mojom",
"//skia",
]
}
}
source_set("assert_enums") {
visibility = [ ":*" ]
testonly = true
sources = [ "pdfium/pdfium_assert_matching_enums.cc" ]
deps = [
":accessibility",
":content_restriction",
":internal",
":pdf",
"//third_party/blink/public/common:headers",
"//third_party/pdfium",
"//ui/base",
]
}
source_set("content_restriction") {
# Exists separately to expose this header for testing.
public = [ "content_restriction.h" ]
}
source_set("accessibility") {
visibility = [
":*",
"//components:components_browsertests${exec_target_suffix}",
"//components/pdf/renderer",
"//components/pdf/renderer:unit_tests",
]
sources = [
"accessibility_helper.cc",
"accessibility_helper.h",
"accessibility_structs.cc",
"accessibility_structs.h",
"pdf_accessibility_action_handler.h",
"pdf_accessibility_data_handler.h",
"pdf_accessibility_image_fetcher.h",
]
configs += [ ":strict" ]
deps = [
"//base",
"//skia",
"//ui/gfx/geometry",
]
}
static_library("pdf_view_web_plugin") {
assert(enable_plugins, "The PDF viewer relies on plugin infrastructure")
visibility = [
":*",
"//components/pdf/renderer",
]
sources = [
"pdf_view_web_plugin.cc",
"post_message_receiver.cc",
"post_message_receiver.h",
"v8_value_converter.h",
]
configs += [ ":strict" ]
public = [ "pdf_view_web_plugin.h" ]
public_deps = [ "//pdf/mojom" ]
deps = [
":accessibility",
":buildflags",
":content_restriction",
":features",
":internal",
"//base",
"//base:i18n",
"//cc/paint",
"//gin",
"//net",
"//pdf/loader",
"//printing",
"//services/network/public/mojom:url_loader_base",
"//skia",
"//third_party/blink/public:blink_headers",
"//third_party/blink/public/common:headers",
"//ui/base/cursor",
"//ui/base/cursor/mojom:cursor_type",
"//ui/events/blink",
"//ui/gfx/range",
"//v8",
]
if (enable_pdf_ink2) {
deps += [ "//pdf/ink" ]
}
}
source_set("pdf_test_utils") {
visibility = [ "//pdf/*" ]
testonly = true
sources = [
"test/mock_web_associated_url_loader.cc",
"test/mock_web_associated_url_loader.h",
"test/mouse_event_builder.cc",
"test/mouse_event_builder.h",
"test/test_client.cc",
"test/test_client.h",
"test/test_document_loader.cc",
"test/test_document_loader.h",
"test/test_helpers.cc",
"test/test_helpers.h",
"test/test_pdfium_engine.cc",
"test/test_pdfium_engine.h",
]
deps = [
":internal",
"//base",
"//cc:test_support",
"//pdf/loader",
"//testing/gmock",
"//testing/gtest",
"//third_party/blink/public:blink",
"//ui/gfx/range",
"//ui/latency:latency",
]
}
test("pdf_unittests") {
testonly = true
sources = [
"document_layout_unittest.cc",
"draw_utils/coordinates_unittest.cc",
"input_utils_unittest.cc",
"page_orientation_unittest.cc",
"paint_manager_unittest.cc",
"parsed_params_unittest.cc",
"pdf_transform_unittest.cc",
"pdf_utils/dates_unittest.cc",
"pdf_view_web_plugin_unittest.cc",
"pdfium/accessibility_unittest.cc",
"pdfium/findtext_unittest.cc",
"pdfium/pdfium_engine_exports_unittest.cc",
"pdfium/pdfium_engine_unittest.cc",
"pdfium/pdfium_form_filler_unittest.cc",
"pdfium/pdfium_page_unittest.cc",
"pdfium/pdfium_permissions_unittest.cc",
"pdfium/pdfium_print_unittest.cc",
"pdfium/pdfium_range_unittest.cc",
"pdfium/pdfium_test_base.cc",
"pdfium/pdfium_test_base.h",
"test/run_all_unittests.cc",
"ui/document_properties_unittest.cc",
"ui/file_name_unittest.cc",
"ui/thumbnail_unittest.cc",
]
if (is_win) {
sources += [ "pdfium/pdfium_font_win_unittest.cc" ]
}
data = [ "test/data/" ]
deps = [
":accessibility",
":assert_enums",
":buildflags",
":content_restriction",
":features",
":internal",
":pdf",
":pdf_test_utils",
":pdf_view_web_plugin",
"//base",
"//base:i18n",
"//base/test:test_support",
"//cc:test_support",
"//gin",
"//mojo/core/embedder",
"//mojo/public/cpp/bindings",
"//net",
"//pdf/loader",
"//pdf/loader:unit_tests",
"//printing",
"//services/screen_ai/buildflags",
"//skia",
"//testing/gmock",
"//testing/gtest",
"//third_party/blink/public:blink",
"//third_party/blink/public:test_support",
"//third_party/blink/public/common:headers",
"//third_party/pdfium",
"//tools/v8_context_snapshot:buildflags",
"//ui/base",
"//ui/base/cursor",
"//ui/events/blink:blink",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
"//ui/gfx/range",
"//v8",
]
data_deps = [
":pdf_unittests_pak",
"//ui/resources:ui_test_pak_data",
]
assert_no_deps = [
"//ppapi/c/*",
"//ppapi/cpp/*",
]
if (enable_pdf_ink2) {
sources += [
"draw_utils/page_boundary_intersect_unittest.cc",
"pdf_ink_brush_unittest.cc",
"pdf_ink_cursor_unittest.cc",
"pdf_ink_module_unittest.cc",
"pdf_ink_transform_unittest.cc",
"pdf_ink_undo_redo_model_unittest.cc",
"test/pdf_ink_test_helpers.cc",
"test/pdf_ink_test_helpers.h",
]
}
if (enable_screen_ai_service) {
sources += [ "pdfium/pdfium_searchify_unittest.cc" ]
}
if (v8_use_external_startup_data) {
deps += [
"//tools/v8_context_snapshot",
"//tools/v8_context_snapshot:buildflags",
]
configs += [ "//v8:external_startup_data" ]
}
}
repack("pdf_unittests_pak") {
sources =
[ "$root_gen_dir/components/strings/components_strings_en-US.pak" ]
output = "$root_out_dir/pdf_tests_resources.pak"
deps = [ "//components/strings" ]
}
fuzzer_test("pdf_dates_fuzzer") {
sources = [ "pdf_utils/dates_fuzzer.cc" ]
deps = [
":internal",
"//base",
]
}
} else {
# Dummy groups when PDF support is disabled so targets can unconditionally
# depend on it.
group("features") {
}
group("pdf") {
}
}
if (is_ios) {
bundle_data_from_filelist("pdf_test_bundle_data") {
testonly = true
filelist_name = "test/pdf_test_bundle_data.filelist"
}
}