chromium/extensions/renderer/BUILD.gn

# 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/config/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//pdf/features.gni")

assert(enable_extensions_core)

source_set("renderer") {
  sources = [
    "activity_log_converter_strategy.cc",
    "activity_log_converter_strategy.h",
    "api/context_menus_custom_bindings.cc",
    "api/context_menus_custom_bindings.h",
    "api/core_extensions_renderer_api_provider.cc",
    "api/core_extensions_renderer_api_provider.h",
    "api/declarative_content_hooks_delegate.cc",
    "api/declarative_content_hooks_delegate.h",
    "api/dom_hooks_delegate.cc",
    "api/dom_hooks_delegate.h",
    "api/feedback_private_hooks_delegate.cc",
    "api/feedback_private_hooks_delegate.h",
    "api/file_system_natives.cc",
    "api/file_system_natives.h",
    "api/i18n_hooks_delegate.cc",
    "api/i18n_hooks_delegate.h",
    "api/messaging/gin_port.cc",
    "api/messaging/gin_port.h",
    "api/messaging/message_target.cc",
    "api/messaging/message_target.h",
    "api/messaging/messaging_bindings.cc",
    "api/messaging/messaging_bindings.h",
    "api/messaging/messaging_util.cc",
    "api/messaging/messaging_util.h",
    "api/messaging/native_renderer_messaging_service.cc",
    "api/messaging/native_renderer_messaging_service.h",
    "api/messaging/one_time_message_handler.cc",
    "api/messaging/one_time_message_handler.h",
    "api/runtime_hooks_delegate.cc",
    "api/runtime_hooks_delegate.h",
    "api/web_request_hooks.cc",
    "api/web_request_hooks.h",
    "api_activity_logger.cc",
    "api_activity_logger.h",
    "api_definitions_natives.cc",
    "api_definitions_natives.h",
    "binding_generating_native_handler.cc",
    "binding_generating_native_handler.h",
    "bindings/api_binding.cc",
    "bindings/api_binding.h",
    "bindings/api_binding_bridge.cc",
    "bindings/api_binding_bridge.h",
    "bindings/api_binding_hooks.cc",
    "bindings/api_binding_hooks.h",
    "bindings/api_binding_hooks_delegate.cc",
    "bindings/api_binding_hooks_delegate.h",
    "bindings/api_binding_js_util.cc",
    "bindings/api_binding_js_util.h",
    "bindings/api_binding_types.cc",
    "bindings/api_binding_types.h",
    "bindings/api_binding_util.cc",
    "bindings/api_binding_util.h",
    "bindings/api_bindings_system.cc",
    "bindings/api_bindings_system.h",
    "bindings/api_event_handler.cc",
    "bindings/api_event_handler.h",
    "bindings/api_event_listeners.cc",
    "bindings/api_event_listeners.h",
    "bindings/api_invocation_errors.cc",
    "bindings/api_invocation_errors.h",
    "bindings/api_last_error.cc",
    "bindings/api_last_error.h",
    "bindings/api_request_handler.cc",
    "bindings/api_request_handler.h",
    "bindings/api_response_validator.cc",
    "bindings/api_response_validator.h",
    "bindings/api_signature.cc",
    "bindings/api_signature.h",
    "bindings/api_type_reference_map.cc",
    "bindings/api_type_reference_map.h",
    "bindings/argument_spec.cc",
    "bindings/argument_spec.h",
    "bindings/binding_access_checker.cc",
    "bindings/binding_access_checker.h",
    "bindings/declarative_event.cc",
    "bindings/declarative_event.h",
    "bindings/event_emitter.cc",
    "bindings/event_emitter.h",
    "bindings/exception_handler.cc",
    "bindings/exception_handler.h",
    "bindings/interaction_provider.h",
    "bindings/js_runner.cc",
    "bindings/js_runner.h",
    "bindings/listener_tracker.cc",
    "bindings/listener_tracker.h",
    "blob_native_handler.cc",
    "blob_native_handler.h",
    "chrome_setting.cc",
    "chrome_setting.h",
    "console.cc",
    "console.h",
    "content_setting.cc",
    "content_setting.h",
    "content_watcher.cc",
    "content_watcher.h",
    "dispatcher.cc",
    "dispatcher.h",
    "dom_activity_logger.cc",
    "dom_activity_logger.h",
    "extension_frame_helper.cc",
    "extension_frame_helper.h",
    "extension_injection_host.cc",
    "extension_injection_host.h",
    "extension_interaction_provider.cc",
    "extension_interaction_provider.h",
    "extension_js_runner.cc",
    "extension_js_runner.h",
    "extension_localization_throttle.cc",
    "extension_localization_throttle.h",
    "extension_throttle_entry.cc",
    "extension_throttle_entry.h",
    "extension_throttle_manager.cc",
    "extension_throttle_manager.h",
    "extension_url_loader_throttle.cc",
    "extension_url_loader_throttle.h",
    "extension_web_view_helper.cc",
    "extension_web_view_helper.h",
    "extensions_render_frame_observer.cc",
    "extensions_render_frame_observer.h",
    "extensions_renderer_api_provider.h",
    "extensions_renderer_client.cc",
    "extensions_renderer_client.h",
    "feature_cache.cc",
    "feature_cache.h",
    "gc_callback.cc",
    "gc_callback.h",
    "get_script_context.cc",
    "get_script_context.h",
    "id_generator_custom_bindings.cc",
    "id_generator_custom_bindings.h",
    "injection_host.cc",
    "injection_host.h",
    "ipc_message_sender.cc",
    "ipc_message_sender.h",
    "isolated_world_manager.cc",
    "isolated_world_manager.h",
    "lazy_background_page_native_handler.cc",
    "lazy_background_page_native_handler.h",
    "logging_native_handler.cc",
    "logging_native_handler.h",
    "module_system.cc",
    "module_system.h",
    "native_extension_bindings_system.cc",
    "native_extension_bindings_system.h",
    "native_handler.cc",
    "native_handler.h",
    "object_backed_native_handler.cc",
    "object_backed_native_handler.h",
    "process_info_native_handler.cc",
    "process_info_native_handler.h",
    "programmatic_script_injector.cc",
    "programmatic_script_injector.h",
    "render_frame_observer_natives.cc",
    "render_frame_observer_natives.h",
    "renderer_context_data.cc",
    "renderer_context_data.h",
    "renderer_extension_registry.cc",
    "renderer_extension_registry.h",
    "renderer_frame_context_data.cc",
    "renderer_frame_context_data.h",
    "resource_bundle_source_map.cc",
    "resource_bundle_source_map.h",
    "resource_request_policy.cc",
    "resource_request_policy.h",
    "runtime_custom_bindings.cc",
    "runtime_custom_bindings.h",
    "safe_builtins.cc",
    "safe_builtins.h",
    "script_context.cc",
    "script_context.h",
    "script_context_set.cc",
    "script_context_set.h",
    "script_context_set_iterable.cc",
    "script_context_set_iterable.h",
    "script_injection.cc",
    "script_injection.h",
    "script_injection_manager.cc",
    "script_injection_manager.h",
    "script_injector.h",
    "scripts_run_info.cc",
    "scripts_run_info.h",
    "service_worker_data.cc",
    "service_worker_data.h",
    "service_worker_natives.cc",
    "service_worker_natives.h",
    "set_icon_natives.cc",
    "set_icon_natives.h",
    "shared_l10n_map.cc",
    "shared_l10n_map.h",
    "source_map.h",
    "static_v8_external_one_byte_string_resource.cc",
    "static_v8_external_one_byte_string_resource.h",
    "storage_area.cc",
    "storage_area.h",
    "test_features_native_handler.cc",
    "test_features_native_handler.h",
    "trace_util.h",
    "user_gestures_native_handler.cc",
    "user_gestures_native_handler.h",
    "user_script_injector.cc",
    "user_script_injector.h",
    "user_script_set.cc",
    "user_script_set.h",
    "user_script_set_manager.cc",
    "user_script_set_manager.h",
    "utils_native_handler.cc",
    "utils_native_handler.h",
    "v8_context_native_handler.cc",
    "v8_context_native_handler.h",
    "v8_helpers.h",
    "v8_schema_registry.cc",
    "v8_schema_registry.h",
    "web_ui_injection_host.cc",
    "web_ui_injection_host.h",
    "worker_script_context_set.cc",
    "worker_script_context_set.h",
    "worker_thread_dispatcher.cc",
    "worker_thread_dispatcher.h",
    "worker_thread_util.cc",
    "worker_thread_util.h",
  ]

  configs += [
    "//build/config:precompiled_headers",
    "//build/config/compiler:wexit_time_destructors",
  ]

  deps = [
    "//build:chromeos_buildflags",
    "//chrome:resources",
    "//components/crx_file",
    "//components/version_info",
    "//content:content_resources",
    "//content/public/renderer",
    "//extensions:extensions_resources",
    "//extensions/common",
    "//extensions/common:mojom",
    "//extensions/common/api",
    "//gin",
    "//mojo/public/js:resources",
    "//pdf:buildflags",
    "//services/accessibility/public/mojom",
    "//services/metrics/public/cpp:metrics_cpp",
    "//skia",
    "//storage/common",
    "//third_party/blink/public:blink",
    "//third_party/blink/public/common",
    "//third_party/cld_3/src/src:cld_3",
    "//third_party/zlib/google:compression_utils",
    "//ui/strings:auto_image_annotation_strings_grit",
  ]

  # TODO(https://crbug.com/356905053): The following files don't compile
  # cleanly with the experimental desktop-android build. Either make them
  # compile, or determine they should not be included and place them under a
  # more appropriate if-block.
  if (enable_extensions) {
    sources += [
      "api/automation/automation_api_converters.cc",
      "api/automation/automation_api_converters.h",
      "api/automation/automation_internal_custom_bindings.cc",
      "api/automation/automation_internal_custom_bindings.h",
    ]
  }

  if (enable_pdf) {
    deps += [
      "//components/pdf/common:util",
      "//pdf:features",
    ]
  }

  if (enable_guest_view) {
    sources += [
      "guest_view/guest_view_internal_custom_bindings.cc",
      "guest_view/guest_view_internal_custom_bindings.h",
      "guest_view/mime_handler_view/mime_handler_view_container_manager.cc",
      "guest_view/mime_handler_view/mime_handler_view_container_manager.h",
      "guest_view/mime_handler_view/mime_handler_view_frame_container.cc",
      "guest_view/mime_handler_view/mime_handler_view_frame_container.h",
      "guest_view/mime_handler_view/post_message_support.cc",
      "guest_view/mime_handler_view/post_message_support.h",
    ]

    deps += [
      "//components/guest_view/common",
      "//components/guest_view/common:mojom",
      "//components/guest_view/renderer",
    ]
  }

  if (enable_platform_apps) {
    sources += [
      "api/app_window_custom_bindings.cc",
      "api/app_window_custom_bindings.h",
    ]
  }
}

if (enable_extensions) {
  static_library("unit_test_support") {
    # Sources that are shared between chrome-based renderer unit tests and
    # top-level extensions renderer unit tests.
    testonly = true
    sources = [
      "api/messaging/mock_message_port_host.cc",
      "api/messaging/mock_message_port_host.h",
      "api/messaging/send_message_tester.cc",
      "api/messaging/send_message_tester.h",
      "bindings/api_binding_test.cc",
      "bindings/api_binding_test.h",
      "bindings/api_binding_test_util.cc",
      "bindings/api_binding_test_util.h",
      "bindings/test_interaction_provider.cc",
      "bindings/test_interaction_provider.h",
      "bindings/test_js_runner.cc",
      "bindings/test_js_runner.h",
      "native_extension_bindings_system_test_base.cc",
      "native_extension_bindings_system_test_base.h",
      "string_source_map.cc",
      "string_source_map.h",
      "test_v8_extension_configuration.cc",
      "test_v8_extension_configuration.h",
    ]

    deps = [
      ":renderer",
      "//base",
      "//base/test:test_support",
      "//components/crx_file",
      "//content/public/renderer",
      "//content/test:test_support",
      "//extensions:test_support",
      "//extensions/buildflags",
      "//extensions/common",
      "//gin",
      "//gin:gin_test",
      "//testing/gmock",
      "//testing/gtest",
      "//third_party/zlib/google:compression_utils",
    ]
  }

  source_set("unit_tests") {
    testonly = true
    sources = [
      "activity_log_converter_strategy_unittest.cc",
      "api/automation/automation_internal_custom_bindings_unittests.cc",
      "api/feedback_private_hooks_delegate_unittest.cc",
      "api/i18n_hooks_delegate_unittest.cc",
      "api/messaging/gin_port_unittest.cc",
      "api/messaging/messaging_util_unittest.cc",
      "api/messaging/native_renderer_messaging_service_unittest.cc",
      "api/messaging/one_time_message_handler_unittest.cc",
      "api/runtime_hooks_delegate_unittest.cc",
      "api_activity_logger_unittest.cc",
      "bindings/api_binding_bridge_unittest.cc",
      "bindings/api_binding_hooks_test_delegate.cc",
      "bindings/api_binding_hooks_test_delegate.h",
      "bindings/api_binding_js_util_unittest.cc",
      "bindings/api_binding_unittest.cc",
      "bindings/api_bindings_system_unittest.cc",
      "bindings/api_bindings_system_unittest.h",
      "bindings/api_event_handler_unittest.cc",
      "bindings/api_event_listeners_unittest.cc",
      "bindings/api_invocation_errors_unittest.cc",
      "bindings/api_last_error_unittest.cc",
      "bindings/api_request_handler_unittest.cc",
      "bindings/api_response_validator_unittest.cc",
      "bindings/api_signature_unittest.cc",
      "bindings/argument_spec_builder.cc",
      "bindings/argument_spec_builder.h",
      "bindings/argument_spec_unittest.cc",
      "bindings/binding_access_checker_unittest.cc",
      "bindings/declarative_event_unittest.cc",
      "bindings/event_emitter_unittest.cc",
      "bindings/exception_handler_unittest.cc",
      "bindings/listener_tracker_unittest.cc",
      "bindings/returns_async_builder.cc",
      "bindings/returns_async_builder.h",
      "extension_localization_throttle_unittest.cc",
      "extension_throttle_simulation_unittest.cc",
      "extension_throttle_test_support.cc",
      "extension_throttle_test_support.h",
      "extension_throttle_unittest.cc",
      "feature_cache_unittest.cc",
      "gc_callback_unittest.cc",
      "module_system_test.cc",
      "module_system_test.h",
      "module_system_unittest.cc",
      "native_extension_bindings_system_unittest.cc",
      "safe_builtins_unittest.cc",
      "scoped_web_frame.cc",
      "scoped_web_frame.h",
      "script_context_set_unittest.cc",
      "storage_area_unittest.cc",
      "utils_unittest.cc",
    ]

    deps = [
      ":renderer",
      ":unit_test_support",
      "//base",
      "//base/test:test_support",
      "//build:chromeos_buildflags",
      "//components/crx_file:crx_file",
      "//content/test:test_support",
      "//extensions:extensions_renderer_resources",
      "//extensions:test_support",
      "//extensions/buildflags",
      "//extensions/common",
      "//gin",
      "//gin:gin_test",
      "//ipc:test_support",
      "//services/network:test_support",
      "//testing/gmock",
      "//testing/gtest",
      "//third_party/blink/public:blink",
      "//ui/base",
    ]
  }

  source_set("browser_tests") {
    testonly = true
    sources = [ "script_context_browsertest.cc" ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    deps = [
      ":renderer",
      "//base",
      "//content/public/renderer",
      "//content/test:test_support",
      "//extensions:test_support",
      "//extensions/common",
      "//extensions/shell:app_shell_lib",
      "//extensions/shell:browser_tests",
      "//third_party/blink/public:blink",
      "//url",
    ]
  }
}