chromium/extensions/browser/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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//pdf/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

assert(enable_extensions_core)

# The overarching "build all the things" for the browser side of the
# //extensions module. In particular, this includes:
# - The core extensions system
# - The API implementations for the given platform and gn args
# - The glue to fit them together (though some of this is left to the
#   embedder).
# Typically, embedders should depend on this, rather than any of the
# subtargets.
group("browser") {
  public_deps = [
    "//extensions/browser:browser_context_keyed_service_factories",
    "//extensions/browser:browser_sources",
  ]

  public_deps += [
    # Includes all API implementations and the ExtensionsApiClient
    # interface. Moving an API from src/chrome to src/extensions implies
    # it can be cleanly disabled with enable_extensions=false.
    "//extensions/browser/api",
  ]
}

source_set("url_fetcher") {
  visibility = [ "./*" ]

  sources = [ "url_fetcher.h" ]
}

# A group of helpers to instantiate the set of all browser context keyed service
# factories, including both the API methods and core system services.
source_set("browser_context_keyed_service_factories") {
  visibility = [ ":*" ]

  sources = [
    "browser_context_keyed_service_factories.cc",
    "browser_context_keyed_service_factories.h",
  ]

  deps = [
    "//extensions/browser:core_keyed_service_factories",
    "//extensions/browser/api:api_keyed_service_factories",
  ]
}

# A helper to instantiate all the necessary core system keyed services
# factories.
source_set("core_keyed_service_factories") {
  visibility = [ ":*" ]

  sources = [
    "core_browser_context_keyed_service_factories.cc",
    "core_browser_context_keyed_service_factories.h",
  ]

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

  deps = [
    "//extensions/browser:browser_sources",
    "//extensions/browser/updater",
    "//extensions/buildflags",
  ]
}

# The set of all sources that are related to the core extensions system.
# Ideally, this would be isolated from all API targets (so that APIs are "leaf
# nodes" and could be easily toggled on-and-off through dependencies for
# different platforms).
# See also https://crbug.com/883570.
source_set("browser_sources") {
  visibility = [ "./*" ]

  sources = [
    "activity.cc",
    "activity.h",
    "allowlist_state.h",

    # TODO(crbug.com/40593486): Anything under api/ should be moved out of
    # this target.
    "api/api_resource.cc",
    "api/api_resource.h",
    "api/api_resource_manager.h",
    "api/content_settings/content_settings_service.cc",
    "api/content_settings/content_settings_service.h",
    "api/declarative/declarative_api.cc",
    "api/declarative/declarative_api.h",
    "api/declarative/declarative_rule.h",
    "api/declarative/deduping_factory.h",
    "api/declarative/rules_cache_delegate.cc",
    "api/declarative/rules_cache_delegate.h",
    "api/declarative/rules_registry.cc",
    "api/declarative/rules_registry.h",
    "api/declarative/rules_registry_service.cc",
    "api/declarative/rules_registry_service.h",
    "api/declarative_content/content_rules_registry.h",
    "api/declarative_net_request/action_tracker.cc",
    "api/declarative_net_request/action_tracker.h",
    "api/declarative_net_request/composite_matcher.cc",
    "api/declarative_net_request/composite_matcher.h",
    "api/declarative_net_request/constants.cc",
    "api/declarative_net_request/constants.h",
    "api/declarative_net_request/extension_url_pattern_index_matcher.cc",
    "api/declarative_net_request/extension_url_pattern_index_matcher.h",
    "api/declarative_net_request/file_backed_ruleset_source.cc",
    "api/declarative_net_request/file_backed_ruleset_source.h",
    "api/declarative_net_request/file_sequence_helper.cc",
    "api/declarative_net_request/file_sequence_helper.h",
    "api/declarative_net_request/flat_ruleset_indexer.cc",
    "api/declarative_net_request/flat_ruleset_indexer.h",
    "api/declarative_net_request/global_rules_tracker.cc",
    "api/declarative_net_request/global_rules_tracker.h",
    "api/declarative_net_request/indexed_rule.cc",
    "api/declarative_net_request/indexed_rule.h",
    "api/declarative_net_request/install_index_helper.cc",
    "api/declarative_net_request/install_index_helper.h",
    "api/declarative_net_request/parse_info.cc",
    "api/declarative_net_request/parse_info.h",
    "api/declarative_net_request/prefs_helper.cc",
    "api/declarative_net_request/prefs_helper.h",
    "api/declarative_net_request/regex_rules_matcher.cc",
    "api/declarative_net_request/regex_rules_matcher.h",
    "api/declarative_net_request/request_action.cc",
    "api/declarative_net_request/request_action.h",
    "api/declarative_net_request/request_params.cc",
    "api/declarative_net_request/request_params.h",
    "api/declarative_net_request/rule_counts.cc",
    "api/declarative_net_request/rule_counts.h",
    "api/declarative_net_request/rules_monitor_service.cc",
    "api/declarative_net_request/rules_monitor_service.h",
    "api/declarative_net_request/ruleset_manager.cc",
    "api/declarative_net_request/ruleset_manager.h",
    "api/declarative_net_request/ruleset_matcher.cc",
    "api/declarative_net_request/ruleset_matcher.h",
    "api/declarative_net_request/ruleset_matcher_base.cc",
    "api/declarative_net_request/ruleset_matcher_base.h",
    "api/declarative_net_request/ruleset_source.cc",
    "api/declarative_net_request/ruleset_source.h",
    "api/declarative_net_request/utils.cc",
    "api/declarative_net_request/utils.h",
    "api/declarative_webrequest/request_stage.cc",
    "api/declarative_webrequest/request_stage.h",
    "api/declarative_webrequest/webrequest_action.cc",
    "api/declarative_webrequest/webrequest_action.h",
    "api/declarative_webrequest/webrequest_condition.cc",
    "api/declarative_webrequest/webrequest_condition.h",
    "api/declarative_webrequest/webrequest_condition_attribute.cc",
    "api/declarative_webrequest/webrequest_condition_attribute.h",
    "api/declarative_webrequest/webrequest_constants.cc",
    "api/declarative_webrequest/webrequest_constants.h",
    "api/declarative_webrequest/webrequest_rules_registry.cc",
    "api/declarative_webrequest/webrequest_rules_registry.h",
    "api/execute_code_function.cc",
    "api/execute_code_function.h",
    "api/extensions_api_client.cc",
    "api/extensions_api_client.h",
    "api/system_display/display_info_provider.cc",
    "api/system_display/display_info_provider.h",
    "api/system_display/system_display_api.cc",
    "api/system_display/system_display_api.h",
    "api/web_accessible_resources/web_accessible_resources_router.cc",
    "api/web_accessible_resources/web_accessible_resources_router.h",
    "api/web_contents_capture_client.cc",
    "api/web_contents_capture_client.h",
    "api/web_request/extension_web_request_event_router.cc",
    "api/web_request/extension_web_request_event_router.h",
    "api/web_request/form_data_parser.cc",
    "api/web_request/form_data_parser.h",
    "api/web_request/permission_helper.cc",
    "api/web_request/permission_helper.h",
    "api/web_request/upload_data_presenter.cc",
    "api/web_request/upload_data_presenter.h",
    "api/web_request/web_request_api.cc",
    "api/web_request/web_request_api.h",
    "api/web_request/web_request_api_constants.cc",
    "api/web_request/web_request_api_constants.h",
    "api/web_request/web_request_api_helpers.cc",
    "api/web_request/web_request_api_helpers.h",
    "api/web_request/web_request_event_details.cc",
    "api/web_request/web_request_event_details.h",
    "api/web_request/web_request_event_router_factory.cc",
    "api/web_request/web_request_event_router_factory.h",
    "api/web_request/web_request_info.cc",
    "api/web_request/web_request_info.h",
    "api/web_request/web_request_permissions.cc",
    "api/web_request/web_request_permissions.h",
    "api/web_request/web_request_proxying_url_loader_factory.cc",
    "api/web_request/web_request_proxying_url_loader_factory.h",
    "api/web_request/web_request_proxying_websocket.cc",
    "api/web_request/web_request_proxying_websocket.h",
    "api/web_request/web_request_proxying_webtransport.cc",
    "api/web_request/web_request_proxying_webtransport.h",
    "api/web_request/web_request_resource_type.cc",
    "api/web_request/web_request_resource_type.h",
    "api/web_request/web_request_time_tracker.cc",
    "api/web_request/web_request_time_tracker.h",
    "api_activity_monitor.cc",
    "api_activity_monitor.h",
    "app_sorting.h",
    "bad_message.cc",
    "bad_message.h",
    "blob_reader.cc",
    "blob_reader.h",
    "blocked_action_type.h",
    "blocklist_extension_prefs.cc",
    "blocklist_extension_prefs.h",
    "blocklist_state.h",
    "browser_context_keyed_api_factory.h",
    "browser_frame_context_data.cc",
    "browser_frame_context_data.h",
    "browser_process_context_data.cc",
    "browser_process_context_data.h",
    "component_extension_resource_manager.h",
    "computed_hashes.cc",
    "computed_hashes.h",
    "content_hash_fetcher.cc",
    "content_hash_fetcher.h",
    "content_hash_reader.cc",
    "content_hash_reader.h",
    "content_hash_tree.cc",
    "content_hash_tree.h",
    "content_verifier/content_hash.cc",
    "content_verifier/content_hash.h",
    "content_verifier/content_verifier.cc",
    "content_verifier/content_verifier.h",
    "content_verifier/content_verifier_delegate.h",
    "content_verifier/content_verifier_io_data.cc",
    "content_verifier/content_verifier_io_data.h",
    "content_verifier/content_verifier_key.h",
    "content_verifier/content_verifier_utils.cc",
    "content_verifier/content_verifier_utils.h",
    "content_verifier/content_verify_job.cc",
    "content_verifier/content_verify_job.h",
    "content_verifier/scoped_uma_recorder.h",
    "crx_file_info.cc",
    "crx_file_info.h",
    "deferred_start_render_host.h",
    "disable_reason.h",
    "embedder_user_script_loader.cc",
    "embedder_user_script_loader.h",
    "error_map.cc",
    "error_map.h",
    "event_listener_map.cc",
    "event_listener_map.h",
    "event_page_tracker.h",
    "event_router.cc",
    "event_router.h",
    "event_router_factory.cc",
    "event_router_factory.h",
    "events/event_ack_data.cc",
    "events/event_ack_data.h",
    "events/lazy_event_dispatch_util.cc",
    "events/lazy_event_dispatch_util.h",
    "events/lazy_event_dispatcher.cc",
    "events/lazy_event_dispatcher.h",
    "extension_action.cc",
    "extension_action.h",
    "extension_action_icon_factory.cc",
    "extension_action_icon_factory.h",
    "extension_action_manager.cc",
    "extension_action_manager.h",
    "extension_api_frame_id_map.cc",
    "extension_api_frame_id_map.h",
    "extension_creator.cc",
    "extension_creator.h",
    "extension_creator_filter.cc",
    "extension_creator_filter.h",
    "extension_dialog_auto_confirm.cc",
    "extension_dialog_auto_confirm.h",
    "extension_error.cc",
    "extension_error.h",
    "extension_file_task_runner.cc",
    "extension_file_task_runner.h",
    "extension_frame_host.cc",
    "extension_frame_host.h",
    "extension_function.cc",
    "extension_function.h",
    "extension_function_constants.cc",
    "extension_function_constants.h",
    "extension_function_crash_keys.cc",
    "extension_function_crash_keys.h",
    "extension_function_dispatcher.cc",
    "extension_function_dispatcher.h",
    "extension_function_registry.cc",
    "extension_function_registry.h",
    "extension_host.cc",
    "extension_host.h",
    "extension_host_delegate.h",
    "extension_host_observer.h",
    "extension_host_queue.cc",
    "extension_host_queue.h",
    "extension_host_registry.cc",
    "extension_host_registry.h",
    "extension_icon_image.cc",
    "extension_icon_image.h",
    "extension_icon_manager.cc",
    "extension_icon_manager.h",
    "extension_icon_placeholder.cc",
    "extension_icon_placeholder.h",
    "extension_navigation_throttle.cc",
    "extension_navigation_throttle.h",
    "extension_navigation_ui_data.cc",
    "extension_navigation_ui_data.h",
    "extension_pref_store.cc",
    "extension_pref_store.h",
    "extension_pref_value_map.cc",
    "extension_pref_value_map.h",
    "extension_pref_value_map_factory.cc",
    "extension_pref_value_map_factory.h",
    "extension_prefs.cc",
    "extension_prefs.h",
    "extension_prefs_factory.cc",
    "extension_prefs_factory.h",
    "extension_prefs_helper.cc",
    "extension_prefs_helper.h",
    "extension_prefs_helper_factory.cc",
    "extension_prefs_helper_factory.h",
    "extension_prefs_observer.h",
    "extension_protocols.cc",
    "extension_protocols.h",
    "extension_registrar.cc",
    "extension_registrar.h",
    "extension_registry.cc",
    "extension_registry.h",
    "extension_registry_factory.cc",
    "extension_registry_factory.h",
    "extension_registry_observer.h",
    "extension_system.cc",
    "extension_system.h",
    "extension_system_provider.cc",
    "extension_system_provider.h",
    "extension_user_script_loader.cc",
    "extension_user_script_loader.h",
    "extension_util.cc",
    "extension_util.h",
    "extension_web_contents_observer.cc",
    "extension_web_contents_observer.h",
    "extension_zoom_request_client.cc",
    "extension_zoom_request_client.h",
    "extensions_browser_api_provider.h",
    "extensions_browser_client.cc",
    "extensions_browser_client.h",
    "extensions_browser_interface_binders.cc",
    "extensions_browser_interface_binders.h",
    "external_install_info.cc",
    "external_install_info.h",
    "external_provider_interface.h",
    "file_highlighter.cc",
    "file_highlighter.h",
    "file_reader.cc",
    "file_reader.h",
    "granted_file_entry.cc",
    "granted_file_entry.h",
    "image_loader.cc",
    "image_loader.h",
    "image_loader_factory.cc",
    "image_loader_factory.h",
    "image_sanitizer.cc",
    "image_sanitizer.h",
    "install_flag.h",
    "install_prefs_helper.cc",
    "install_prefs_helper.h",
    "install_stage.h",
    "json_file_sanitizer.cc",
    "json_file_sanitizer.h",
    "l10n_file_util.cc",
    "l10n_file_util.h",
    "lazy_background_task_queue.cc",
    "lazy_background_task_queue.h",
    "lazy_background_task_queue_factory.cc",
    "lazy_background_task_queue_factory.h",
    "lazy_context_id.cc",
    "lazy_context_id.h",
    "lazy_context_task_queue.cc",
    "lazy_context_task_queue.h",
    "load_and_localize_file.cc",
    "load_and_localize_file.h",
    "management_policy.cc",
    "management_policy.h",
    "media_capture_util.cc",
    "media_capture_util.h",
    "message_service_api.cc",
    "message_service_api.h",
    "mojo/keep_alive_impl.cc",
    "mojo/keep_alive_impl.h",
    "network_permissions_updater.cc",
    "network_permissions_updater.h",
    "null_app_sorting.cc",
    "null_app_sorting.h",
    "offscreen_document_host.cc",
    "offscreen_document_host.h",
    "path_util.cc",
    "path_util.h",
    "permissions_manager.cc",
    "permissions_manager.h",
    "policy_check.cc",
    "policy_check.h",
    "pref_names.cc",
    "pref_names.h",
    "pref_types.cc",
    "pref_types.h",
    "preload_check.cc",
    "preload_check.h",
    "preload_check_group.cc",
    "preload_check_group.h",
    "process_manager.cc",
    "process_manager.h",
    "process_manager_delegate.h",
    "process_manager_factory.cc",
    "process_manager_factory.h",
    "process_manager_observer.h",
    "process_map.cc",
    "process_map.h",
    "process_map_factory.cc",
    "process_map_factory.h",
    "process_util.cc",
    "process_util.h",
    "quota_service.cc",
    "quota_service.h",
    "renderer_startup_helper.cc",
    "renderer_startup_helper.h",
    "requirements_checker.cc",
    "requirements_checker.h",
    "ruleset_parse_result.cc",
    "ruleset_parse_result.h",
    "sandboxed_unpacker.cc",
    "sandboxed_unpacker.h",
    "script_executor.cc",
    "script_executor.h",
    "script_injection_tracker.cc",
    "script_injection_tracker.h",
    "scripting_constants.h",
    "scripting_utils.cc",
    "scripting_utils.h",
    "service_worker/service_worker_host.cc",
    "service_worker/service_worker_host.h",
    "service_worker/service_worker_keepalive.cc",
    "service_worker/service_worker_keepalive.h",
    "service_worker/service_worker_task_queue.cc",
    "service_worker/service_worker_task_queue.h",
    "service_worker/service_worker_task_queue_factory.cc",
    "service_worker/service_worker_task_queue_factory.h",
    "service_worker/worker_id.cc",
    "service_worker/worker_id.h",
    "service_worker/worker_id_set.cc",
    "service_worker/worker_id_set.h",
    "service_worker_manager.cc",
    "service_worker_manager.h",
    "site_access_requests_helper.cc",
    "site_access_requests_helper.h",
    "state_store.cc",
    "state_store.h",
    "state_store_test_observer.cc",
    "state_store_test_observer.h",
    "suggest_permission_util.cc",
    "suggest_permission_util.h",
    "supervised_user_extensions_delegate.h",
    "task_queue_util.cc",
    "task_queue_util.h",
    "ui_util.cc",
    "ui_util.h",
    "uninstall_reason.h",
    "unloaded_extension_reason.h",
    "update_observer.h",
    "url_fetcher.h",
    "url_loader_factory_manager.cc",
    "url_loader_factory_manager.h",
    "url_request_util.cc",
    "url_request_util.h",
    "user_script_loader.cc",
    "user_script_loader.h",
    "user_script_manager.cc",
    "user_script_manager.h",
    "user_script_world_configuration_manager.cc",
    "user_script_world_configuration_manager.h",
    "verified_contents.cc",
    "verified_contents.h",
    "view_type_utils.cc",
    "view_type_utils.h",
    "warning_service.cc",
    "warning_service.h",
    "warning_service_factory.cc",
    "warning_service_factory.h",
    "warning_set.cc",
    "warning_set.h",
    "zipfile_installer.cc",
    "zipfile_installer.h",
  ]

  deps = [
    "//base",
    "//base:i18n",
    "//build:chromeos_buildflags",
    "//components/back_forward_cache",
    "//components/content_settings/core/browser",
    "//components/content_settings/core/common",
    "//components/crash/core/common",
    "//components/crx_file",
    "//components/crx_file:crx_creator",
    "//components/input",
    "//components/keyed_service/content",
    "//components/keyed_service/content:content",
    "//components/keyed_service/core",
    "//components/pdf/common:constants",
    "//components/permissions",
    "//components/pref_registry",
    "//components/prefs",
    "//components/safe_browsing/core/common",
    "//components/services/unzip/content",
    "//components/services/unzip/public/cpp",
    "//components/sessions",
    "//components/supervised_user/core/common",
    "//components/supervised_user/core/common:buildflags",
    "//components/sync",
    "//components/ukm/content",
    "//components/update_client",
    "//components/url_pattern_index",
    "//components/variations",
    "//components/vector_icons",
    "//components/version_info",
    "//components/web_cache/browser",
    "//components/web_cache/browser:browser",
    "//components/zoom",
    "//content/public/browser",
    "//content/public/browser:browser",
    "//content/public/common",
    "//extensions:extensions_browser_resources",
    "//extensions/browser/api/content_settings:content_settings",
    "//extensions/browser/api/storage:settings_namespace",
    "//extensions/browser/api/storage:settings_observer",
    "//extensions/browser/api/virtual_keyboard_private:virtual_keyboard_delegate",
    "//extensions/browser/updater:keepalive",
    "//extensions/buildflags",
    "//extensions/common",
    "//extensions/common/api",
    "//extensions/strings",
    "//google_apis",
    "//net",
    "//pdf:buildflags",
    "//pdf:features",
    "//ppapi/buildflags",
    "//services/data_decoder/public/cpp:cpp",
    "//services/device/public/mojom",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/network/public/mojom",
    "//services/preferences/public/cpp",
    "//services/service_manager/public/cpp",
    "//skia",
    "//skia/public/mojom",
    "//third_party/blink/public/common",
    "//third_party/flatbuffers:flatbuffers",
    "//third_party/re2",
    "//third_party/zlib/google:zip",
    "//tools/json_schema_compiler:generated_api_util",
    "//ui/color",
    "//ui/display",
    "//url",
  ]

  public_deps = [
    "//base",
    "//components/url_matcher",
    "//components/url_pattern_index",
    "//components/value_store",
    "//content/public/common",
    "//extensions/browser/api/declarative_net_request/flat:extension_ruleset",
    "//extensions/browser/install",
    "//extensions/browser/kiosk",
    "//extensions/common:mojom",
    "//ipc",
    "//mojo/public/cpp/bindings",
    "//services/device/public/cpp/usb:usb",
    "//third_party/re2",
  ]

  # TODO(crbug.com/41323543): Ideally web_view should be a separate target on
  # which the extension system depends.
  if (enable_guest_view) {
    sources += [
      "api/guest_view/app_view/app_view_guest_internal_api.cc",
      "api/guest_view/app_view/app_view_guest_internal_api.h",
      "api/guest_view/guest_view_internal_api.cc",
      "api/guest_view/guest_view_internal_api.h",
      "api/guest_view/web_view/web_view_internal_api.cc",
      "api/guest_view/web_view/web_view_internal_api.h",
      "guest_view/app_view/app_view_constants.cc",
      "guest_view/app_view/app_view_constants.h",
      "guest_view/app_view/app_view_guest.cc",
      "guest_view/app_view/app_view_guest.h",
      "guest_view/app_view/app_view_guest_delegate.cc",
      "guest_view/app_view/app_view_guest_delegate.h",
      "guest_view/extension_options/extension_options_constants.cc",
      "guest_view/extension_options/extension_options_constants.h",
      "guest_view/extension_options/extension_options_guest.cc",
      "guest_view/extension_options/extension_options_guest.h",
      "guest_view/extension_options/extension_options_guest_delegate.cc",
      "guest_view/extension_options/extension_options_guest_delegate.h",
      "guest_view/extensions_guest_view.cc",
      "guest_view/extensions_guest_view.h",
      "guest_view/extensions_guest_view_manager_delegate.cc",
      "guest_view/extensions_guest_view_manager_delegate.h",
      "guest_view/guest_view_events.cc",
      "guest_view/guest_view_events.h",
      "guest_view/mime_handler_view/mime_handler_stream_manager.cc",
      "guest_view/mime_handler_view/mime_handler_stream_manager.h",
      "guest_view/mime_handler_view/mime_handler_view_attach_helper.cc",
      "guest_view/mime_handler_view/mime_handler_view_attach_helper.h",
      "guest_view/mime_handler_view/mime_handler_view_constants.cc",
      "guest_view/mime_handler_view/mime_handler_view_constants.h",
      "guest_view/mime_handler_view/mime_handler_view_embedder.cc",
      "guest_view/mime_handler_view/mime_handler_view_embedder.h",
      "guest_view/mime_handler_view/mime_handler_view_guest.cc",
      "guest_view/mime_handler_view/mime_handler_view_guest.h",
      "guest_view/mime_handler_view/mime_handler_view_guest_delegate.cc",
      "guest_view/mime_handler_view/mime_handler_view_guest_delegate.h",
      "guest_view/web_view/controlled_frame_embedder_url_fetcher.cc",
      "guest_view/web_view/controlled_frame_embedder_url_fetcher.h",
      "guest_view/web_view/javascript_dialog_helper.cc",
      "guest_view/web_view/javascript_dialog_helper.h",
      "guest_view/web_view/web_view_constants.cc",
      "guest_view/web_view/web_view_constants.h",
      "guest_view/web_view/web_view_content_script_manager.cc",
      "guest_view/web_view/web_view_content_script_manager.h",
      "guest_view/web_view/web_view_find_helper.cc",
      "guest_view/web_view/web_view_find_helper.h",
      "guest_view/web_view/web_view_guest.cc",
      "guest_view/web_view/web_view_guest.h",
      "guest_view/web_view/web_view_guest_delegate.h",
      "guest_view/web_view/web_view_permission_helper.cc",
      "guest_view/web_view/web_view_permission_helper.h",
      "guest_view/web_view/web_view_permission_helper_delegate.cc",
      "guest_view/web_view/web_view_permission_helper_delegate.h",
      "guest_view/web_view/web_view_permission_types.h",
      "guest_view/web_view/web_view_renderer_state.cc",
      "guest_view/web_view/web_view_renderer_state.h",
    ]

    deps += [
      "//components/guest_view/browser",
      "//extensions/browser/guest_view/web_view/web_ui",
    ]
  }

  # TODO(https://crbug.com/41407868): Platform Apps code should not be
  # included in //extensions code. But, at least this isolates them. Move
  # more platform app-specific code into this (and related) blocks.
  if (enable_platform_apps) {
    sources += [
      "app_window/app_delegate.h",
      "app_window/app_web_contents_helper.cc",
      "app_window/app_web_contents_helper.h",
      "app_window/app_window.cc",
      "app_window/app_window.h",
      "app_window/app_window_client.cc",
      "app_window/app_window_client.h",
      "app_window/app_window_contents.cc",
      "app_window/app_window_contents.h",
      "app_window/app_window_geometry_cache.cc",
      "app_window/app_window_geometry_cache.h",
      "app_window/app_window_registry.cc",
      "app_window/app_window_registry.h",
      "app_window/native_app_window.h",
      "app_window/size_constraints.cc",
      "app_window/size_constraints.h",
    ]

    deps += [ "//components/web_modal" ]
  }

  # TODO(https://crbug.com/356905053): The following files don't compile cleanly
  # with desktop-android. 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/device_permissions_manager.cc",
      "api/device_permissions_manager.h",
      "api/device_permissions_prompt.cc",
      "api/device_permissions_prompt.h",
      "api/hid/hid_api.cc",
      "api/hid/hid_api.h",
      "api/hid/hid_connection_resource.cc",
      "api/hid/hid_connection_resource.h",
      "api/hid/hid_device_manager.cc",
      "api/hid/hid_device_manager.h",
      "api/usb/usb_api.cc",
      "api/usb/usb_api.h",
      "api/usb/usb_device_manager.cc",
      "api/usb/usb_device_manager.h",
      "api/usb/usb_device_resource.cc",
      "api/usb/usb_device_resource.h",
    ]

    deps += [ "//services/device/public/cpp/hid" ]
  }

  if (is_mac) {
    # For LSCopyDisplayNameForURL, path_util.cc.
    frameworks = [ "CoreServices.framework" ]
  }

  if (is_chromeos_ash) {
    deps += [
      "//chrome/browser/ash/crosapi:browser_util",
      "//chromeos/ash/components/login/login_state",
    ]
  }

  if (is_chromeos) {
    sources += [
      "api/clipboard/clipboard_api.cc",
      "api/clipboard/clipboard_api.h",
    ]
    deps += [
      "//chromeos/constants",
      "//chromeos/dbus/permission_broker",
      "//components/prefs:prefs",
      "//ui/base/clipboard",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/crosapi/mojom",
      "//chromeos/startup",
    ]
  }

  if (enable_pdf) {
    deps += [ "//components/resources:components_resources_grit" ]
  }

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

source_set("test_support") {
  testonly = true
  sources = [
    "api/declarative_net_request/test_utils.cc",
    "api/declarative_net_request/test_utils.h",
    "api/idle/test_idle_provider.cc",
    "api/idle/test_idle_provider.h",
    "api/sockets_udp/test_udp_echo_server.cc",
    "api/sockets_udp/test_udp_echo_server.h",
    "background_script_executor.cc",
    "background_script_executor.h",
    "browsertest_util.cc",
    "browsertest_util.h",
    "extension_host_test_helper.cc",
    "extension_host_test_helper.h",
    "mock_display_info_provider.cc",
    "mock_display_info_provider.h",
    "mock_screen.cc",
    "mock_screen.h",
    "preload_check_test_util.cc",
    "preload_check_test_util.h",
    "script_result_queue.cc",
    "script_result_queue.h",
    "service_worker/service_worker_test_utils.cc",
    "service_worker/service_worker_test_utils.h",
    "test_event_router_observer.cc",
    "test_event_router_observer.h",
    "test_extension_console_observer.cc",
    "test_extension_console_observer.h",
    "updater/extension_cache_fake.cc",
    "updater/extension_cache_fake.h",
    "updater/extension_downloader_test_helper.cc",
    "updater/extension_downloader_test_helper.h",
  ]

  deps = [
    "//base",
    "//base/test:test_support",
    "//components/value_store:test_support",
    "//content/public/browser",
    "//content/test:test_support",
    "//extensions/browser",
    "//extensions/browser/updater:updater",
    "//extensions/common",
    "//extensions/common:test_support",
    "//extensions/common/api:api",
    "//net/traffic_annotation:test_support",
    "//services/data_decoder/public/cpp:test_support",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/base/idle:idle",
  ]

  if (is_chromeos_ash) {
    sources += [
      "api/feedback_private/mock_feedback_service.cc",
      "api/feedback_private/mock_feedback_service.h",
    ]
    deps += [
      "//components/crash/core/app:app",
      "//net:test_support",
    ]
  }
}

# TODO(https://crbug.com/356905053): Gradually include more of these sources
# in the desktop-android build.
if (enable_extensions) {
  # The set of all browsertests for anything defined under the
  # //extensions/browser module. Note that, unlike the production build targets
  # above, this is a monolithic target that includes all tests for both the core
  # system and relevant APIs.
  source_set("browser_tests") {
    testonly = true
    sources = [
      # TODO(michaelpg): bluetooth_appshell_test.cc is a crutch until we have a
      # better system for testing APIs in both app_shell and chrome. See
      # crbug.com/650835.
      "api/bluetooth/bluetooth_appshell_test.cc",
      "api/bluetooth_socket/bluetooth_socket_apitest.cc",
      "api/dns/dns_apitest.cc",
      "api/feedback_private/feedback_private_apitest.cc",
      "api/hid/hid_apitest.cc",
      "api/socket/socket_apitest.cc",
      "api/sockets_tcp/sockets_tcp_apitest.cc",
      "api/sockets_tcp_server/sockets_tcp_server_apitest.cc",
      "api/sockets_udp/sockets_udp_apitest.cc",
      "api/system_display/system_display_apitest.cc",
      "api/system_network/system_network_apitest.cc",
      "api/system_storage/storage_api_test_util.cc",
      "api/system_storage/storage_api_test_util.h",
      "api/system_storage/system_storage_apitest.cc",
      "api/system_storage/system_storage_eject_apitest.cc",
      "api/usb/usb_apitest.cc",
      "browsertest_util_browsertest.cc",
      "content_script_matching_browsertest.cc",
      "extension_frame_host_browsertest.cc",
      "guest_view/app_view/app_view_apitest.cc",
      "guest_view/web_view/web_view_apitest.cc",
      "guest_view/web_view/web_view_apitest.h",
      "guest_view/web_view/web_view_media_access_apitest.cc",
    ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    deps = [
      ":browser",
      "//base",
      "//build:chromeos_buildflags",
      "//components/guest_view/browser:test_support",
      "//components/storage_monitor:test_support",
      "//device/bluetooth:mocks",
      "//extensions:test_support",
      "//extensions/browser:test_support",
      "//extensions/common",
      "//extensions/common/api",
      "//extensions/shell:app_shell_lib",
      "//extensions/shell:browser_tests",
      "//net:test_support",
      "//services/device/public/cpp:test_support",
      "//services/device/public/mojom",
      "//services/network:test_support",
      "//services/service_manager/public/cpp",
      "//ui/display:test_support",
    ]

    public_deps = [ "//content/test:test_support" ]

    if (is_chromeos_ash) {
      sources += [
        "api/audio/audio_apitest_chromeos.cc",
        "api/cec_private/cec_private_ash_apitest.cc",
        "api/media_perception_private/media_perception_private_apitest.cc",
        "api/virtual_keyboard/virtual_keyboard_apitest.cc",
      ]

      deps += [
        "//chromeos/ash/components/audio",
        "//chromeos/ash/components/dbus:test_support",
        "//chromeos/ash/components/dbus/audio",
        "//chromeos/ash/components/dbus/cec_service",
        "//chromeos/ash/components/dbus/media_analytics",
        "//chromeos/ash/components/dbus/media_analytics:media_perception_proto",
        "//chromeos/ash/components/dbus/upstart",
        "//chromeos/ash/components/login/login_state",
        "//chromeos/ash/components/network",
        "//chromeos/dbus/permission_broker",
        "//chromeos/dbus/power",
        "//chromeos/dbus/power:power_manager_proto",
        "//components/crash/content/browser/error_reporting:mock_crash_endpoint",
        "//extensions/common:mojom",
      ]
    }

    if (is_chromeos_lacros) {
      sources += [ "api/cec_private/cec_private_lacros_apitest.cc" ]
      deps += [
        "//chromeos/crosapi/mojom",
        "//chromeos/lacros",
      ]
    }
  }

  # The set of sources that are needed for both browser and unit tests.
  # The set of all unittests for anything defined under the //extensions/browser
  # module. Note that, unlike the production build targets above, this is a
  # monolithic target that includes all tests for both the core system and
  # relevant APIs.
  source_set("unit_tests") {
    testonly = true
    sources = [
      "api/alarms/alarms_api_unittest.cc",
      "api/api_resource_manager_unittest.cc",
      "api/bluetooth/bluetooth_event_router_unittest.cc",
      "api/bluetooth_socket/bluetooth_socket_api_unittest.cc",
      "api/content_settings/content_settings_store_unittest.cc",
      "api/content_settings/content_settings_unittest.cc",
      "api/declarative/declarative_rule_unittest.cc",
      "api/declarative/deduping_factory_unittest.cc",
      "api/declarative/rules_registry_unittest.cc",
      "api/declarative_net_request/composite_matcher_unittest.cc",
      "api/declarative_net_request/file_sequence_helper_unittest.cc",
      "api/declarative_net_request/flat_ruleset_indexer_unittest.cc",
      "api/declarative_net_request/indexed_rule_unittest.cc",
      "api/declarative_net_request/indexed_ruleset_format_version_unittest.cc",
      "api/declarative_net_request/prefs_helper_unittest.cc",
      "api/declarative_net_request/ruleset_matcher_unittest.cc",
      "api/declarative_webrequest/webrequest_condition_attribute_unittest.cc",
      "api/declarative_webrequest/webrequest_condition_unittest.cc",
      "api/feedback_private/feedback_service_unittest.cc",
      "api/file_handlers/app_file_handler_util_unittest.cc",
      "api/file_handlers/directory_util_unittest.cc",
      "api/file_handlers/mime_util_unittest.cc",
      "api/idle/idle_api_unittest.cc",
      "api/mime_handler_private/mime_handler_private_unittest.cc",
      "api/power/power_api_unittest.cc",
      "api/runtime/restart_after_delay_api_unittest.cc",
      "api/socket/mojo_data_pump_unittest.cc",
      "api/sockets_tcp/sockets_tcp_api_unittest.cc",
      "api/sockets_udp/sockets_udp_api_unittest.cc",
      "api/storage/session_storage_manager_unittest.cc",
      "api/storage/settings_quota_unittest.cc",
      "api/storage/storage_api_unittest.cc",
      "api/storage/storage_frontend_unittest.cc",
      "api/system_info/system_info_api_unittest.cc",
      "api/system_network/system_network_api_unittest.cc",
      "api/web_request/form_data_parser_unittest.cc",
      "api/web_request/upload_data_presenter_unittest.cc",
      "api/web_request/web_request_info_unittest.cc",
      "api/web_request/web_request_permissions_unittest.cc",
      "api/web_request/web_request_time_tracker_unittest.cc",
      "app_window/app_window_geometry_cache_unittest.cc",
      "browser_frame_context_data_unittest.cc",
      "computed_hashes_unittest.cc",
      "content_hash_fetcher_unittest.cc",
      "content_hash_tree_unittest.cc",
      "content_verifier/content_hash_unittest.cc",
      "content_verifier/content_verifier_unittest.cc",
      "content_verifier/content_verify_job_unittest.cc",
      "error_map_unittest.cc",
      "event_listener_map_unittest.cc",
      "event_router_unittest.cc",
      "extension_action_manager_unittest.cc",
      "extension_action_unittest.cc",
      "extension_creator_filter_unittest.cc",
      "extension_creator_unittest.cc",
      "extension_event_histogram_value_unittest.cc",
      "extension_function_crash_keys_unittest.cc",
      "extension_function_histogram_value_unittest.cc",
      "extension_icon_image_unittest.cc",
      "extension_icon_manager_unittest.cc",
      "extension_pref_value_map_unittest.cc",
      "extension_registrar_unittest.cc",
      "extension_registry_unittest.cc",
      "extension_util_unittest.cc",
      "file_highlighter_unittest.cc",
      "file_reader_unittest.cc",
      "image_loader_unittest.cc",
      "image_sanitizer_unittest.cc",
      "json_file_sanitizer_unittest.cc",
      "lazy_background_task_queue_unittest.cc",
      "management_policy_unittest.cc",
      "mojo/keep_alive_impl_unittest.cc",
      "path_util_unittest.cc",
      "permissions_manager_unittest.cc",
      "policy_check_unittest.cc",
      "preload_check_group_unittest.cc",
      "process_manager_unittest.cc",
      "process_map_unittest.cc",
      "quota_service_unittest.cc",
      "renderer_startup_helper_unittest.cc",
      "requirements_checker_unittest.cc",
      "sandboxed_unpacker_unittest.cc",
      "service_worker/worker_id_set_unittest.cc",
      "updater/extension_downloader_unittest.cc",
      "updater/extension_installer_unittest.cc",
      "updater/safe_manifest_parser_unittest.cc",
      "updater/update_data_provider_unittest.cc",
      "updater/update_service_unittest.cc",
      "verified_contents_unittest.cc",
      "warning_service_unittest.cc",
    ]

    deps = [
      ":browser",
      ":test_support",
      "//base",
      "//base/test:test_support",
      "//build:chromeos_buildflags",
      "//components/content_settings/core/test:test_support",
      "//components/crx_file",
      "//components/feedback",
      "//components/file_access:test_support",
      "//components/keyed_service/content",
      "//components/onc",
      "//components/permissions:permissions_common",
      "//components/pref_registry:pref_registry",
      "//components/prefs:test_support",
      "//components/safe_browsing/core/common",
      "//components/safe_browsing/core/common/hashprefix_realtime:hash_realtime_utils",
      "//components/services/unzip:in_process",
      "//components/services/unzip/content",
      "//components/storage_monitor:test_support",
      "//components/sync_preferences:test_support",
      "//components/update_client",
      "//components/url_matcher",
      "//components/user_prefs",
      "//components/value_store:test_support",
      "//components/version_info",
      "//content/test:test_support",
      "//device/bluetooth:mocks",
      "//extensions:extensions_browser_resources",
      "//extensions:test_support",
      "//extensions/browser/api/content_settings:content_settings",
      "//extensions/browser/api/declarative_net_request/filter_list_converter:unit_tests",
      "//extensions/browser/api/storage:settings_namespace",
      "//extensions/browser/updater:updater",
      "//extensions/buildflags",
      "//extensions/common",
      "//extensions/common:mojom",
      "//extensions/common:test_support",
      "//extensions/common/api",
      "//extensions/shell:app_shell_lib",
      "//extensions/strings",
      "//ipc:test_support",
      "//net:test_support",
      "//services/data_decoder/public/cpp:test_support",
      "//services/device/public/mojom",
      "//services/network:test_support",
      "//services/network/public/cpp",
      "//services/service_manager/public/cpp/test:test_support",
      "//storage/browser:test_support",
      "//third_party/leveldatabase",
      "//third_party/zlib/google:zip",
      "//ui/display:test_support",
    ]

    if (is_chromeos) {
      deps += [
        "//chromeos/constants",
        "//chromeos/crosapi/mojom",
      ]
    }

    if (is_chromeos_ash) {
      sources += [
        "api/audio/audio_device_id_calculator_unittest.cc",
        "api/audio/audio_service_utils_unittest.cc",
        "api/feedback_private/access_rate_limiter_chromeos_unittest.cc",
        "api/feedback_private/feedback_private_api_chromeos_unittest.cc",
        "api/feedback_private/feedback_private_api_unittest_base_chromeos.cc",
        "api/feedback_private/feedback_private_api_unittest_base_chromeos.h",
        "api/feedback_private/log_source_access_manager_chromeos_unittest.cc",
        "api/lock_screen_data/data_item_unittest.cc",
        "api/lock_screen_data/lock_screen_item_storage_unittest.cc",
        "api/lock_screen_data/lock_screen_value_store_migrator_impl_unittest.cc",
        "api/media_perception_private/conversion_utils_unittest.cc",
        "api/media_perception_private/media_perception_api_manager_unittest.cc",
        "api/networking_private/networking_private_chromeos_unittest.cc",
        "api/virtual_keyboard_private/virtual_keyboard_private_api_unittest.cc",
        "api/webcam_private/visca_webcam_unittest.cc",
      ]

      deps += [
        "//ash/constants",
        "//chrome/browser/ash/crosapi:browser_util",
        "//chrome/common:constants",
        "//chromeos:test_support",
        "//chromeos/ash/components/dbus:test_support",
        "//chromeos/ash/components/dbus/audio",
        "//chromeos/ash/components/dbus/debug_daemon",
        "//chromeos/ash/components/dbus/media_analytics",
        "//chromeos/ash/components/dbus/media_analytics:media_perception_proto",
        "//chromeos/ash/components/dbus/shill",
        "//chromeos/ash/components/dbus/upstart",
        "//chromeos/ash/components/login/login_state",
        "//chromeos/ash/components/network:test_support",
        "//chromeos/ash/components/standalone_browser",
        "//chromeos/ash/components/standalone_browser:test_support",
        "//chromeos/dbus/permission_broker",
        "//chromeos/dbus/power",
        "//components/account_id",
        "//components/feedback",
        "//components/prefs:prefs",
        "//components/user_manager",
        "//components/user_manager:test_support",
        "//extensions/shell:app_shell_lib",
      ]
    }

    if (is_chromeos_lacros) {
      deps += [ "//chromeos/startup" ]
    }

    data = [
      "//extensions/browser/extension_event_histogram_value.h",
      "//extensions/browser/extension_function_histogram_value.h",
      "//tools/metrics/histograms/metadata/extensions/enums.xml",
      "//extensions/browser/api/declarative_net_request/flat/extension_ruleset.fbs",
    ]
  }

  fuzzer_test("extension_file_highlighter_fuzzer") {
    sources = [ "file_highlighter_fuzzer.cc" ]
    deps = [
      ":browser",
      "//base",
    ]
  }

  fuzzer_test("extension_web_request_form_data_parser_fuzzer") {
    sources = [ "api/web_request/form_data_parser_fuzzer.cc" ]
    deps = [
      ":browser",
      "//base",
      "//net",
    ]
  }

  fuzzer_test("extension_declarative_net_request_indexed_rule_fuzzer") {
    sources = [ "api/declarative_net_request/indexed_rule_fuzzer.cc" ]
    deps = [
      ":browser",
      "//base",
      "//extensions/common",
      "//extensions/common/api",
      "//third_party/abseil-cpp:absl",
      "//url",
    ]

    # The fuzzed code needs more RAM that the default limit.
    libfuzzer_options = [ "rss_limit_mb=4096" ]
  }
}