chromium/content/shell/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/ozone.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//build/config/win/console_app.gni")
import("//build/config/win/manifest.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//gpu/vulkan/features.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//third_party/inspector_protocol/inspector_protocol.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
if (is_android) {
  import("//build/config/android/config.gni")
} else if (is_mac) {
  import("//build/apple/tweak_info_plist.gni")
  import("//build/config/mac/rules.gni")
  import("//content/public/app/mac_helpers.gni")
  import("//third_party/icu/config.gni")
  import("//ui/gl/features.gni")
  import("//v8/gni/v8.gni")
} else if (is_fuchsia) {
  import("//build/config/fuchsia/generate_runner_scripts.gni")
  import("//third_party/fuchsia-gn-sdk/src/component.gni")
  import("//third_party/fuchsia-gn-sdk/src/package.gni")
} else if (is_ios) {
  import("//build/config/apple/swift_source_set.gni")
  import("//build/config/ios/config.gni")
  import("//content/shell/app/ios/extensions.gni")
}

# TODO(crbug.com/1336055, spang): Investigate using shell_views with cast builds as
# true.
shell_use_toolkit_views = toolkit_views && !is_castos

declare_args() {
  content_shell_product_name = "Content Shell"
  content_shell_version = "999.77.34.5"
  content_shell_major_version = "999"
}

config("content_shell_lib_warnings") {
  if (is_clang) {
    # TODO(thakis): Remove this once http://crbug.com/383820 is figured out
    cflags = [ "-Wno-nonnull" ]
  }
}

# Web test support not built on android, but is everywhere else.
support_web_tests = !is_android

source_set("android_shell_descriptors") {
  testonly = true
  sources = []
  public_deps = [ "//content/public/common:content_descriptors" ]
  if (is_android) {
    sources += [ "android/shell_descriptors.h" ]
  }
}

# This component provides a ContentMainDelegate for Content Shell and derived
# applications. This delegate is the central place that creates interfaces for
# each type of process (browser, renderer, etc). This implementation of
# ContentMainDelegate will create either production or test-based
# implementations.
#
# This component needs to be linked into every process in a Content Shell-based
# application that wants to use ShellMainDelegate.
#
# TODO(danakj): This component will depend on {renderer,browser}/web_test. The
# content_shell_lib component will not, to avoid circular deps, as web_test
# inherits from things in content_shell_lib.
static_library("content_shell_app") {
  testonly = true
  sources = [
    "app/shell_crash_reporter_client.cc",
    "app/shell_crash_reporter_client.h",
    "app/shell_main_delegate.cc",
    "app/shell_main_delegate.h",
  ]
  deps = [
    ":content_shell_lib",
    "//components/crash/core/common:crash_key",
    "//components/memory_system",
    "//content/public/app",
    "//v8",
  ]
  if (support_web_tests) {
    deps += [
      "//content/web_test:web_test_browser",
      "//content/web_test:web_test_common",
      "//content/web_test:web_test_renderer",
    ]
  }
  if (!is_fuchsia) {
    deps += [
      "//components/crash/core/app",
      "//components/crash/core/app:test_support",
    ]
  }
  if (is_apple) {
    sources += [
      "app/paths_mac.h",
      "app/paths_mac.mm",
    ]
  }
  if (is_mac) {
    sources += [
      "app/shell_main_delegate_mac.h",
      "app/shell_main_delegate_mac.mm",
    ]
  }
  if (is_ios) {
    sources += [
      "app/ios/shell_application_ios.h",
      "app/ios/shell_application_ios.mm",
      "app/ios/web_tests_support_ios.h",
      "app/ios/web_tests_support_ios.mm",
    ]
  }
  defines = [
    "CONTENT_SHELL_VERSION=\"$content_shell_version\"",
    "CONTENT_SHELL_MAJOR_VERSION=\"$content_shell_major_version\"",
  ]
}

inspector_protocol_generate("protocol_sources") {
  visibility = [ ":content_shell_lib" ]
  deps = [ "//third_party/blink/public/devtools_protocol:protocol_version" ]
  _blink_protocol_path = rebase_path(
          "$root_gen_dir/third_party/blink/public/devtools_protocol/protocol.json",
          root_build_dir)

  inspector_protocol_dir = "//third_party/inspector_protocol"
  out_dir = "$target_gen_dir/browser"
  config_file = "browser/protocol_config.json"
  config_values = [ "protocol.path=$_blink_protocol_path" ]
  use_embedder_types = true

  inputs = [
    "$root_gen_dir/third_party/blink/public/devtools_protocol/protocol.json",
    config_file,
  ]

  # These are relative to $target_gen_dir.
  outputs = [
    "protocol/browser.cc",
    "protocol/browser.h",
    "protocol/protocol.h",
  ]
}

static_library("content_shell_lib") {
  testonly = true
  sources = [
    "browser/protocol/browser_handler.cc",
    "browser/protocol/browser_handler.h",
    "browser/protocol/domain_handler.h",
    "browser/protocol/shell_devtools_session.cc",
    "browser/protocol/shell_devtools_session.h",
    "browser/shell.cc",
    "browser/shell.h",
    "browser/shell_browser_context.cc",
    "browser/shell_browser_context.h",
    "browser/shell_browser_main_parts.cc",
    "browser/shell_browser_main_parts.h",
    "browser/shell_content_browser_client.cc",
    "browser/shell_content_browser_client.h",
    "browser/shell_content_index_provider.cc",
    "browser/shell_content_index_provider.h",
    "browser/shell_devtools_bindings.cc",
    "browser/shell_devtools_bindings.h",
    "browser/shell_devtools_frontend.cc",
    "browser/shell_devtools_frontend.h",
    "browser/shell_devtools_manager_delegate.cc",
    "browser/shell_devtools_manager_delegate.h",
    "browser/shell_download_manager_delegate.cc",
    "browser/shell_download_manager_delegate.h",
    "browser/shell_javascript_dialog.h",
    "browser/shell_javascript_dialog_manager.cc",
    "browser/shell_javascript_dialog_manager.h",
    "browser/shell_paths.cc",
    "browser/shell_paths.h",
    "browser/shell_permission_manager.cc",
    "browser/shell_permission_manager.h",
    "browser/shell_platform_data_aura.cc",
    "browser/shell_platform_data_aura.h",
    "browser/shell_platform_delegate.cc",
    "browser/shell_platform_delegate.h",
    "browser/shell_speech_recognition_manager_delegate.cc",
    "browser/shell_speech_recognition_manager_delegate.h",
    "browser/shell_web_contents_view_delegate.h",
    "browser/shell_web_contents_view_delegate_creator.h",
    "common/main_frame_counter_test_impl.cc",
    "common/main_frame_counter_test_impl.h",
    "common/power_monitor_test_impl.cc",
    "common/power_monitor_test_impl.h",
    "common/shell_content_client.cc",
    "common/shell_content_client.h",
    "common/shell_origin_trial_policy.cc",
    "common/shell_origin_trial_policy.h",
    "common/shell_switches.cc",
    "common/shell_switches.h",
    "gpu/shell_content_gpu_client.cc",
    "gpu/shell_content_gpu_client.h",
    "renderer/render_frame_test_helper.cc",
    "renderer/render_frame_test_helper.h",
    "renderer/shell_content_renderer_client.cc",
    "renderer/shell_content_renderer_client.h",
    "renderer/shell_render_frame_observer.cc",
    "renderer/shell_render_frame_observer.h",
    "utility/shell_content_utility_client.cc",
    "utility/shell_content_utility_client.h",
  ]

  sources += get_target_outputs(":protocol_sources")

  if (is_android) {
    sources += [
      "android/shell_manager.cc",
      "android/shell_manager.h",
      "browser/shell_platform_delegate_android.cc",
      "browser/shell_web_contents_view_delegate_android.cc",
    ]
  }

  if (is_mac) {
    sources += [
      "browser/renderer_host/shell_render_widget_host_view_mac_delegate.h",
      "browser/renderer_host/shell_render_widget_host_view_mac_delegate.mm",
      "browser/shell_application_mac.h",
      "browser/shell_application_mac.mm",
      "browser/shell_browser_main_parts_mac.mm",
      "browser/shell_javascript_dialog_mac.mm",
      "browser/shell_platform_delegate_mac.mm",
      "browser/shell_web_contents_view_delegate_mac.mm",
    ]
  }

  if (is_ios) {
    sources += [
      "browser/bluetooth/ios/shell_bluetooth_chooser_coordinator.h",
      "browser/bluetooth/ios/shell_bluetooth_chooser_coordinator.mm",
      "browser/bluetooth/ios/shell_bluetooth_chooser_ios.h",
      "browser/bluetooth/ios/shell_bluetooth_chooser_ios.mm",
      "browser/bluetooth/ios/shell_bluetooth_chooser_mediator.h",
      "browser/bluetooth/ios/shell_bluetooth_chooser_mediator.mm",
      "browser/bluetooth/ios/shell_bluetooth_device_list_consumer.h",
      "browser/bluetooth/ios/shell_bluetooth_device_list_delegate.h",
      "browser/bluetooth/ios/shell_bluetooth_device_list_view_controller.h",
      "browser/bluetooth/ios/shell_bluetooth_device_list_view_controller.mm",
      "browser/bluetooth/shell_bluetooth_delegate_impl_client.cc",
      "browser/bluetooth/shell_bluetooth_delegate_impl_client.h",
      "browser/color_chooser/shell_color_chooser_ios.h",
      "browser/color_chooser/shell_color_chooser_ios.mm",
      "browser/shell_browser_main_parts_ios.mm",
      "browser/shell_file_select_helper.cc",
      "browser/shell_file_select_helper.h",
      "browser/shell_platform_delegate_ios.mm",
      "browser/shell_web_contents_view_delegate_ios.mm",
    ]
  }

  if (is_win) {
    sources += [ "browser/shell_javascript_dialog_win.cc" ]
  }

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

  defines = [
    "CONTENT_SHELL_VERSION=\"$content_shell_version\"",
    "CONTENT_SHELL_MAJOR_VERSION=\"$content_shell_major_version\"",
  ]

  # This is to support our dependency on //content/browser.
  # See comment at the top of //content/BUILD.gn for why this is disabled in
  # component builds.
  if (is_component_build) {
    check_includes = false
  }

  public_deps = [
    ":android_shell_descriptors",

    # content_shell_lib also exposes all public content APIs.
    "//content/public/app",
    "//content/public/browser",
    "//content/public/child",
    "//content/public/common",
    "//content/public/gpu",
    "//content/public/renderer",
    "//content/public/utility",
    "//services/network:network_service",
  ]
  deps = [
    ":content_browsertests_mojom",
    ":protocol_sources",
    ":resources",
    ":shell_controller_mojom",
    "//base",
    "//base:base_static",
    "//build:chromeos_buildflags",
    "//cc/base",
    "//components/cdm/renderer",
    "//components/custom_handlers",
    "//components/custom_handlers:test_support",
    "//components/input",
    "//components/keyed_service/content",
    "//components/metrics",
    "//components/metrics:net",
    "//components/metrics:test_support",
    "//components/network_hints/browser:browser",
    "//components/network_hints/renderer",
    "//components/network_session_configurator/common",
    "//components/origin_trials:browser",
    "//components/origin_trials:common",
    "//components/performance_manager",
    "//components/permissions",
    "//components/prefs",
    "//components/services/storage/test_api",
    "//components/url_formatter",
    "//components/variations",
    "//components/variations/service",
    "//components/web_cache/renderer",
    "//content:content_resources",
    "//content/common:main_frame_counter",
    "//content/public/common",
    "//content/test:content_test_mojo_bindings",
    "//content/test:test_support",
    "//device/bluetooth",
    "//media",
    "//media/mojo:buildflags",
    "//media/mojo/services",
    "//net",
    "//net:net_resources",
    "//ppapi/buildflags",
    "//services/device/public/cpp:test_support",
    "//services/network/public/cpp",
    "//services/test/echo:lib",
    "//services/test/echo/public/mojom",
    "//third_party/blink/public:blink",
    "//third_party/blink/public:image_resources",
    "//third_party/blink/public:resources",
    "//third_party/blink/public/strings",
    "//third_party/inspector_protocol:crdtp",
    "//ui/base",
    "//ui/base/clipboard",
    "//ui/base/ime/init",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/platform_window",
    "//ui/strings:auto_image_annotation_strings",
    "//url",
    "//v8",
  ]

  if (is_fuchsia) {
    sources += [
      "browser/fuchsia_view_presenter.cc",
      "browser/fuchsia_view_presenter.h",
    ]
    deps += [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.element:fuchsia.element_hlcpp" ]
  } else {
    deps += [
      "//components/crash/content/browser",
      "//components/crash/core/app",
    ]
  }

  if (enable_plugins) {
    sources += [
      "browser/shell_plugin_service_filter.cc",
      "browser/shell_plugin_service_filter.h",
    ]
  }

  if (enable_cast_renderer) {
    deps += [ "//media/mojo/services" ]
  }

  if (is_win) {
    sources += [
      "common/v8_crashpad_support_win.cc",
      "common/v8_crashpad_support_win.h",
    ]
    deps += [ "//gin" ]
  }

  if (is_linux) {
    deps += [ "//ui/linux:linux_ui_factory" ]
  }

  if (is_mac) {
    deps += [ "//ui/display:test_support" ]
  }

  if (is_ios) {
    deps += [
      "//components/permissions",
      "//components/strings:components_strings",
      "//services/tracing/public/cpp",
      "//services/tracing/public/mojom:mojom",
      "//ui/shell_dialogs",
    ]
  }

  if (is_android) {
    deps += [
      "//components/embedder_support/android:view",
      "//content/shell/android:content_shell_jni_headers",
      "//mojo/public/java/system:test_support",
      "//ui/android",
    ]
  }

  if (shell_use_toolkit_views) {
    # All content_shell code should use this define instead of TOOLKIT_VIEWS,
    # since any transitive dependency on //ui/views from another component will
    # cause TOOLKIT_VIEWS to be defined, even when content_shell does not want
    # to use it internally. See https://crbug.com/1218907.
    defines += [ "SHELL_USE_TOOLKIT_VIEWS=1" ]
    deps += [ "//ui/views" ]
  }

  if (use_aura) {
    deps += [
      "//ui/aura",
      "//ui/aura:test_support",
      "//ui/events",
      "//ui/wm",
    ]

    if (shell_use_toolkit_views) {
      sources += [
        "browser/shell_platform_delegate_views.cc",
        "browser/shell_web_contents_view_delegate_views.cc",
      ]
      deps += [
        "//ui/color:color_headers",
        "//ui/native_theme",
        "//ui/resources",
        "//ui/views:test_support",
        "//ui/views/controls/webview",
        "//ui/wm:test_support",
      ]
    } else {
      sources += [
        "browser/shell_platform_delegate_aura.cc",
        "browser/shell_web_contents_view_delegate_aura.cc",
      ]
    }
  } else {
    sources -= [
      "browser/shell_platform_data_aura.cc",
      "browser/shell_platform_data_aura.h",
    ]
  }

  if (is_chromeos_ash) {
    deps += [ "//chromeos/ash/components/dbus" ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/dbus/constants",
      "//chromeos/lacros/dbus",
    ]
  }

  if (is_linux || is_chromeos) {
    deps += [ "//build/config/freetype" ]
  }

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

grit("content_shell_resources_grit") {
  testonly = true

  # External code should depend on ":resources" instead.
  visibility = [ ":*" ]
  source = "shell_resources.grd"
  outputs = [
    "grit/shell_resources.h",
    "shell_resources.pak",
  ]
}

copy("copy_shell_resources") {
  testonly = true

  sources = [ "$target_gen_dir/shell_resources.pak" ]
  outputs = [ "$root_out_dir/shell_resources.pak" ]

  public_deps = [ ":content_shell_resources_grit" ]
}

group("resources") {
  testonly = true

  public_deps = [ ":copy_shell_resources" ]
}

repack("pak") {
  testonly = true

  sources = [
    "$root_gen_dir/base/tracing/protos/tracing_proto_resources.pak",
    "$root_gen_dir/components/ukm_resources.pak",
    "$root_gen_dir/content/attribution_internals_resources.pak",
    "$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
    "$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
    "$root_gen_dir/content/content_resources.pak",
    "$root_gen_dir/content/gpu_resources.pak",
    "$root_gen_dir/content/histograms_resources.pak",
    "$root_gen_dir/content/private_aggregation_internals_resources.pak",
    "$root_gen_dir/content/process_resources.pak",
    "$root_gen_dir/content/quota_internals_resources.pak",
    "$root_gen_dir/content/service_worker_resources.pak",
    "$root_gen_dir/content/shell/shell_resources.pak",
    "$root_gen_dir/content/test/web_ui_mojo_test_resources.pak",
    "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
    "$root_gen_dir/net/net_resources.pak",
    "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
    "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
    "$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
    "$root_gen_dir/third_party/blink/public/strings/blink_strings_en-US.pak",
    "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
    "$root_gen_dir/ui/resources/webui_resources.pak",
    "$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
    "$root_gen_dir/ui/strings/auto_image_annotation_strings_en-US.pak",
    "$root_gen_dir/ui/strings/ax_strings_en-US.pak",
    "$root_gen_dir/ui/strings/ui_strings_en-US.pak",
  ]

  deps = [
    ":resources",
    "//base/tracing/protos:chrome_track_event_resources",
    "//components/ukm/debug:resources",
    "//content:content_resources",
    "//content/browser/resources:resources",
    "//content/browser/resources/media:resources",
    "//content/browser/webrtc/resources",
    "//content/test:web_ui_mojo_test_resources",
    "//mojo/public/js:resources",
    "//net:net_resources",
    "//third_party/blink/public:devtools_inspector_resources",
    "//third_party/blink/public:resources",
    "//third_party/blink/public:scaled_resources_100_percent",
    "//third_party/blink/public/strings",
    "//ui/resources",
    "//ui/strings",
  ]

  if (enable_vr) {
    sources += [ "$root_gen_dir/content/webxr_internals_resources.pak" ]
  }

  if (!is_android && !is_ios) {
    deps += [ "//content/browser/tracing:resources" ]
    sources += [
      "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
      "$root_gen_dir/content/traces_internals_resources.pak",
    ]
  }

  if (is_ios) {
    sources += [
      "$root_gen_dir/device/bluetooth/strings/bluetooth_strings_en-US.pak",
      "${root_gen_dir}/components/strings/components_strings_en-US.pak",
    ]
    deps += [
      "//components/strings:components_strings",
      "//device/bluetooth/strings/",
    ]
  }

  if (shell_use_toolkit_views) {
    deps += [ "//ui/views/resources" ]
    sources +=
        [ "$root_gen_dir/ui/views/resources/views_resources_100_percent.pak" ]
  }
  if (!is_android && !is_fuchsia && !is_ios) {
    sources +=
        [ "$root_gen_dir/content/browser/devtools/devtools_resources.pak" ]
    deps += [ "//content/browser/devtools:devtools_resources" ]
  }
  output = "$root_out_dir/content_shell.pak"
}

if (is_android) {
  group("content_shell") {
    testonly = true
    deps = [ "//content/shell/android:content_shell_apk" ]
  }
} else if (is_mac) {
  tweak_info_plist("content_shell_plist") {
    testonly = true
    info_plist = "app/app-Info.plist"
    args = [
      "--scm=1",
      "--version",
      content_shell_version,
    ]
  }
  mac_app_bundle("content_shell") {
    testonly = true
    output_name = content_shell_product_name
    sources = [ "app/shell_main_mac.cc" ]
    defines = [ "SHELL_PRODUCT_NAME=\"$content_shell_product_name\"" ]

    # Must have minimal dependencies. In particular cannot depend on //base.
    # Depending on //base leads to loading //base twice (once in the exe, once
    # in the main framework).
    deps = [
      ":content_shell_framework_bundle_data",
      ":content_shell_resources_bundle_data",

      # Despite its path, this does not add a //base dependency, see comments in
      # the .cc file.
      "//base/allocator:early_zone_registration_apple",
      "//sandbox/mac:seatbelt",
    ]
    info_plist_target = ":content_shell_plist"
    data_deps = [ ":content_shell_app" ]

    if (is_component_build) {
      ldflags = [ "-Wl,-rpath,@executable_path/../Frameworks" ]
    }
  }
} else if (is_ios) {
  declare_args() {
    # The bundle identifier. Overriding this will affect the provisioning profile
    # used, and hence will affect the app's capabilities.
    ios_content_shell_bundle_identifier = shared_bundle_id_for_test_apps

    # Path to an entitlements file used in ios_content_shell. Can be overridden
    # to provide an alternative.
    ios_content_shell_entitlements_path =
        "//content/app/ios/appex/app.entitlements"
  }

  ios_app_bundle("content_shell") {
    info_plist = "app/ios/ios-app.plist"
    testonly = true

    sources = [ "app/ios/shell_main_trampoline.cc" ]

    deps = [
      ":content_process_bundle",
      ":content_shell_framework+link",
      ":gpu_process_bundle",
      ":network_process_bundle",
    ]
    bundle_deps = [
      ":content_shell_framework_resources",
      "app/ios/resources",
    ]
    entitlements_path = ios_content_shell_entitlements_path
    bundle_identifier = ios_content_shell_bundle_identifier
  }

  ios_framework_bundle("content_shell_framework") {
    testonly = true
    transparent = true

    output_name = "content_shell_framework"
    sources = [ "app/shell_main.cc" ]

    deps = [
      ":content_shell_app",
      ":content_shell_lib",
      "//content/app/ios/appex:child_process_bridge",
      "//content/public/app",
      "//content/public/common",
      "//third_party/icu:icudata",
    ]
    info_plist = "app/ios/ios-app.plist"
  }

  browserkit_extension("gpu_process") {
    testonly = true
    bundle_identifier = "$shared_bundle_id_for_test_apps.GPUProcess"
  }

  browserkit_extension("network_process") {
    testonly = true
    bundle_identifier = "$shared_bundle_id_for_test_apps.NetworkProcess"
  }

  browserkit_extension("content_process") {
    testonly = true
    bundle_identifier = "$shared_bundle_id_for_test_apps.ContentProcess"
  }
} else {
  executable("content_shell") {
    testonly = true

    sources = [ "app/shell_main.cc" ]

    if (is_win) {
      sources += [ "app/shell.rc" ]
    }

    defines = []

    deps = [
      ":content_shell_app",
      ":content_shell_lib",
      ":pak",
      "//build/win:default_exe_manifest",
      "//content/public/app",
      "//sandbox",
    ]

    data_deps = [
      ":pak",
      "//tools/v8_context_snapshot:v8_context_snapshot",
    ]

    if (is_win) {
      deps += [
        "//base",
        "//sandbox",
      ]
      if (win_console_app) {
        defines += [ "WIN_CONSOLE_APP" ]
      } else {
        # Set /SUBSYSTEM:WINDOWS unless a console build has been requested.
        configs -= [ "//build/config/win:console" ]
        configs += [ "//build/config/win:windowed" ]
      }

      # Limit pre-loaded modules to improve sandbox coverage in content_shell.
      configs += [ "//build/config/win:delayloads" ]

      # Increase the initial stack size. The default is 1MB, this is 8MB.
      # This matches the chrome.exe.
      ldflags = [ "/STACK:0x800000" ]
    }

    if (is_win) {
      data_deps +=
          [ "//third_party/crashpad/crashpad/handler:crashpad_handler" ]
    } else if (is_linux || is_chromeos) {
      data_deps += [ "//components/crash/core/app:chrome_crashpad_handler" ]
    }

    if ((is_linux || is_chromeos) && !is_component_build) {
      # Set rpath to find our own libfreetype even in a non-component build.
      configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
    }
  }

  if (is_fuchsia) {
    fuchsia_component("content_shell_component") {
      testonly = true
      manifest = "fuchsia/content_shell.cml"
      data_deps = [ ":content_shell" ]
      visibility = [ ":*" ]
    }

    fuchsia_package("content_shell_pkg") {
      testonly = true
      package_name = "content_shell"
      deps = [ ":content_shell_component" ]
    }

    fuchsia_package_installer("content_shell_fuchsia") {
      testonly = true
      visibility = [
        ":*",  # See https://crbug.com/1328459#c4.
        "//:*",
      ]
      package = ":content_shell_pkg"
      package_name = "content_shell"
    }
  }
}

if (is_apple) {
  bundle_data("content_shell_framework_resources") {
    testonly = true
    sources = [ "$root_out_dir/content_shell.pak" ]

    public_deps = [ ":pak" ]

    if (is_mac && icu_use_data_file) {
      sources += [ "$root_out_dir/icudtl.dat" ]
      deps = [ "//third_party/icu:icudata" ]
    }

    if (is_mac) {
      sources += [ "//ui/gl/resources/angle-metal/gpu_shader_cache.bin" ]
    }

    if (v8_use_external_startup_data) {
      public_deps += [ "//v8" ]
      if (use_v8_context_snapshot) {
        sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
        public_deps += [ "//tools/v8_context_snapshot" ]
      }
      if (!use_v8_context_snapshot || include_both_v8_snapshots) {
        sources += [ "$root_out_dir/snapshot_blob.bin" ]
      }
    }

    outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  }
}

if (is_mac) {
  if (enable_ppapi) {
    bundle_data("content_shell_framework_plugins") {
      sources = [
        "$root_out_dir/blink_deprecated_test_plugin.plugin",
        "$root_out_dir/blink_test_plugin.plugin",
      ]

      outputs = [ "{{bundle_contents_dir}}/{{source_file_part}}" ]

      public_deps = [
        "//ppapi:blink_deprecated_test_plugin",
        "//ppapi:blink_test_plugin",
      ]
    }
  }

  content_shell_framework_name = "$content_shell_product_name Framework"
  content_shell_helper_name = "$content_shell_product_name Helper"

  bundle_data("content_shell_framework_helpers") {
    testonly = true
    sources = [ "$root_out_dir/chrome_crashpad_handler" ]
    outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
    public_deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
    foreach(helper_params, content_mac_helpers) {
      sources += [
        "$root_out_dir/${content_shell_helper_name}${helper_params[2]}.app",
      ]
      public_deps += [ ":content_shell_helper_app_${helper_params[0]}" ]
    }
  }

  tweak_info_plist("content_shell_framework_plist") {
    testonly = true
    info_plist = "app/framework-Info.plist"
    args = [
      "--breakpad=0",
      "--keystone=0",
      "--scm=1",
      "--version",
      content_shell_version,
      "--branding",
      content_shell_product_name,
    ]
  }

  mac_framework_bundle("content_shell_framework") {
    testonly = true

    output_name = content_shell_framework_name

    framework_version = "C"

    framework_contents = [
      "Helpers",
      "Libraries",
      "Resources",
    ]

    sources = [
      "app/shell_content_main.cc",
      "app/shell_content_main.h",
    ]

    deps = [
      ":content_shell_angle_binaries",
      ":content_shell_app",
      "//content/public/app",
      "//content/public/common",
      "//third_party/icu:icudata",
    ]

    bundle_deps = [
      ":content_shell_framework_helpers",
      ":content_shell_framework_resources",
      ":content_shell_swiftshader_binaries",
    ]

    if (enable_ppapi) {
      deps += [ ":content_shell_framework_plugins" ]
    }

    if (!is_component_build) {
      # Specify a sensible install_name for static builds. The library is
      # dlopen()ed so this is not used to resolve the module.
      ldflags = [ "-Wl,-install_name,@executable_path/../Frameworks/$output_name.framework/$output_name" ]
      deps += [ "//base/test:test_trace_processor_bundle_data" ]
    } else {
      # Both the main :content_shell and :content_shell_helper_app executables
      # need to link the framework. Because they are at different directory
      # depths, using @executable_path as the install_name would require using
      # install_name_tool on one of the executables. However install_name_tool
      # only operates in-place, which is problematic to express in GN. Instead,
      # use rpath-based loading.
      ldflags =
          [ "-Wl,-install_name,@rpath/$output_name.framework/$output_name" ]

      # Set up the rpath for the framework so that it can find dylibs in the
      # root output directory. The framework is at
      # Content Shell.app/Contents/Frameworks/Content Shell Framework.framework/Versions/C/Content Shell Framework
      # so use loader_path to go back to the root output directory.
      ldflags += [ "-Wl,-rpath,@loader_path/../../../../../.." ]
    }

    info_plist_target = ":content_shell_framework_plist"
  }

  tweak_info_plist("content_shell_helper_plist") {
    testonly = true
    info_plist = "app/helper-Info.plist"
    args = [
      "--breakpad=0",
      "--keystone=0",
      "--scm=0",
      "--version",
      content_shell_version,
    ]
  }

  template("content_shell_helper_app") {
    mac_app_bundle(target_name) {
      assert(defined(invoker.helper_name_suffix))
      assert(defined(invoker.helper_bundle_id_suffix))

      testonly = true

      output_name = content_shell_helper_name + invoker.helper_name_suffix

      sources = [ "app/shell_main_mac.cc" ]
      defines = [
        "HELPER_EXECUTABLE",
        "SHELL_PRODUCT_NAME=\"$content_shell_product_name\"",
      ]
      extra_substitutions = [
        "CONTENT_SHELL_HELPER_SUFFIX=${invoker.helper_name_suffix}",
        "CONTENT_SHELL_HELPER_BUNDLE_ID_SUFFIX=${invoker.helper_bundle_id_suffix}",
      ]
      deps = [
        "//base/allocator:early_zone_registration_apple",
        "//sandbox/mac:seatbelt",
      ]

      info_plist_target = ":content_shell_helper_plist"

      if (is_component_build) {
        ldflags = [
          # The helper is in Content Shell.app/Contents/Frameworks/
          #     Content Shell Framework.framework/Versions/C/Helpers/
          #     Content Shell Helper.app/Contents/MacOS/
          # so set rpath up to the base.
          "-Wl,-rpath,@executable_path/../../../../../../../../../..",

          # ... and up to Contents/Frameworks.
          "-Wl,-rpath,@executable_path/../../../../../../..",
        ]

        # In a component build, the framework is directly linked to the
        # executable because dlopen() and loading all the dependent dylibs
        # is time-consuming, see https://crbug.com/1197495.
        deps += [ ":content_shell_framework+link_nested" ]
      }
    }
  }

  foreach(helper_params, content_mac_helpers) {
    _helper_target = helper_params[0]
    _helper_bundle_id = helper_params[1]
    _helper_suffix = helper_params[2]
    content_shell_helper_app("content_shell_helper_app_${_helper_target}") {
      helper_name_suffix = _helper_suffix
      helper_bundle_id_suffix = _helper_bundle_id
    }
  }

  bundle_data("content_shell_framework_bundle_data") {
    testonly = true
    sources = [ "$root_out_dir/$content_shell_framework_name.framework" ]
    outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
    if (is_component_build) {
      # In a component build, the framework is directly linked to the
      # executable because dlopen() and loading all the dependent dylibs
      # is time-consuming, see https://crbug.com/1197495.
      public_deps = [ ":content_shell_framework+link" ]
    } else {
      public_deps = [ ":content_shell_framework" ]
    }
  }

  bundle_data("content_shell_resources_bundle_data") {
    testonly = true
    sources = [ "app/app.icns" ]
    outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  }

  # Add the ANGLE .dylibs in the Libraries directory of the Framework.
  bundle_data("content_shell_angle_binaries") {
    sources = [
      "$root_out_dir/egl_intermediates/libEGL.dylib",
      "$root_out_dir/egl_intermediates/libGLESv2.dylib",
    ]
    outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
    public_deps = [ "//ui/gl:angle_library_copy" ]
  }

  # Add the SwiftShader .dylibs in the Libraries directory of the Framework.
  bundle_data("content_shell_swiftshader_binaries") {
    sources = [
      "$root_out_dir/vk_intermediates/libvk_swiftshader.dylib",
      "$root_out_dir/vk_intermediates/vk_swiftshader_icd.json",
    ]
    outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
    public_deps = [ "//ui/gl:swiftshader_vk_library_copy" ]
  }
}

mojom("content_browsertests_mojom") {
  sources = [
    "common/main_frame_counter_test.mojom",
    "common/power_monitor_test.mojom",
    "common/render_frame_test_helper.mojom",
  ]
  public_deps = [
    "//sandbox/policy/mojom",
    "//third_party/blink/public/mojom/tokens",
  ]
}

group("content_shell_crash_test") {
  testonly = true
  data_deps = [
    ":content_shell",
    "//testing:test_scripts_shared",
    "//third_party/angle:includes",
  ]
  data = [
    "//content/shell/tools/breakpad_integration_test.py",
    "//testing/scripts/content_shell_crash_test.py",
  ]
  if (is_mac && !use_system_xcode) {
    data += [
      # Scripts call otool, which calls either llvm-otool or otool-classic,
      # so we need all three.
      # llvm-otool shells out to llvm-objdump, so that's needed as well.
      mac_bin_path + "llvm-objdump",
      mac_bin_path + "llvm-otool",
      mac_bin_path + "otool",
      mac_bin_path + "otool-classic",
    ]
  }
  if (is_posix) {
    data += [
      "//components/crash/content/tools/generate_breakpad_symbols.py",
      "//components/crash/content/tools/dmp2minidump.py",
    ]
  }
  if (is_win) {
    data_deps += [ "//build/win:copy_cdb_to_output" ]
  }
  if (is_posix) {
    data_deps += [
      "//third_party/breakpad:dump_syms",
      "//third_party/breakpad:minidump_stackwalk",
    ]
  }
  if (is_android) {
    data_deps += [
      "//build/android:devil_chromium_py",
      "//build/android:test_runner_py",
      "//third_party/breakpad:microdump_stackwalk",
      "//third_party/breakpad:minidump_dump",
      "//third_party/breakpad:symupload",
      "//tools/android/forwarder2",
    ]
  }
}

mojom("shell_controller_mojom") {
  testonly = true
  sources = [ "common/shell_controller.test-mojom" ]
  public_deps = [ "//mojo/public/mojom/base" ]
}