chromium/content/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/cast.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//content/common/features.gni")
import("//media/media_options.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//sandbox/features.gni")
import("//services/screen_ai/buildflags/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/webrtc/webrtc.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")

if (is_component_build) {
  link_target_type = "source_set"
} else {
  link_target_type = "static_library"
}

target(link_target_type, "renderer") {
  # Only the public target should depend on this. All other targets (even
  # internal content ones) should depend on the public one.
  visibility = [
    ":for_content_tests",
    "//chromecast/media/audio:*",
    "//content/app:*",
    "//content/public/renderer:renderer_sources",
    "//media/mojo/clients:unit_tests",
  ]

  sources = [
    "accessibility/annotations/ax_annotator.h",
    "accessibility/annotations/ax_annotators_manager.cc",
    "accessibility/annotations/ax_annotators_manager.h",
    "accessibility/annotations/ax_image_annotator.cc",
    "accessibility/annotations/ax_image_annotator.h",
    "accessibility/annotations/ax_image_stopwords.cc",
    "accessibility/annotations/ax_image_stopwords.h",
    "accessibility/aom_content_ax_tree.cc",
    "accessibility/aom_content_ax_tree.h",
    "accessibility/ax_action_target_factory.cc",
    "accessibility/ax_action_target_factory.h",
    "accessibility/ax_tree_snapshotter_impl.cc",
    "accessibility/ax_tree_snapshotter_impl.h",
    "accessibility/blink_ax_action_target.cc",
    "accessibility/blink_ax_action_target.h",
    "accessibility/render_accessibility_impl.cc",
    "accessibility/render_accessibility_impl.h",
    "accessibility/render_accessibility_manager.cc",
    "accessibility/render_accessibility_manager.h",
    "agent_scheduling_group.cc",
    "agent_scheduling_group.h",
    "background_resource_fetch_assets.cc",
    "background_resource_fetch_assets.h",
    "browser_exposed_renderer_interfaces.cc",
    "browser_exposed_renderer_interfaces.h",
    "content_security_policy_util.cc",
    "content_security_policy_util.h",
    "discardable_memory_utils.cc",
    "discardable_memory_utils.h",
    "document_state.cc",
    "document_state.h",
    "dom_automation_controller.cc",
    "dom_automation_controller.h",
    "effective_connection_type_helper.cc",
    "effective_connection_type_helper.h",
    "frame_owner_properties_converter.cc",
    "frame_owner_properties_converter.h",
    "gpu_benchmarking_extension.cc",
    "gpu_benchmarking_extension.h",
    "in_process_renderer_thread.cc",
    "in_process_renderer_thread.h",
    "media/audio_decoder.cc",
    "media/audio_decoder.h",
    "media/batching_media_log.cc",
    "media/batching_media_log.h",
    "media/codec_factory.cc",
    "media/codec_factory.h",
    "media/codec_factory_mojo.cc",
    "media/codec_factory_mojo.h",
    "media/gpu/gpu_video_accelerator_factories_impl.cc",
    "media/gpu/gpu_video_accelerator_factories_impl.h",
    "media/inspector_media_event_handler.cc",
    "media/inspector_media_event_handler.h",
    "media/media_factory.cc",
    "media/media_factory.h",
    "media/media_interface_factory.cc",
    "media/media_interface_factory.h",
    "media/media_permission_dispatcher.cc",
    "media/media_permission_dispatcher.h",
    "media/render_media_client.cc",
    "media/render_media_client.h",
    "media/render_media_event_handler.cc",
    "media/render_media_event_handler.h",
    "media/renderer_web_media_player_delegate.cc",
    "media/renderer_web_media_player_delegate.h",
    "media/renderer_webaudiodevice_impl.cc",
    "media/renderer_webaudiodevice_impl.h",
    "mhtml_handle_writer.cc",
    "mhtml_handle_writer.h",
    "mojo/blink_interface_registry_impl.cc",
    "mojo/blink_interface_registry_impl.h",
    "navigation_client.cc",
    "navigation_client.h",
    "navigation_state.cc",
    "navigation_state.h",
    "net_info_helper.cc",
    "net_info_helper.h",
    "policy_container_util.cc",
    "policy_container_util.h",
    "render_frame_impl.cc",
    "render_frame_impl.h",
    "render_process.cc",
    "render_process.h",
    "render_process_impl.cc",
    "render_process_impl.h",
    "render_thread_impl.cc",
    "render_thread_impl.h",
    "renderer_blink_platform_impl.cc",
    "renderer_blink_platform_impl.h",
    "renderer_main.cc",
    "renderer_main_platform_delegate.h",
    "sad_plugin.cc",
    "sad_plugin.h",
    "service_worker/controller_service_worker_connector.cc",
    "service_worker/controller_service_worker_connector.h",
    "service_worker/embedded_worker_instance_client_impl.cc",
    "service_worker/embedded_worker_instance_client_impl.h",
    "service_worker/service_worker_context_client.cc",
    "service_worker/service_worker_context_client.h",
    "service_worker/service_worker_network_provider_for_frame.cc",
    "service_worker/service_worker_network_provider_for_frame.h",
    "service_worker/service_worker_provider_context.cc",
    "service_worker/service_worker_provider_context.h",
    "service_worker/service_worker_subresource_loader.cc",
    "service_worker/service_worker_subresource_loader.h",
    "service_worker/service_worker_type_converters.cc",
    "service_worker/service_worker_type_converters.h",
    "service_worker/web_service_worker_provider_impl.cc",
    "service_worker/web_service_worker_provider_impl.h",
    "skia_benchmarking_extension.cc",
    "skia_benchmarking_extension.h",
    "stats_collection_controller.cc",
    "stats_collection_controller.h",
    "v8_value_converter_impl.cc",
    "v8_value_converter_impl.h",
    "variations_render_thread_observer.cc",
    "variations_render_thread_observer.h",
    "web_ui_extension.cc",
    "web_ui_extension.h",
    "web_ui_extension_data.cc",
    "web_ui_extension_data.h",
    "webgraphicscontext3d_provider_impl.cc",
    "webgraphicscontext3d_provider_impl.h",
    "worker/dedicated_worker_host_factory_client.cc",
    "worker/dedicated_worker_host_factory_client.h",
    "worker/embedded_shared_worker_stub.cc",
    "worker/embedded_shared_worker_stub.h",
    "worker/fetch_client_settings_object_helpers.cc",
    "worker/fetch_client_settings_object_helpers.h",
    "worker/shared_worker_factory_impl.cc",
    "worker/shared_worker_factory_impl.h",
    "worker/worker_thread_registry.cc",
    "worker/worker_thread_registry.h",
  ]

  if (is_android) {
    sources += [
      "java/gin_java_bridge_dispatcher.cc",
      "java/gin_java_bridge_dispatcher.h",
      "java/gin_java_bridge_object.cc",
      "java/gin_java_bridge_object.h",
      "java/gin_java_bridge_value_converter.cc",
      "java/gin_java_bridge_value_converter.h",
      "java/gin_java_function_invocation_helper.cc",
      "java/gin_java_function_invocation_helper.h",
      "media/android/flinging_renderer_client.cc",
      "media/android/flinging_renderer_client.h",
      "media/android/flinging_renderer_client_factory.cc",
      "media/android/flinging_renderer_client_factory.h",
      "media/android/media_player_renderer_client.cc",
      "media/android/media_player_renderer_client.h",
      "media/android/media_player_renderer_client_factory.cc",
      "media/android/media_player_renderer_client_factory.h",
      "media/android/stream_texture_factory.cc",
      "media/android/stream_texture_factory.h",
      "media/android/stream_texture_wrapper_impl.cc",
      "media/android/stream_texture_wrapper_impl.h",
      "renderer_main_platform_delegate_android.cc",
      "seccomp_sandbox_status_android.cc",
      "seccomp_sandbox_status_android.h",
      "stream_texture_host_android.cc",
      "stream_texture_host_android.h",
    ]
  }

  if (is_linux || is_chromeos) {
    sources += [ "renderer_main_platform_delegate_linux.cc" ]
  }

  if (is_mac) {
    sources += [
      "renderer_main_platform_delegate_mac.mm",
      "theme_helper_mac.h",
      "theme_helper_mac.mm",
    ]
  }

  if (is_ios) {
    sources += [ "renderer_main_platform_delegate_ios.mm" ]
  }

  if (is_win) {
    sources += [
      "font_data/font_data_manager.cc",
      "font_data/font_data_manager.h",
      "renderer_main_platform_delegate_win.cc",
    ]
  }

  if (enable_cast_renderer) {
    sources += [
      "media/cast_renderer_client_factory.cc",
      "media/cast_renderer_client_factory.h",
    ]
  }

  configs += [ "//content:content_implementation" ]
  defines = []

  public_deps = [
    "//content/common:mojo_bindings",
    "//content/public/common:common_sources",
    "//content/public/renderer:render_frame_media_playback_options",
    "//ipc",
  ]

  deps = [
    "//base",
    "//base:i18n",
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//cc",
    "//cc/animation",
    "//cc/mojo_embedder",
    "//cc/mojom",
    "//cc/paint",
    "//components/discardable_memory/client",
    "//components/input",
    "//components/metrics",
    "//components/metrics:single_sample_metrics",
    "//components/services/font_data/public/mojom",
    "//components/startup_metric_utils",
    "//components/url_formatter",
    "//components/variations:variations_mojom",
    "//components/variations/net",
    "//components/viz/client",
    "//components/viz/common",
    "//content:content_resources",
    "//content/child",
    "//content/common",
    "//content/common:buildflags",
    "//content/common:main_frame_counter",
    "//content/gpu:gpu_sources",
    "//content/public/child:child_sources",
    "//content/services/auction_worklet:auction_worklet",
    "//crypto",
    "//device/base/synchronization",
    "//device/gamepad/public/cpp:shared_with_blink",
    "//device/gamepad/public/mojom",
    "//gin",
    "//gpu",
    "//gpu/command_buffer/client:gles2_interface",
    "//gpu/command_buffer/client:raster_interface",
    "//gpu/command_buffer/client:webgpu_interface",
    "//media",
    "//media:media_buildflags",
    "//media/capture",
    "//media/gpu",
    "//media/gpu/ipc/common",
    "//media/midi",
    "//media/midi:mojo",
    "//media/mojo:buildflags",
    "//media/mojo/clients",
    "//media/mojo/mojom",
    "//media/webrtc",
    "//mojo/public/cpp/bindings",
    "//net",
    "//ppapi/buildflags",
    "//printing/buildflags",
    "//sandbox",
    "//services/audio/public/mojom",
    "//services/device/public/cpp/generic_sensor",
    "//services/device/public/mojom",
    "//services/device/public/mojom:usb",
    "//services/image_annotation/public/cpp:cpp",
    "//services/image_annotation/public/mojom:mojom",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/network:network_service",
    "//services/network/public/mojom",
    "//services/screen_ai/buildflags",
    "//services/service_manager/public/cpp",
    "//services/service_manager/public/mojom",
    "//services/tracing/public/cpp",
    "//services/viz/public/cpp/gpu",
    "//skia",
    "//storage/common",
    "//third_party/blink/public:blink",
    "//third_party/blink/public:buildflags",
    "//third_party/blink/public/common",
    "//third_party/blink/public/platform/media",
    "//third_party/boringssl",
    "//third_party/icu",
    "//third_party/libyuv",
    "//third_party/sqlite",
    "//third_party/widevine/cdm:headers",
    "//ui/accessibility",
    "//ui/base",
    "//ui/base/clipboard",
    "//ui/base/dragdrop/mojom:mojom_shared",
    "//ui/base/ime",
    "//ui/display",
    "//ui/events:dom_keycode_converter",
    "//ui/events:events_base",
    "//ui/events/blink",
    "//ui/gfx/geometry/mojom",
    "//ui/gl",
    "//ui/latency",
    "//ui/native_theme",
    "//ui/strings:auto_image_annotation_strings_grit",
    "//ui/surface",
    "//url",
    "//v8",
  ]
  allow_circular_includes_from = []

  if (is_android) {
    deps += [
      # Used by Android WebView only.
      "//components/viz/service",
      "//third_party/ashmem",
      "//third_party/cpu_features:ndk_compat",
      "//third_party/libphonenumber",
    ]

    if (use_seccomp_bpf) {
      deps += [ "//sandbox/policy" ]
    }
  }

  if (enable_screen_ai_service) {
    sources += [
      "accessibility/annotations/ax_main_node_annotator.cc",
      "accessibility/annotations/ax_main_node_annotator.h",
    ]

    deps += [ "//services/screen_ai/public/mojom" ]
  }

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

  if (is_fuchsia) {
    sources += [
      "media/codec_factory_fuchsia.cc",
      "media/codec_factory_fuchsia.h",
      "renderer_main_platform_delegate_fuchsia.cc",
    ]
    public_deps += [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mediacodec:fuchsia.mediacodec_hlcpp" ]

    deps += [
      "//media/fuchsia/video",
      "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
    ]
  }

  if (enable_cast_receiver) {
    deps += [
      "//components/cast_streaming/common",
      "//components/cast_streaming/renderer:resource_provider",
    ]
  }

  # TODO(crbug.com/1293520): Remove this dependency on cast devices.
  if (enable_media_remoting || is_castos || is_cast_android) {
    deps += [ "//media/mojo/mojom:remoting" ]

    if (enable_media_remoting) {
      deps += [ "//media/remoting:remoting_sender" ]
    }

    if (is_castos || is_cast_android) {
      if (enable_cast_audio_renderer) {
        sources += [
          "media/cast_renderer_factory.cc",
          "media/cast_renderer_factory.h",
        ]

        deps += [ "//chromecast/media/audio:audio_renderer" ]
      }

      deps += [ "//media/remoting:remoting_renderer" ]
    }
  }

  if (enable_ppapi) {
    sources += [
      "pepper/audio_helper.cc",
      "pepper/audio_helper.h",
      "pepper/content_renderer_pepper_host_factory.cc",
      "pepper/content_renderer_pepper_host_factory.h",
      "pepper/event_conversion.cc",
      "pepper/event_conversion.h",
      "pepper/host_array_buffer_var.cc",
      "pepper/host_array_buffer_var.h",
      "pepper/host_dispatcher_wrapper.cc",
      "pepper/host_dispatcher_wrapper.h",
      "pepper/host_globals.cc",
      "pepper/host_globals.h",
      "pepper/host_resource_var.cc",
      "pepper/host_resource_var.h",
      "pepper/host_var_tracker.cc",
      "pepper/host_var_tracker.h",
      "pepper/message_channel.cc",
      "pepper/message_channel.h",
      "pepper/pepper_audio_controller.cc",
      "pepper/pepper_audio_controller.h",
      "pepper/pepper_audio_input_host.cc",
      "pepper/pepper_audio_input_host.h",
      "pepper/pepper_audio_output_host.cc",
      "pepper/pepper_audio_output_host.h",
      "pepper/pepper_browser_connection.cc",
      "pepper/pepper_browser_connection.h",
      "pepper/pepper_camera_device_host.cc",
      "pepper/pepper_camera_device_host.h",
      "pepper/pepper_device_enumeration_host_helper.cc",
      "pepper/pepper_device_enumeration_host_helper.h",
      "pepper/pepper_file_chooser_host.cc",
      "pepper/pepper_file_chooser_host.h",
      "pepper/pepper_file_ref_renderer_host.cc",
      "pepper/pepper_file_ref_renderer_host.h",
      "pepper/pepper_file_system_host.cc",
      "pepper/pepper_file_system_host.h",
      "pepper/pepper_graphics_2d_host.cc",
      "pepper/pepper_graphics_2d_host.h",
      "pepper/pepper_hung_plugin_filter.cc",
      "pepper/pepper_hung_plugin_filter.h",
      "pepper/pepper_in_process_resource_creation.cc",
      "pepper/pepper_in_process_resource_creation.h",
      "pepper/pepper_in_process_router.cc",
      "pepper/pepper_in_process_router.h",
      "pepper/pepper_media_device_manager.cc",
      "pepper/pepper_media_device_manager.h",
      "pepper/pepper_media_stream_audio_track_host.cc",
      "pepper/pepper_media_stream_audio_track_host.h",
      "pepper/pepper_media_stream_track_host_base.cc",
      "pepper/pepper_media_stream_track_host_base.h",
      "pepper/pepper_media_stream_video_track_host.cc",
      "pepper/pepper_media_stream_video_track_host.h",
      "pepper/pepper_platform_audio_input.cc",
      "pepper/pepper_platform_audio_input.h",
      "pepper/pepper_platform_audio_output.cc",
      "pepper/pepper_platform_audio_output.h",
      "pepper/pepper_platform_audio_output_dev.cc",
      "pepper/pepper_platform_audio_output_dev.h",
      "pepper/pepper_platform_camera_device.cc",
      "pepper/pepper_platform_camera_device.h",
      "pepper/pepper_platform_video_capture.cc",
      "pepper/pepper_platform_video_capture.h",
      "pepper/pepper_plugin_instance_impl.cc",
      "pepper/pepper_plugin_instance_impl.h",
      "pepper/pepper_plugin_registry.cc",
      "pepper/pepper_plugin_registry.h",
      "pepper/pepper_proxy_channel_delegate_impl.cc",
      "pepper/pepper_proxy_channel_delegate_impl.h",
      "pepper/pepper_try_catch.cc",
      "pepper/pepper_try_catch.h",
      "pepper/pepper_url_loader_host.cc",
      "pepper/pepper_url_loader_host.h",
      "pepper/pepper_video_capture_host.cc",
      "pepper/pepper_video_capture_host.h",
      "pepper/pepper_video_decoder_host.cc",
      "pepper/pepper_video_decoder_host.h",
      "pepper/pepper_video_encoder_host.cc",
      "pepper/pepper_video_encoder_host.h",
      "pepper/pepper_webplugin_impl.cc",
      "pepper/pepper_webplugin_impl.h",
      "pepper/pepper_websocket_host.cc",
      "pepper/pepper_websocket_host.h",
      "pepper/plugin_module.cc",
      "pepper/plugin_module.h",
      "pepper/plugin_object.cc",
      "pepper/plugin_object.h",
      "pepper/ppapi_preferences_builder.cc",
      "pepper/ppapi_preferences_builder.h",
      "pepper/ppb_audio_impl.cc",
      "pepper/ppb_audio_impl.h",
      "pepper/ppb_buffer_impl.cc",
      "pepper/ppb_buffer_impl.h",
      "pepper/ppb_graphics_3d_impl.cc",
      "pepper/ppb_graphics_3d_impl.h",
      "pepper/ppb_image_data_impl.cc",
      "pepper/ppb_image_data_impl.h",
      "pepper/ppb_proxy_impl.cc",
      "pepper/ppb_proxy_impl.h",
      "pepper/ppb_var_deprecated_impl.cc",
      "pepper/ppb_var_deprecated_impl.h",
      "pepper/renderer_ppapi_host_impl.cc",
      "pepper/renderer_ppapi_host_impl.h",
      "pepper/renderer_restrict_dispatch_group.h",
      "pepper/resource_converter.cc",
      "pepper/resource_converter.h",
      "pepper/resource_creation_impl.cc",
      "pepper/resource_creation_impl.h",
      "pepper/url_request_info_util.cc",
      "pepper/url_request_info_util.h",
      "pepper/url_response_info_util.cc",
      "pepper/url_response_info_util.h",
      "pepper/v8_var_converter.cc",
      "pepper/v8_var_converter.h",
      "pepper/v8object_var.cc",
      "pepper/v8object_var.h",
      "pepper/video_decoder_shim.cc",
      "pepper/video_decoder_shim.h",
      "pepper/video_encoder_shim.cc",
      "pepper/video_encoder_shim.h",
    ]

    deps += [
      "//components/nacl/common:buildflags",
      "//ppapi/host",
      "//ppapi/proxy",
      "//ppapi/shared_impl",
      "//printing/mojom",
      "//third_party/libvpx",
      "//third_party/opus",
      "//ui/base/cursor",
      "//ui/base/cursor/mojom:cursor_type",
    ]
  }

  if (is_win) {
    sources += [
      "media/win/dcomp_texture_factory.cc",
      "media/win/dcomp_texture_factory.h",
      "media/win/dcomp_texture_host.cc",
      "media/win/dcomp_texture_host.h",
      "media/win/dcomp_texture_wrapper_impl.cc",
      "media/win/dcomp_texture_wrapper_impl.h",
      "media/win/overlay_state_observer_impl.cc",
      "media/win/overlay_state_observer_impl.h",
      "media/win/overlay_state_service_provider.cc",
      "media/win/overlay_state_service_provider.h",
    ]
  }

  if (is_linux || is_chromeos || is_android) {
    deps += [ "//sandbox:sandbox_buildflags" ]
  }

  if (is_chromeos) {
    deps += [ "//chromeos/system:system" ]
  }
  if (is_chromeos_ash) {
    deps += [ "//chromeos:chromeos_export" ]
    if (target_cpu == "x64") {
      deps += [ "//chromeos/ash/components/memory/userspace_swap" ]
    }
  }

  if (use_ozone) {
    deps += [ "//ui/ozone" ]
  }

  if (enable_ipc_fuzzer) {
    configs += [ "//tools/ipc_fuzzer:ipc_fuzzer_config" ]
  }
}

# See comment at the top of //content/BUILD.gn for how this works.
group("for_content_tests") {
  visibility = [
    ":audio_decoder_fuzzer",
    ":content_security_policy_util_fuzzer",
    "//content/test/*",
    "//content/web_test:web_test_renderer_public_deps",
  ]

  if (!is_component_build) {
    public_deps = [ ":renderer" ]
  }
}

fuzzer_test("audio_decoder_fuzzer") {
  # See comment at the top of //content/BUILD.gn for why this is disabled in
  # component builds.
  if (is_component_build) {
    check_includes = false
  }

  sources = [ "media/audio_decoder_fuzzer.cpp" ]
  deps = [
    ":for_content_tests",
    "//content/test:test_support",
  ]
  seed_corpus = "//media/test/data"
}

fuzzer_test("content_security_policy_util_fuzzer") {
  # See comment at the top of //content/BUILD.gn for why this is disabled in
  # component builds.
  if (is_component_build) {
    check_includes = false
  }

  sources = [ "content_security_policy_util_fuzzer.cc" ]
  deps = [
    ":for_content_tests",
    "//base",
    "//content/test:test_support",
    "//services/network:network_service",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
  ]
  dict = "//testing/libfuzzer/fuzzers/dicts/content_security_policy.dict"
  seed_corpus = "//testing/libfuzzer/fuzzers/content_security_policy_corpus"
}