# 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/buildflag_header.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/util/process_version.gni")
import("//chrome/browser/downgrade/buildflags.gni")
import("//chrome/common/features.gni")
import("//components/nacl/features.gni")
import("//components/offline_pages/buildflags/features.gni")
import("//components/signin/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/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)
assert(!is_fuchsia, "Fuchsia shouldn't use anything in //chrome")
declare_args() {
enable_android_site_isolation = is_desktop_android
}
fuzzer_test("ini_parser_fuzzer") {
sources = [ "ini_parser_fuzzer.cc" ]
deps = [
"//base",
"//chrome/common:ini_parser",
]
# Large ini files can cause test cases to timeout
libfuzzer_options = [ "max_len=100000" ]
}
grit("resources") {
source = "common_resources.grd"
defines = chrome_grit_defines
output_dir = "$root_gen_dir/chrome"
output_name = "common_resources"
outputs = [
"grit/common_resources.h",
"common_resources.pak",
]
}
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"CHROME_ENABLE_LOGGING_BY_DEFAULT=$chrome_enable_logging_by_default",
"CHROME_ROOT_STORE_CERT_MANAGEMENT_UI=$chrome_root_store_cert_management_ui",
"ENABLE_ANDROID_SITE_ISOLATION=$enable_android_site_isolation",
"ENABLE_BACKGROUND_MODE=$enable_background_mode",
"ENABLE_BACKGROUND_CONTENTS=$enable_background_contents",
"ENABLE_CHROME_NOTIFICATIONS=$enable_chrome_notifications",
"ENABLE_DOWNGRADE_PROCESSING=$enable_downgrade_processing",
"ENABLE_HANGOUT_SERVICES_EXTENSION=$enable_hangout_services_extension",
"ENABLE_SERVICE_DISCOVERY=$enable_service_discovery",
"ENABLE_SESSION_SERVICE=$enable_session_service",
"ENABLE_WEBUI_CERTIFICATE_VIEWER=$enable_webui_certificate_viewer",
"ENABLE_WEBUI_TAB_STRIP=$enable_webui_tab_strip",
"OPTIMIZE_WEBUI=$optimize_webui",
]
}
source_set("channel_info") {
sources = [
"channel_info.cc",
"channel_info.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
"//build:branding_buildflags",
"//build:chromeos_buildflags",
]
public_deps = [
"//base",
"//components/version_info",
"//components/version_info:version_string",
]
if (is_win) {
sources += [ "channel_info_win.cc" ]
public_deps += [ "//chrome/install_static:install_static_util" ]
} else if (is_mac) {
sources += [ "channel_info_mac.mm" ]
} else if (is_android) {
sources += [ "channel_info_android.cc" ]
public_deps += [ "//components/version_info/android:channel_getter" ]
} else if (is_chromeos_ash) {
sources += [ "channel_info_chromeos.cc" ]
deps += [ "//chromeos/ash/components/channel" ]
} else if (is_chromeos_lacros) {
sources += [ "channel_info_lacros.cc" ]
} else if (is_posix) {
sources += [ "channel_info_posix.cc" ]
}
}
source_set("ini_parser") {
sources = [
"ini_parser.cc",
"ini_parser.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [ "//base" ]
}
group("common") {
public_deps = [ ":common_lib" ]
if (is_win) {
public_deps += [ "//chrome/common/win:delay_load_hooks" ]
}
}
source_set("request_code_constants") {
sources = [ "chrome_resource_request_blocked_reason.h" ]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [ "//content/public/common" ]
}
# Use a static library here because many test binaries depend on this but don't
# require many files from it. This makes linking more efficient.
static_library("common_lib") {
visibility = [
":*",
"//chrome/common/win:eventlog_messages",
]
sources = [
"all_messages.h",
"child_process_logging.h",
"chrome_content_client.cc",
"chrome_content_client.h",
"chrome_content_client_constants.cc",
"chrome_descriptors.h",
"chrome_isolated_world_ids.h",
"chrome_result_codes.cc",
"chrome_result_codes.h",
"common_message_generator.cc",
"common_message_generator.h",
"content_restriction.h",
"crash_keys.cc",
"crash_keys.h",
"google_url_loader_throttle.cc",
"google_url_loader_throttle.h",
"logging_chrome.cc",
"logging_chrome.h",
"media/cdm_registration.cc",
"media/cdm_registration.h",
"media/media_resource_provider.cc",
"media/media_resource_provider.h",
"media_galleries/metadata_types.h",
"pdf_util.cc",
"pdf_util.h",
"pref_names_util.cc",
"pref_names_util.h",
"ref_counted_util.h",
"search/instant_mojom_traits.h",
"search/instant_types.cc",
"search/instant_types.h",
"search/ntp_logging_events.h",
"secure_origin_allowlist.cc",
"secure_origin_allowlist.h",
"webui_util.cc",
"webui_util.h",
]
defines = []
configs += [
"//build/config:precompiled_headers",
"//build/config/compiler:wexit_time_destructors",
]
public_deps = [
":available_offline_content_mojom",
":buildflags",
":channel_info",
":ini_parser",
":mojo_bindings",
":offline_page_auto_fetcher_mojom",
":request_code_constants",
":supervised_user_commands_mojom",
":url_constants",
"//base",
"//base:base_static",
"//base:i18n",
"//chrome:resources",
"//chrome:strings",
"//chrome/app/theme:theme_resources",
"//chrome/common:constants",
"//chrome/common/net",
"//chrome/common/privacy_budget",
"//chrome/common/profiler",
"//chrome/common/search:mojo_bindings",
"//chrome/installer/util:with_no_strings",
"//components/client_hints/common",
"//components/cloud_devices/common",
"//components/component_updater",
"//components/content_settings/core/common",
"//components/crash/core/common",
"//components/device_signals/core/common:features",
"//components/dom_distiller/core",
"//components/embedder_support/origin_trials",
"//components/error_page/common",
"//components/favicon_base",
"//components/flags_ui:switches",
"//components/gcm_driver/common",
"//components/language_detection/content/common",
"//components/metrics",
"//components/metrics:net",
"//components/nacl/common:buildflags",
"//components/nacl/common:process_type",
"//components/nacl/common:switches",
"//components/net_log",
"//components/network_session_configurator/common",
"//components/ntp_tiles",
"//components/offline_pages/buildflags",
"//components/offline_pages/core:switches",
"//components/omnibox/common",
"//components/page_load_metrics/common:page_load_metrics_mojom",
"//components/password_manager/core/common",
"//components/policy:generated",
"//components/policy/core/common",
"//components/prefs",
"//components/safe_browsing:buildflags",
"//components/safe_search_api",
"//components/services/app_service",
"//components/services/heap_profiling/public/cpp",
"//components/strings",
"//components/supervised_user/core/common",
"//components/translate/content/common",
"//components/translate/core/common",
"//components/url_formatter",
"//components/variations",
"//components/variations/net",
"//components/visitedlink/common",
"//google_apis",
"//gpu/command_buffer/service",
"//gpu/config",
"//ipc",
"//media",
"//mojo/public/cpp/bindings",
"//pdf:buildflags",
"//ppapi/buildflags",
"//sandbox/policy",
"//skia",
"//third_party/icu",
"//third_party/re2",
"//third_party/widevine/cdm:buildflags",
"//ui/accessibility",
"//ui/base",
"//ui/gfx/ipc",
"//ui/gfx/ipc/geometry",
"//ui/gfx/ipc/skia",
"//ui/gl",
"//ui/message_center/public/cpp",
"//ui/native_theme",
"//ui/resources:resources",
"//url",
]
deps = [
"//build:chromeos_buildflags",
"//components/crash/core/app",
"//components/google/core/common",
"//components/heap_profiling/in_process",
"//components/heap_profiling/in_process:mojom",
"//components/live_caption:constants",
"//components/metrics:call_stack_profile_builder",
"//components/no_state_prefetch/common",
"//components/no_state_prefetch/common:mojo_bindings",
"//components/page_load_metrics/common:common",
"//components/pdf/common:constants",
]
if (is_android || enable_library_cdms) {
public_deps += [ "//components/cdm/common" ]
}
if (enable_ppapi) {
public_deps += [ "//ppapi/shared_impl" ]
}
if (enable_extensions_core) {
public_deps += [
"//chrome/common/extensions",
"//extensions/common",
"//extensions/common:common_constants",
"//extensions/common:core_api_provider",
]
sources += [
"initialize_extensions_client.cc",
"initialize_extensions_client.h",
]
# TODO(https://crbug.com/356905053): Gradually include more of these sources
# in the desktop-android build (taking them out of this enable_extensions
# block), or put them behind more specific build flags.
if (enable_extensions) {
sources += [
"controlled_frame/controlled_frame.cc",
"controlled_frame/controlled_frame.h",
]
deps += [
"//chrome/common/apps/platform_apps",
"//chrome/common/controlled_frame",
"//components/app_constants",
]
public_deps += [
"//chrome/common/extensions/api",
"//chrome/common/extensions/api:extensions_features",
"//extensions:extensions_resources",
"//extensions/common/api",
"//extensions/strings",
"//services/device/public/cpp/usb",
]
} # if (enable_extensions)
}
if (is_mac) {
assert(enable_extensions)
sources += [
"extensions/image_writer/image_writer_util_mac.cc",
"extensions/image_writer/image_writer_util_mac.h",
]
public_deps += [ ":app_mode_app_support" ]
}
if (is_chromeos_ash) {
assert(enable_extensions)
public_deps += [ "//ash/keyboard/ui" ]
deps += [ "//ash/constants" ]
} else if (is_chromeos_lacros) {
deps += [ "//chromeos/startup" ]
}
if (is_chromeos) {
deps += [ "//chrome/common/chromeos/extensions" ]
}
if (enable_nacl) {
public_deps += [ "//components/nacl/common" ]
}
# Printing.
if (enable_printing) {
public_deps += [
"//components/printing/common",
"//printing",
]
}
if (is_android) {
sources -= [ "media_galleries/metadata_types.h" ]
sources += [
"media/chrome_media_drm_bridge_client.cc",
"media/chrome_media_drm_bridge_client.h",
]
} else {
# Non-Android.
public_deps += [ "//chrome/common/importer" ]
sources += [
"accessibility/read_anything_constants.cc",
"accessibility/read_anything_constants.h",
]
}
if (is_win) {
sources += [
"child_process_logging_win.cc",
"conflicts/module_watcher_win.cc",
"conflicts/module_watcher_win.h",
"conflicts/remote_module_watcher_win.cc",
"conflicts/remote_module_watcher_win.h",
]
deps += [
"//chrome/chrome_elf:chrome_elf_main_include",
"//chrome/common/win:eventlog_messages",
"//components/crash/core/app:crash_export_thunk_include",
]
public_deps += [
"//components/dom_distiller/core", # Needed by chrome_content_client.cc.
"//third_party/wtl",
]
libs = [ "wintrust.lib" ]
}
if (is_posix && !is_android) {
sources += [
"process_singleton_lock_posix.cc",
"process_singleton_lock_posix.h",
]
}
if (is_mac) {
public_deps += [ "//third_party/google_toolbox_for_mac" ]
frameworks = [ "ServiceManagement.framework" ]
}
if (enable_plugins) {
sources += [
"ppapi_utils.cc",
"ppapi_utils.h",
]
}
if (enable_plugins && enable_extensions) {
sources += [
"pepper_permission_util.cc",
"pepper_permission_util.h",
]
}
if (enable_library_cdms) {
deps += [ "//media/cdm:cdm_paths" ] # Needed by chrome_content_client.cc
if (enable_widevine) {
if (is_linux || is_chromeos) {
sources += [
"media/component_widevine_cdm_hint_file_linux.cc",
"media/component_widevine_cdm_hint_file_linux.h",
]
}
deps += [ "//third_party/widevine/cdm:headers" ]
}
}
if (safe_browsing_mode != 0) {
public_deps += [ "//chrome/common/safe_browsing" ]
}
if (is_linux || is_chromeos) {
sources += [
"auto_start_linux.cc",
"auto_start_linux.h",
]
deps += [ "//sandbox/linux:sandbox_services" ]
}
if (enable_cdm_host_verification) {
sources += [
"media/cdm_host_file_path.cc",
"media/cdm_host_file_path.h",
]
public_deps += [ "//chrome/common:version_header" ]
}
if (enable_bound_session_credentials) {
sources += [ "bound_session_request_throttled_handler.h" ]
}
}
process_version("version_header") {
# TODO(brettw) this should have more reduced visibility, but chrome/browser
# currently depends on this.
#visibility = [ ":*" ]
sources = [
"//chrome/VERSION",
branding_file_path,
]
template_file = "chrome_version.h.in"
output = "$target_gen_dir/chrome_version.h"
}
# Separate out the constants that aren't intermingled with or dependent on code
# so that they can be used without adding any binary bloat.
static_library("non_code_constants") {
sources = [
"chrome_constants.cc",
"chrome_constants.h",
"chrome_switches.cc",
"chrome_switches.h",
"env_vars.cc",
"env_vars.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
":buildflags",
":version_header",
"//base",
"//build:chromeos_buildflags",
"//ppapi/buildflags",
]
public_deps = [
"//build:branding_buildflags",
"//printing/buildflags",
"//ui/base:buildflags",
]
if (is_win) {
sources += [ "chrome_icon_resources_win.h" ]
}
}
component("chrome_features") {
defines = [ "IS_CHROME_FEATURES_IMPL" ]
sources = [
"chrome_features.cc",
"chrome_features.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
":buildflags",
":non_code_constants",
"//base",
"//build:chromeos_buildflags",
"//components/offline_pages/buildflags",
"//device/vr/buildflags",
"//extensions/buildflags",
"//media:media_buildflags",
"//net:buildflags",
"//ppapi/buildflags",
"//printing/buildflags",
"//rlz/buildflags",
]
public_deps = [ "//ui/base:buildflags" ]
}
static_library("url_constants") {
visibility = [ "//chrome/common/*" ]
sources = [
"url_constants.h",
"webui_url_constants.cc",
"webui_url_constants.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [
":buildflags",
"//build:branding_buildflags",
"//build/config/chromebox_for_meetings:buildflags",
"//components/signin/public/base:signin_buildflags",
"//components/supervised_user/core/common:buildflags",
"//content/public/common",
"//extensions/buildflags",
"//net:buildflags",
"//printing/buildflags",
]
deps = [
"//components/commerce/core:commerce_constants",
"//components/history_clusters/history_clusters_internals/webui:constants",
"//components/lens:buildflags",
"//components/nacl/common:buildflags",
"//components/optimization_guide/optimization_guide_internals/webui:url_constants",
"//components/password_manager/content/common",
"//components/safe_browsing/core/common",
"//device/vr/buildflags",
]
}
static_library("constants") {
sources = [
"chrome_paths.cc",
"chrome_paths.h",
"chrome_paths_internal.h",
"chrome_result_codes.h",
"pref_font_script_names-inl.h",
"pref_font_webkit_names.h",
"pref_names.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [
":buildflags",
":chrome_features",
":non_code_constants",
"//components/compose:buildflags",
"//components/signin/public/base:signin_buildflags",
"//content/public/common:result_codes",
"//rlz/buildflags",
"//third_party/widevine/cdm:buildflags",
]
deps = [
":version_header",
"//base",
"//build:branding_buildflags",
"//build:chromeos_buildflags",
"//components/bookmarks/common",
"//components/nacl/common:switches",
"//components/offline_pages/buildflags",
"//components/policy/core/common:policy_path_constants",
"//extensions/buildflags",
"//media:media_buildflags",
"//ppapi/buildflags",
"//printing/buildflags",
"//third_party/widevine/cdm:buildflags",
]
if (is_android) {
sources += [ "chrome_paths_android.cc" ]
# This dependency must only be added for Android.
#
# On Windows, //chrome/installer/util depends on this target to get
# constants. That target is in turn used in a number of installer helper
# targets independent of Chrome that we want to keep small. So we don't
# want something large like //ui/base.
#
# Android doesn't have this structure and corresponding size limitation
# on this target. On that platform one of the Chrome paths forwards to one
# implemented in //ui/base, so we need that dependency.
deps += [ "//ui/base" ]
}
if (is_chromeos_lacros) {
sources += [
"chrome_paths_lacros.cc",
"chrome_paths_lacros.h",
]
deps += [
"//chromeos/crosapi/cpp:crosapi_constants",
"//chromeos/lacros:lacros_paths",
"//chromeos/startup",
]
public_deps += [ "//chromeos/crosapi/mojom" ]
} else if (is_linux || is_chromeos) {
sources += [ "chrome_paths_linux.cc" ]
deps += [ ":channel_info" ]
}
if (is_mac) {
sources += [ "chrome_paths_mac.mm" ]
}
if (is_win) {
sources += [ "chrome_paths_win.cc" ]
deps += [ "//chrome/install_static:install_static_util" ]
}
if (enable_widevine && enable_library_cdms) {
deps += [
"//media/cdm:cdm_paths", # Needed by chrome_paths.cc.
"//third_party/widevine/cdm:headers",
]
}
}
# Use a static library here because many test binaries depend on this but don't
# require many files from it. This makes linking more efficient.
static_library("test_support") {
testonly = true
visibility = [ "//chrome/test:*" ]
sources = [
"search/mock_embedded_search_client.cc",
"search/mock_embedded_search_client.h",
]
deps = [
":common",
"//base",
"//chrome/common/search:mojo_bindings",
"//testing/gmock",
"//testing/gtest",
]
if (enable_extensions) {
sources += [
"extensions/extension_test_util.cc",
"extensions/extension_test_util.h",
]
deps += [ "//chrome/common/extensions:test_features" ]
}
}
if (is_mac) {
source_set("app_mode_app_support") {
sources = [
"mac/app_mode_chrome_locator.h",
"mac/app_mode_chrome_locator.mm",
"mac/app_mode_common.h",
"mac/app_mode_common.mm",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
":constants",
"//components/version_info",
"//mojo/core/embedder",
]
public_deps = [ "//base" ]
}
}
mojom("mojo_bindings") {
disable_variants = true
sources = [
"chrome_render_frame.mojom",
"google_accounts_private_api_extension.mojom",
"media/webrtc_logging.mojom",
"metrics.mojom",
"net/net_error_page_support.mojom",
"net_benchmarking.mojom",
"network_diagnostics.mojom",
"network_easter_egg.mojom",
"open_search_description_document_handler.mojom",
"plugin.mojom",
"privacy_budget/identifiability_study_configurator.mojom",
"renderer_configuration.mojom",
"trusted_vault_encryption_keys_extension.mojom",
]
deps = [ "//components/lens:lens_mojo" ]
if (is_android) {
sources += [ "sandbox_status_extension_android.mojom" ]
}
if (is_mac) {
sources += [ "mac/app_shim.mojom" ]
deps +=
[ "//components/metrics/public/mojom:histogram_fetcher_mojo_bindings" ]
cpp_typemaps = [
{
types = [
{
mojom = "chrome.mojom.FeatureState"
cpp = "::variations::VariationsCommandLine"
move_only = true
},
]
traits_headers = [ "mac/app_shim_mojom_traits.h" ]
traits_sources = [ "mac/app_shim_mojom_traits.cc" ]
traits_public_deps = [ "//components/variations/net" ]
},
]
}
if (is_win) {
sources += [
"conflicts/module_event_sink_win.mojom",
"font_prewarmer.mojom",
]
}
public_deps = [
"//components/content_settings/common:mojom",
"//components/content_settings/core/common:mojo_bindings",
"//components/no_state_prefetch/common:mojo_bindings",
"//content/public/common:interfaces",
"//mojo/public/mojom/base",
"//third_party/blink/public/mojom:mojom_core",
"//third_party/blink/public/mojom:mojom_platform",
"//ui/gfx/geometry/mojom",
"//ui/gfx/image/mojom",
"//url/mojom:url_mojom_gurl",
"//url/mojom:url_mojom_origin",
]
if (is_mac) {
public_deps += [
"//chrome/services/mac_notifications/public/mojom",
"//components/remote_cocoa/common:mojo",
]
}
if (safe_browsing_mode == 1) {
public_deps += [ "//chrome/services/file_util/public/mojom" ]
}
overridden_deps = [
"//content/public/common:interfaces",
"//third_party/blink/public/mojom:mojom_core",
"//third_party/blink/public/mojom:mojom_platform",
]
component_deps = [ "//content/public/common" ]
enabled_features = []
if (enable_offline_pages) {
sources += [ "mhtml_page_notifier.mojom" ]
deps += [ "//third_party/blink/public/mojom:mojom_mhtml_load_result" ]
enabled_features += [ "enable_offline_pages" ]
}
if (enable_plugins) {
enabled_features += [ "enable_plugins" ]
}
if (enable_bound_session_credentials) {
enabled_features += [ "enable_bound_session_credentials" ]
}
}
mojom("supervised_user_commands_mojom") {
sources = [ "supervised_user_commands.mojom" ]
}
mojom("available_offline_content_mojom") {
sources = [ "available_offline_content.mojom" ]
public_deps = [ "//url/mojom:url_mojom_gurl" ]
}
mojom("offline_page_auto_fetcher_mojom") {
sources = [ "offline_page_auto_fetcher.mojom" ]
public_deps = [ "//url/mojom:url_mojom_gurl" ]
}