chromium/chrome/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/buildflags_paint_preview.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//chrome/common/features.gni")
import("//components/nacl/features.gni")
import("//components/offline_pages/buildflags/features.gni")
import("//components/signin/features.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/grit_rule.gni")

assert(enable_supervised_users)

grit("resources") {
  source = "resources/renderer_resources.grd"
  defines = chrome_grit_defines
  output_dir = "$root_gen_dir/chrome"
  output_name = "renderer_resources"
  outputs = [
    "grit/renderer_resources.h",
    "renderer_resources_100_percent.pak",
    "renderer_resources_200_percent.pak",
    "renderer_resources_300_percent.pak",
  ]
  grit_flags = [
    "-E",
    "mojom_root=" + rebase_path(root_gen_dir, root_build_dir),
  ]
  deps = [
    "//services/network/public/mojom:mojom_js",
    "//url/mojom:url_mojom_gurl_js",
    "//url/mojom:url_mojom_origin_js",
  ]
  if (is_chromeos) {
    deps += [ "//chromeos/components/remote_apps/mojom:mojom_js" ]
  }
  if (is_chromeos_ash) {
    deps += [
      # The JS binding files of seal.mojom will be imported to Google3 via
      # copybara.
      "//chrome/browser/ui/webui/ash/emoji:seal_mojom_js",
      "//chrome/browser/ui/webui/ash/lobster:lobster_mojom_js",
      "//chromeos/ash/components/enhanced_network_tts/mojom:mojom_js",
      "//chromeos/ash/services/ime/public/mojom:mojom_js",
      "//chromeos/ash/services/orca/public/mojom:mojom_js",
      "//chromeos/services/tts/public/mojom:mojom_js",
    ]
  }
}

static_library("process_state") {
  sources = [
    "process_state.cc",
    "process_state.h",
  ]
}

static_library("renderer") {
  sources = [
    "benchmarking_extension.cc",
    "benchmarking_extension.h",
    "browser_exposed_renderer_interfaces.cc",
    "browser_exposed_renderer_interfaces.h",
    "cart/commerce_hint_agent.cc",
    "cart/commerce_hint_agent.h",
    "chrome_content_renderer_client.cc",
    "chrome_content_renderer_client.h",
    "chrome_content_settings_agent_delegate.cc",
    "chrome_content_settings_agent_delegate.h",
    "chrome_render_frame_observer.cc",
    "chrome_render_frame_observer.h",
    "chrome_render_thread_observer.cc",
    "chrome_render_thread_observer.h",
    "custom_menu_commands.h",
    "google_accounts_private_api_extension.cc",
    "google_accounts_private_api_extension.h",
    "google_accounts_private_api_util.cc",
    "google_accounts_private_api_util.h",
    "instant_restricted_id_cache.h",
    "loadtimes_extension_bindings.cc",
    "loadtimes_extension_bindings.h",
    "media/flash_embed_rewrite.cc",
    "media/flash_embed_rewrite.h",
    "media/media_feeds.cc",
    "media/media_feeds.h",
    "media/webrtc_logging_agent_impl.cc",
    "media/webrtc_logging_agent_impl.h",
    "net/net_error_helper.cc",
    "net/net_error_helper.h",
    "net/net_error_helper_core.cc",
    "net/net_error_helper_core.h",
    "net/net_error_page_controller.cc",
    "net/net_error_page_controller.h",
    "net_benchmarking_extension.cc",
    "net_benchmarking_extension.h",
    "plugins/non_loadable_plugin_placeholder.cc",
    "plugins/non_loadable_plugin_placeholder.h",
    "plugins/pdf_plugin_placeholder.cc",
    "plugins/pdf_plugin_placeholder.h",
    "supervised_user/supervised_user_error_page_controller.cc",
    "supervised_user/supervised_user_error_page_controller.h",
    "supervised_user/supervised_user_error_page_controller_delegate.h",
    "supervised_user/supervised_user_error_page_controller_delegate_impl.cc",
    "supervised_user/supervised_user_error_page_controller_delegate_impl.h",
    "trusted_vault_encryption_keys_extension.cc",
    "trusted_vault_encryption_keys_extension.h",
    "url_loader_throttle_provider_impl.cc",
    "url_loader_throttle_provider_impl.h",
    "v8_unwinder.cc",
    "v8_unwinder.h",
    "web_link_preview_triggerer_impl.cc",
    "web_link_preview_triggerer_impl.h",
    "websocket_handshake_throttle_provider_impl.cc",
    "websocket_handshake_throttle_provider_impl.h",
    "worker_content_settings_client.cc",
    "worker_content_settings_client.h",
  ]

  defines = []

  public_deps = [
    "//components/contextual_search:buildflags",
    "//components/signin/public/base:signin_buildflags",
  ]

  deps = [
    ":process_state",
    "//base/allocator:buildflags",
    "//build:chromeos_buildflags",
    "//chrome:resources",
    "//chrome:strings",
    "//chrome/common",
    "//chrome/common:mojo_bindings",
    "//chrome/common/cart:mojo_bindings",
    "//chrome/common/net",
    "//chrome/common/search:mojo_bindings",
    "//chrome/renderer/companion/visual_query",
    "//chrome/services/speech/buildflags",
    "//components/autofill/content/renderer",
    "//components/autofill/core/common:features",
    "//components/base32",
    "//components/cdm/renderer",
    "//components/commerce/content/renderer",
    "//components/commerce/core:commerce_heuristics_data",
    "//components/commerce/core:feature_list",
    "//components/commerce/core:heuristics_provider",
    "//components/content_capture/common",
    "//components/content_capture/renderer",
    "//components/content_settings/common:mojom",
    "//components/content_settings/renderer",
    "//components/continuous_search/renderer",
    "//components/country_codes",
    "//components/dom_distiller/content/renderer",
    "//components/facilitated_payments/content/renderer",
    "//components/facilitated_payments/core/features",
    "//components/feed:feature_list",
    "//components/feed/content/renderer:feed_renderer",
    "//components/google/core/common",
    "//components/heap_profiling/in_process",
    "//components/history_clusters/core",
    "//components/language/core/common",
    "//components/lens",
    "//components/lens:lens_mojo",
    "//components/metrics:child_call_stack_profile_builder",
    "//components/network_hints/renderer",
    "//components/no_state_prefetch/common",
    "//components/no_state_prefetch/renderer",
    "//components/omnibox/common",
    "//components/optimization_guide/content/renderer",
    "//components/optimization_guide/core:features",
    "//components/page_content_annotations/core:features",
    "//components/page_image_annotation/content/renderer",
    "//components/page_load_metrics/renderer",
    "//components/paint_preview/buildflags",
    "//components/password_manager/core/common",
    "//components/pdf/common:constants",
    "//components/pdf/common:util",
    "//components/permissions:permissions_common",
    "//components/plugins/renderer",
    "//components/resources:components_resources",
    "//components/resources:components_scaled_resources",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/content/common:interfaces",
    "//components/safe_browsing/content/renderer",
    "//components/safe_browsing/content/renderer:throttles",
    "//components/safe_browsing/core/common",
    "//components/safe_browsing/core/common:interfaces",
    "//components/search:search",
    "//components/security_interstitials/content/renderer:security_interstitial_page_controller",
    "//components/security_interstitials/core:",
    "//components/security_interstitials/core/common/mojom:",
    "//components/spellcheck:buildflags",
    "//components/subresource_filter/content/renderer",
    "//components/subresource_filter/core/common",
    "//components/supervised_user/core/common:buildflags",
    "//components/translate/content/renderer",
    "//components/translate/core/common",
    "//components/translate/core/language_detection",
    "//components/visitedlink/renderer",
    "//components/web_cache/renderer",
    "//components/webapps/renderer",
    "//content/public/child",
    "//content/public/common",
    "//content/public/renderer",
    "//extensions/buildflags",
    "//gin",
    "//media",
    "//media:media_buildflags",
    "//media/capture",
    "//media/mojo/common",
    "//mojo/public/cpp/bindings",
    "//net",
    "//pdf:buildflags",
    "//ppapi/buildflags",
    "//printing/buildflags",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/metrics/public/mojom",
    "//services/service_manager/public/cpp",
    "//skia",
    "//storage/common",
    "//third_party/blink/public:blink",
    "//third_party/blink/public:resources",
    "//third_party/blink/public:scaled_resources",
    "//third_party/blink/public/strings",
    "//third_party/icu",
    "//third_party/libwebp",
    "//third_party/re2",
    "//third_party/widevine/cdm:buildflags",
    "//ui/gfx/geometry:geometry",
    "//ui/surface",
    "//v8",
  ]

  data_deps = [ "//tools/v8_context_snapshot" ]

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

  if (enable_bound_session_credentials) {
    sources += [
      "bound_session_credentials/bound_session_request_throttled_handler_renderer_impl.cc",
      "bound_session_credentials/bound_session_request_throttled_handler_renderer_impl.h",
      "bound_session_credentials/bound_session_request_throttled_in_renderer_manager.cc",
      "bound_session_credentials/bound_session_request_throttled_in_renderer_manager.h",
    ]
  }

  if (enable_nacl) {
    deps += [ "//components/nacl/renderer" ]

    # TODO(https://crbug.com/1299021): This dependency might be redundant
    # given that we were able to disable it, apparently without negative
    # consequences, for the ARM32-NaCl-on-ARM64 case.
    if (target_cpu != "arm64") {
      deps += [ "//components/nacl/loader" ]
    }
  }

  if (enable_plugins) {
    sources += [
      "plugins/chrome_plugin_placeholder.cc",
      "plugins/chrome_plugin_placeholder.h",
    ]
    deps += [ "//components/strings" ]
  }

  if (enable_ppapi) {
    sources += [
      "pepper/chrome_renderer_pepper_host_factory.cc",
      "pepper/chrome_renderer_pepper_host_factory.h",
      "pepper/pepper_helper.cc",
      "pepper/pepper_helper.h",
      "pepper/pepper_shared_memory_message_filter.cc",
      "pepper/pepper_shared_memory_message_filter.h",
      "pepper/pepper_uma_host.cc",
      "pepper/pepper_uma_host.h",
    ]
    deps += [
      "//media:media_buildflags",
      "//ppapi/host",
      "//ppapi/proxy",
      "//ppapi/proxy:ipc",
      "//ppapi/shared_impl",
    ]

    if (is_linux || is_chromeos) {
      deps += [ "//components/services/font/public/cpp" ]
    }
  }

  if (enable_pdf) {
    sources += [
      "pdf/chrome_pdf_internal_plugin_delegate.cc",
      "pdf/chrome_pdf_internal_plugin_delegate.h",
    ]

    deps += [
      "//components/pdf/renderer",
      "//pdf:features",
    ]
  }

  if (enable_widevine_cdm_component) {
    deps += [ "//third_party/widevine/cdm:headers" ]
  }

  if (enable_library_cdms || is_win || is_android) {
    sources += [
      "media/chrome_key_systems.cc",
      "media/chrome_key_systems.h",
    ]
  }

  if (safe_browsing_mode != 0) {
    deps +=
        [ "//components/safe_browsing/content/renderer/phishing_classifier" ]
  }

  if (enable_extensions_core) {
    deps += [
      "//chrome/renderer/extensions",
      "//extensions/renderer",
    ]
  }

  if (enable_extensions) {
    deps += [ "//chrome/renderer/controlled_frame" ]
  }

  if (enable_spellcheck) {
    deps += [ "//components/spellcheck/renderer:renderer" ]
  }

  if (enable_printing) {
    deps += [
      "//components/printing/renderer",
      "//printing",
    ]
    sources += [
      "printing/chrome_print_render_frame_helper_delegate.cc",
      "printing/chrome_print_render_frame_helper_delegate.h",
    ]
  }

  if (enable_paint_preview) {
    deps += [ "//components/paint_preview/renderer" ]
  }

  if (is_win) {
    deps += [ "//third_party/wtl" ]
    sources += [
      "font_prewarmer.cc",
      "font_prewarmer.h",
      "render_frame_font_family_accessor.cc",
      "render_frame_font_family_accessor.h",
    ]
  }

  if (is_android) {
    sources += [
      "net/available_offline_content_helper.cc",
      "net/available_offline_content_helper.h",
      "net/page_auto_fetcher_helper_android.cc",
      "net/page_auto_fetcher_helper_android.h",
      "sandbox_status_extension_android.cc",
      "sandbox_status_extension_android.h",
      "wallet/boarding_pass_extractor.cc",
      "wallet/boarding_pass_extractor.h",
    ]
    deps += [
      "//chrome/common/wallet:mojo_bindings",
      "//components/feed/content/renderer:feed_renderer",
    ]
  } else {
    sources += [
      "accessibility/ax_tree_distiller.cc",
      "accessibility/ax_tree_distiller.h",
      "accessibility/read_aloud_app_model.cc",
      "accessibility/read_aloud_app_model.h",
      "accessibility/read_aloud_traversal_utils.cc",
      "accessibility/read_aloud_traversal_utils.h",
      "accessibility/read_anything_app_controller.cc",
      "accessibility/read_anything_app_controller.h",
      "accessibility/read_anything_app_model.cc",
      "accessibility/read_anything_app_model.h",
      "accessibility/read_anything_node_utils.cc",
      "accessibility/read_anything_node_utils.h",
      "media/chrome_speech_recognition_client.cc",
      "media/chrome_speech_recognition_client.h",
      "searchbox/searchbox.cc",
      "searchbox/searchbox.h",
      "searchbox/searchbox_extension.cc",
      "searchbox/searchbox_extension.h",
    ]

    deps += [
      "//chrome/common/accessibility:mojo_bindings",
      "//components/crx_file",
      "//components/trusted_vault",
      "//services/screen_ai/buildflags",
      "//services/screen_ai/public/mojom",
      "//services/strings",
      "//third_party/re2:re2",
    ]
  }

  if (is_chromeos_ash) {
    sources += [
      "ash_merge_session_loader_throttle.cc",
      "ash_merge_session_loader_throttle.h",
      "chromeos_delayed_callback_group.cc",
      "chromeos_delayed_callback_group.h",
    ]

    deps += [
      "//ash/constants",
      "//ash/webui/file_manager:constants",
    ]

    if (target_cpu == "x64") {
      sources += [
        "performance_manager/mechanisms/userspace_swap_impl_chromeos.cc",
        "performance_manager/mechanisms/userspace_swap_impl_chromeos.h",
      ]

      deps += [
        "//chromeos/ash/components/memory/userspace_swap",
        "//chromeos/ash/components/memory/userspace_swap:mojom",
      ]
    }
  }
}