chromium/third_party/blink/public/common/BUILD.gn

# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/buildflag_header.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni")
import("//build/config/rust.gni")
import("//skia/features.gni")
import("//testing/test.gni")
import("//third_party/blink/public/public_features.gni")
import("//third_party/blink/renderer/build/scripts/scripts.gni")
import("//third_party/protobuf/proto_library.gni")
import("//third_party/webrtc/webrtc.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

blink_python_runner("make_generated_permissions_policy_helper") {
  script = "../../renderer/build/scripts/make_policy_helper_public.py"

  inputs = scripts_for_json5_files + [
             "../../renderer/build/scripts/make_policy_helper_public.py",
             "../../renderer/core/permissions_policy/permissions_policy_features.json5",
             "../../renderer/build/scripts/templates/policy_helper_public.cc.tmpl",
           ]
  outputs = [ "$root_gen_dir/third_party/blink/public/common/permissions_policy/policy_helper_public.cc" ]

  args = [
    rebase_path(
        "../../renderer/core/permissions_policy/permissions_policy_features.json5",
        root_build_dir),
    "--output_dir",
    rebase_path(
        "$root_gen_dir/third_party/blink/public/common/permissions_policy",
        root_build_dir),
  ]
}

blink_python_runner("make_runtime_feature_state_contexts_headers") {
  script = "../../renderer/build/scripts/make_runtime_feature_state_contexts_headers.py"

  inputs = scripts_for_json5_files + [
             "../../renderer/platform/runtime_enabled_features.json5",
             "../../renderer/build/scripts/templates/runtime_feature_state_context.h.tmpl",
             "../../renderer/build/scripts/templates/runtime_feature_state_read_context.h.tmpl",
           ]

  outputs = [
    "$root_gen_dir/third_party/blink/public/common/runtime_feature_state/runtime_feature_state_context.h",
    "$root_gen_dir/third_party/blink/public/common/runtime_feature_state/runtime_feature_state_read_context.h",
  ]

  args = [
    rebase_path("../../renderer/platform/runtime_enabled_features.json5",
                root_build_dir),
    "--output_dir",
    rebase_path(
        "$root_gen_dir/third_party/blink/public/common/runtime_feature_state/",
        root_build_dir),
  ]
}

# Public common API headers, mojom and libraries that can be linked and
# referenced both by browser-side and renderer-side components.
component("common") {
  output_name = "blink_common"

  public_deps = [
    "//third_party/blink/common/privacy_budget:privacy_budget",
    "//third_party/blink/public/common:headers",
    "//third_party/blink/public/mojom:mojom_modules",
    "//third_party/blink/public/mojom:web_bluetooth_mojo_bindings",
  ]
  deps = [
    "//cc/ipc",
    "//third_party/blink/common",
    "//ui/events/ipc",
  ]
}

buildflag_header("buildflags") {
  header = "buildflags.h"
  flags = [
    "RTC_USE_H264=$rtc_use_h264",
    "RTC_USE_H265=$rtc_use_h265",
    "ENABLE_RUST_CRASH=$enable_rust_crash",
  ]
}

source_set("common_export") {
  visibility = [
    "//third_party/blink/common/*",
    "//third_party/blink/public/common/*",
  ]
  sources = [ "common_export.h" ]
}

source_set("headers") {
  visibility = [
    ":*",
    "//android_webview/*",
    "//chrome/*",
    "//chromecast/*",
    "//components/*",
    "//content/*",
    "//fuchsia/*",
    "//pdf/*",
    "//services/*",
    "//storage/*",
    "//third_party/blink/*",
  ]

  sources = [
    "associated_interfaces/associated_interface_provider.h",
    "associated_interfaces/associated_interface_registry.h",
    "blob/blob_utils.h",
    "bluetooth/web_bluetooth_device_id.h",
    "bluetooth/web_bluetooth_device_id_mojom_traits.h",
    "cache_storage/cache_storage_utils.h",
    "chrome_debug_urls.h",
    "client_hints/client_hints.h",
    "client_hints/enabled_client_hints.h",
    "context_menu_data/context_menu_data.h",
    "context_menu_data/context_menu_params_builder.h",
    "context_menu_data/edit_flags.h",
    "context_menu_data/menu_item_info.h",
    "context_menu_data/untrustworthy_context_menu_params.h",
    "css/forced_colors.h",
    "css/navigation_controls.h",
    "css/page_orientation.h",
    "css/page_size_type.h",
    "css/scripting.h",
    "custom_handlers/protocol_handler_utils.h",
    "device_memory/approximated_device_memory.h",
    "dom_storage/session_storage_namespace_id.h",
    "features.h",
    "fenced_frame/fenced_frame_utils.h",
    "fenced_frame/redacted_fenced_frame_config.h",
    "fenced_frame/redacted_fenced_frame_config_mojom_traits.h",
    "fetch/fetch_api_request_headers_map.h",
    "fetch/fetch_api_request_headers_mojom_traits.h",
    "forcedark/forcedark_switches.h",
    "frame/delegated_capability_request_token.h",
    "frame/fenced_frame_permissions_policies.h",
    "frame/fenced_frame_sandbox_flags.h",
    "frame/frame_ad_evidence.h",
    "frame/frame_owner_element_type.h",
    "frame/frame_owner_element_type_mojom_traits.h",
    "frame/frame_policy.h",
    "frame/frame_visual_properties.h",
    "frame/from_ad_state.h",
    "frame/history_user_activation_state.h",
    "frame/user_activation_state.h",
    "frame/user_activation_update_source.h",
    "frame/view_transition_state.h",
    "history/session_history_constants.h",
    "indexeddb/indexed_db_default_mojom_traits.h",
    "indexeddb/indexeddb_key.h",
    "indexeddb/indexeddb_key_path.h",
    "indexeddb/indexeddb_key_range.h",
    "indexeddb/indexeddb_metadata.h",
    "input/pointer_id.h",
    "input/synthetic_web_input_event_builders.h",
    "input/web_coalesced_input_event.h",
    "input/web_coalesced_input_event_mojom_traits.h",
    "input/web_gesture_device.h",
    "input/web_gesture_event.h",
    "input/web_input_event.h",
    "input/web_input_event_attribution.h",
    "input/web_keyboard_event.h",
    "input/web_menu_source_type.h",
    "input/web_mouse_event.h",
    "input/web_mouse_wheel_event.h",
    "input/web_pointer_event.h",
    "input/web_pointer_properties.h",
    "input/web_touch_event.h",
    "input/web_touch_point.h",
    "interest_group/ad_auction_constants.h",
    "interest_group/ad_auction_currencies.h",
    "interest_group/ad_display_size.h",
    "interest_group/ad_display_size_mojom_traits.h",
    "interest_group/ad_display_size_utils.h",
    "interest_group/auction_config.h",
    "interest_group/auction_config_mojom_traits.h",
    "interest_group/auction_server_request_flags.h",
    "interest_group/devtools_serialization.h",
    "interest_group/interest_group.h",
    "interest_group/interest_group_mojom_traits.h",
    "interest_group/seller_capabilities.h",
    "link_to_text/link_to_text_mojom_traits.h",
    "loader/background_resource_fetch_histograms.h",
    "loader/http_body_element_type.h",
    "loader/inter_process_time_ticks_converter.h",
    "loader/javascript_framework_detection.h",
    "loader/lcp_critical_path_predictor_util.h",
    "loader/loader_constants.h",
    "loader/loading_behavior_flag.h",
    "loader/mime_sniffing_throttle.h",
    "loader/mime_sniffing_url_loader.h",
    "loader/network_utils.h",
    "loader/record_load_histograms.h",
    "loader/referrer_utils.h",
    "loader/resource_type_util.h",
    "loader/url_loader_factory_bundle.h",
    "loader/url_loader_factory_bundle_mojom_traits.h",
    "loader/url_loader_throttle.h",
    "loader/worker_main_script_load_parameters.h",
    "logging/logging_utils.h",
    "manifest/manifest.h",
    "manifest/manifest_icon_selector.h",
    "manifest/manifest_util.h",
    "media/display_type.h",
    "media/video_capture.h",
    "media/watch_time_component.h",
    "media/watch_time_reporter.h",
    "mediastream/media_device_id.h",
    "mediastream/media_devices.h",
    "mediastream/media_devices_mojom_traits.h",
    "mediastream/media_stream_controls.h",
    "mediastream/media_stream_mojom_traits.h",
    "mediastream/media_stream_request.h",
    "messaging/accelerated_image_info.h",
    "messaging/accelerated_static_bitmap_image_mojom_traits.h",
    "messaging/cloneable_message.h",
    "messaging/cloneable_message_mojom_traits.h",
    "messaging/message_port_channel.h",
    "messaging/message_port_descriptor.h",
    "messaging/message_port_descriptor_mojom_traits.h",
    "messaging/string_message_codec.h",
    "messaging/transferable_message.h",
    "messaging/transferable_message_mojom_traits.h",
    "messaging/web_message_port.h",
    "metrics/accept_language_and_content_language_usage.h",
    "metrics/document_update_reason.h",
    "metrics/form_element_pii_type.h",
    "mime_util/mime_util.h",
    "navigation/impression.h",
    "navigation/navigation_params.h",
    "navigation/navigation_params_mojom_traits.h",
    "navigation/navigation_policy.h",
    "navigation/resource_intercept_policy.h",
    "notifications/notification_constants.h",
    "notifications/notification_mojom_traits.h",
    "notifications/notification_resources.h",
    "notifications/platform_notification_data.h",
    "oom_intervention/oom_intervention_types.h",
    "origin_trials/origin_trial_policy.h",
    "origin_trials/origin_trial_public_key.h",
    "origin_trials/origin_trials.h",
    "origin_trials/origin_trials_settings_provider.h",
    "origin_trials/trial_token.h",
    "origin_trials/trial_token_result.h",
    "origin_trials/trial_token_validator.h",
    "page/browsing_context_group_info.h",
    "page/browsing_context_group_info_mojom_traits.h",
    "page/color_provider_color_maps.h",
    "page/color_provider_color_maps_mojom_traits.h",
    "page/content_to_visible_time_reporter.h",
    "page/drag_mojom_traits.h",
    "page/drag_operation.h",
    "page/launching_process_state.h",
    "page/page_zoom.h",
    "page/v8_compile_hints_histograms.h",
    "page_state/page_state.h",
    "page_state/page_state_serialization.h",
    "peerconnection/webrtc_ip_handling_policy.h",
    "performance/largest_contentful_paint_type.h",
    "performance/performance_timeline_constants.h",
    "permissions/permission_utils.h",
    "permissions_policy/document_policy.h",
    "permissions_policy/document_policy_features.h",
    "permissions_policy/permissions_policy.h",
    "permissions_policy/permissions_policy_declaration.h",
    "permissions_policy/permissions_policy_features.h",
    "permissions_policy/policy_helper_public.h",
    "permissions_policy/policy_value.h",
    "renderer_preferences/renderer_preferences.h",
    "responsiveness_metrics/user_interaction_latency.h",
    "safe_url_pattern.h",
    "scheduler/task_attribution_id.h",
    "scheduler/web_scheduler_tracked_feature.h",
    "scheme_registry.h",
    "security/address_space_feature.h",
    "security/protocol_handler_security_level.h",
    "security/security_style.h",
    "security_context/insecure_request_policy.h",
    "service_worker/service_worker_loader_helpers.h",
    "service_worker/service_worker_router_rule.h",
    "service_worker/service_worker_scope_match.h",
    "service_worker/service_worker_status_code.h",
    "service_worker/service_worker_subresource_load_metrics.h",
    "service_worker/service_worker_type_converters.h",
    "service_worker/service_worker_types.h",
    "shared_storage/module_script_downloader.h",
    "shared_storage/shared_storage_mojom_traits.h",
    "shared_storage/shared_storage_utils.h",
    "sms/webotp_constants.h",
    "sms/webotp_service_outcome.h",
    "storage_key/storage_key.h",
    "subresource_load_metrics.h",
    "switches.h",
    "thread_safe_browser_interface_broker_proxy.h",
    "unique_name/unique_name_helper.h",
    "use_counter/use_counter_feature.h",
    "use_counter/use_counter_feature_tracker.h",
    "user_agent/user_agent_brand_version_type.h",
    "user_agent/user_agent_metadata.h",
    "web_cache/web_cache_resource_type_stats.h",
    "web_package/signed_exchange_consts.h",
    "web_package/web_package_request_matcher.h",
    "web_preferences/web_preferences.h",
    "widget/constants.h",
    "widget/device_emulation_params.h",
    "widget/visual_properties.h",
  ]

  sources += get_target_outputs(":make_generated_permissions_policy_helper")
  sources += get_target_outputs(":make_runtime_feature_state_contexts_headers")

  public_deps = [
    ":make_generated_permissions_policy_helper",
    ":make_runtime_feature_state_contexts_headers",
    "//base",
    "//mojo/public/cpp/bindings",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/network/public/cpp:cpp",
    "//skia",
    "//skia/public/mojom:shared_typemap_traits",
    "//third_party/blink/public:runtime_features_for_public",
    "//third_party/blink/public/common/privacy_budget",
    "//third_party/blink/public/common/tokens:tokens_headers",
    "//third_party/blink/public/mojom:mojom_modules_headers",
    "//third_party/blink/public/mojom:mojom_platform_shared",
    "//third_party/blink/public/mojom:web_bluetooth_mojo_bindings_headers",
    "//third_party/blink/public/mojom/origin_trial_feature",
    "//third_party/liburlpattern",
    "//ui/display/mojom",
    "//ui/events:event_constants",
    "//ui/events/types:headers",
    "//ui/latency",
  ]

  deps = [
    ":buildflags",
    ":common_export",
    "//base",
    "//cc",
    "//components/shared_highlighting/core/common",
    "//components/viz/common",
    "//gpu/command_buffer/common",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/system",
    "//mojo/public/mojom/base",
    "//net",
    "//ui/base:base",
  ]

  # Chromium without blink doesn't use and must not depend on //media
  if (use_blink) {
    deps += [
      "//media",
      "//media/capture:capture_base",
      "//media/capture:capture_lib",
    ]
    public_deps += [ "//media/mojo/mojom" ]
  }

  if (is_android || is_win) {
    sources += [
      "font_unique_name_lookup/font_table_matcher.h",
      "font_unique_name_lookup/font_table_persistence.h",
      "font_unique_name_lookup/icu_fold_case_util.h",
    ]
    deps += [ ":font_unique_name_table_proto" ]
  }

  if (is_mac) {
    sources += [ "sandbox_support/sandbox_support_mac.h" ]
  }
}

if (is_android || is_win) {
  proto_library("font_unique_name_table_proto") {
    sources = [ "font_unique_name_lookup/font_unique_name_table.proto" ]
  }
}

proto_library("font_enumeration_table_proto") {
  sources = [ "font_access/font_enumeration_table.proto" ]
}

if (is_android) {
  java_cpp_features("java_features_srcjar") {
    # External code should depend on ":common_java" instead.
    visibility = [ ":*" ]
    sources = [
      "$root_gen_dir/third_party/blink/common/features_generated.cc",
      "//third_party/blink/common/features.cc",
    ]
    template = "//third_party/blink/public/common/android/java_templates/BlinkFeatures.java.tmpl"
    deps = [ "//third_party/blink/common:make_generated_features" ]
  }

  android_library("common_java") {
    # Right now, this only includes the Java features. But if we need more Java
    # files, they should be added here as necessary.
    srcjar_deps = [ ":java_features_srcjar" ]
  }
}

proto_library("storage_key_proto") {
  proto_in_dir = "//"
  sources = [ "storage_key/proto/storage_key.proto" ]
}

source_set("storage_key_proto_converter") {
  sources = [
    "storage_key/storage_key_proto_converter.cc",
    "storage_key/storage_key_proto_converter.h",
  ]
  deps = [ ":common" ]

  public_deps = [ ":storage_key_proto" ]
}