chromium/ios/chrome/app/BUILD.gn

# Copyright 2015 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/apple/compile_entitlements.gni")
import("//build/apple/tweak_info_plist.gni")
import("//build/buildflag_header.gni")
import("//build/config/ios/config.gni")
import("//build/config/ios/ios_sdk.gni")
import("//build/config/ios/rules.gni")
import("//build/ios/extension_bundle_data.gni")
import("//ios/build/chrome_build.gni")
import("//ios/build/config.gni")
import("//ios/chrome/app/chrome_app.gni")
import("//ios/chrome/features.gni")
import("//ios/features.gni")
import("//ios/public/provider/chrome/browser/build_config.gni")

declare_args() {
  # Controls whether fast_app_terminate_buildflags is enabled
  # (see crbug.com/1328891 for details).
  fast_app_terminate_enabled = -1

  # Path to a PrivacyInfo.xcprivacy file to be included in the application.
  ios_chrome_privacy_manifest = ""

  # Path to an orderfile to be used when building the application binary.
  ios_chrome_orderfile = ""
}

# If fast_app_terminate_enabled is not enabled, default to true,
# except in debug mode (as this makes it difficult to debug the
# app termination crashes).
if (fast_app_terminate_enabled == -1) {
  fast_app_terminate_enabled = !is_debug
}

buildflag_header("background_mode_buildflags") {
  header = "background_mode_buildflags.h"
  flags = [ "IOS_BACKGROUND_MODE_ENABLED=$ios_enable_background_mode" ]
}

buildflag_header("fast_app_terminate_buildflags") {
  header = "fast_app_terminate_buildflags.h"
  flags = [ "FAST_APP_TERMINATE_ENABLED=$fast_app_terminate_enabled" ]
}

source_set("app") {
  sources = [
    "app_startup_parameters.h",
    "app_startup_parameters.mm",
    "deferred_initialization_runner.h",
    "deferred_initialization_runner.mm",
  ]

  deps = [
    "//base",
    "//ios/chrome/browser/shared/model/url:constants",
    "//ios/chrome/browser/shared/public/features",
    "//net",
    "//url",
  ]

  frameworks = [ "Foundation.framework" ]
}

source_set("app_trampoline") {
  sources = [ "chrome_exe_trampoline.mm" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "app_metrics_app_state_agent_unittest.mm",
    "deferred_initialization_runner_unittest.mm",
    "post_restore_app_agent_unittest.mm",
    "safe_mode_app_state_agent_unittest.mm",
    "tab_opener_unittest.mm",
    "variations_app_state_agent_unittest.mm",
  ]
  deps = [
    ":app",
    ":app_internal",
    ":app_metrics_app_state_agent",
    ":post_restore_app_agent",
    ":safe_mode_app_state_agent",
    ":variations_app_state_agent",
    "//base",
    "//base/test:test_support",
    "//components/bookmarks/test",
    "//components/metrics",
    "//components/open_from_clipboard",
    "//components/open_from_clipboard:test_support",
    "//components/prefs",
    "//components/prefs:test_support",
    "//components/sync_preferences:sync_preferences",
    "//components/sync_preferences:test_support",
    "//components/variations",
    "//components/variations/service",
    "//ios/chrome/app:enterprise_app_agent",
    "//ios/chrome/app/application_delegate",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/app/application_delegate:tab_opening",
    "//ios/chrome/app/application_delegate:test_support",
    "//ios/chrome/app/application_delegate:url_opener_params",
    "//ios/chrome/browser/bookmarks/model",
    "//ios/chrome/browser/bookmarks/model:test_support",
    "//ios/chrome/browser/browsing_data/model",
    "//ios/chrome/browser/first_run/ui_bundled:constants",
    "//ios/chrome/browser/metrics/model",
    "//ios/chrome/browser/promos_manager/model",
    "//ios/chrome/browser/promos_manager/model:constants",
    "//ios/chrome/browser/promos_manager/model:test_support",
    "//ios/chrome/browser/reading_list/model",
    "//ios/chrome/browser/reading_list/model:test_support",
    "//ios/chrome/browser/safe_mode/ui_bundled",
    "//ios/chrome/browser/sessions/model",
    "//ios/chrome/browser/sessions/model:fake",
    "//ios/chrome/browser/shared/coordinator/scene",
    "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
    "//ios/chrome/browser/shared/coordinator/scene:scene_testing",
    "//ios/chrome/browser/shared/coordinator/scene/test",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser/test:test_support",
    "//ios/chrome/browser/shared/model/prefs:browser_prefs",
    "//ios/chrome/browser/shared/model/prefs:pref_names",
    "//ios/chrome/browser/shared/model/profile/test",
    "//ios/chrome/browser/signin/model",
    "//ios/chrome/browser/signin/model:fake_system_identity",
    "//ios/chrome/browser/signin/model:fake_system_identity_manager",
    "//ios/chrome/browser/signin/model:signin_util",
    "//ios/chrome/browser/signin/model:test_support",
    "//ios/chrome/browser/tabs/model",
    "//ios/chrome/browser/ui/main",
    "//ios/chrome/browser/variations/model:fetcher",
    "//ios/chrome/browser/web_state_list/model/web_usage_enabler",
    "//ios/chrome/common/app_group",
    "//ios/chrome/test:test_support",
    "//ios/public/provider/chrome/browser/app_distribution:app_distribution_api",
    "//ios/testing:block_swizzler",
    "//ios/third_party/material_components_ios",
    "//ios/web/public/test:test",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/ocmock",
    "//url",
  ]
}

source_set("tests_hook") {
  # This target is intentionally not test-only, as the main app depends on it.
  sources = [ "tests_hook.h" ]
  deps = [ "//ios/chrome/browser/shared/model/profile" ]
}

source_set("tests_fake_hook") {
  # This target is intentionally not test-only, as the main app depends on it.
  sources = [ "tests_fake_hook.mm" ]
  deps = [
    ":tests_hook",
    "//components/signin/internal/identity_manager",
  ]
}

source_set("perf_tests_hook") {
  sources = [ "perf_tests_hook.mm" ]
  deps = [
    ":tests_hook",
    "//components/signin/internal/identity_manager",
    "//ios/public/provider/chrome/browser/primes:primes_api",
  ]
}

tweak_info_plist("info_plist") {
  info_plists = [
    "resources/Info.plist",
    "resources/ChromeAddition+Info.plist",
  ]
  if (ios_enable_background_mode) {
    info_plists += [ "resources/Background+Info.plist" ]
  }
  if (target_environment == "catalyst") {
    info_plists += [ "resources/Environment+Catalyst.plist" ]
  } else {
    info_plists += [ "resources/Environment+Default.plist" ]
  }
  if (ios_chrome_info_plist_additions != []) {
    info_plists += ios_chrome_info_plist_additions
  }
  if (ios_encryption_export_compliance_code != "") {
    info_plists += [ "resources/EncryptionExportCompliance+Info.plist" ]
  }
  if (ios_chrome_info_plist_addition_targets != []) {
    if (!defined(deps)) {
      deps = []
    }
    deps += ios_chrome_info_plist_addition_targets
  }
  args = [
    "--branding=$chromium_short_name",
    "--add-gtm-metadata=1",
  ]
}

compile_entitlements("entitlements") {
  entitlements_templates = [ "resources/Chrome.entitlements" ]
  if (ios_chrome_entitlements_additions != []) {
    entitlements_templates += ios_chrome_entitlements_additions
  }
  if (target_environment == "catalyst") {
    entitlements_templates += [ "resources/Environment+Catalyst.entitlements" ]
  }
  if (use_blink) {
    entitlements_templates += [ "//content/app/ios/appex/app.entitlements" ]
  }
  substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
  output_name = "$target_gen_dir/$chromium_short_name.entitlements"
}

if (ios_enable_credential_provider_extension) {
  source_set("credential_provider_migrator_app_agent") {
    sources = [
      "credential_provider_migrator_app_agent.h",
      "credential_provider_migrator_app_agent.mm",
    ]
    deps = [
      "//components/keyed_service/core",
      "//ios/chrome/app/application_delegate:app_state_header",
      "//ios/chrome/app/application_delegate:observing_app_state_agent",
      "//ios/chrome/browser/credential_provider/model",
      "//ios/chrome/browser/passwords/model:store_factory",
      "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
      "//ios/chrome/browser/shared/model/application_context",
      "//ios/chrome/browser/shared/model/browser_state",
      "//ios/chrome/browser/shared/model/profile",
      "//ios/chrome/browser/sync/model",
      "//ios/chrome/browser/webauthn/model",
      "//ios/chrome/common/app_group",
      "//ios/chrome/common/credential_provider",
    ]
  }
}

source_set("app_metrics_app_state_agent") {
  sources = [
    "app_metrics_app_state_agent.h",
    "app_metrics_app_state_agent.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/app",
    "//ios/chrome/app:tests_hook",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/app/application_delegate:observing_app_state_agent",
    "//ios/chrome/browser/metrics/model",
    "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/model/profile",
    "//ios/public/provider/chrome/browser/primes:primes_api",
  ]
}

source_set("safe_mode_app_state_agent") {
  sources = [
    "safe_mode_app_state_agent+private.h",
    "safe_mode_app_state_agent.h",
    "safe_mode_app_state_agent.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/browser/safe_mode/ui_bundled",
    "//ios/chrome/browser/shared/coordinator/scene:observing_scene_agent",
  ]
}

source_set("variations_app_state_agent") {
  sources = [
    "variations_app_state_agent+testing.h",
    "variations_app_state_agent.h",
    "variations_app_state_agent.mm",
  ]
  deps = [
    ":launch_screen_ui",
    "//base",
    "//components/prefs",
    "//components/variations",
    "//components/variations/service",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:observing_app_state_agent",
    "//ios/chrome/browser/first_run/ui_bundled:utils",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/variations/model:fetcher",
    "//ios/chrome/browser/variations/model:store",
    "//ios/chrome/common",
  ]
}

source_set("enterprise_app_agent") {
  sources = [
    "enterprise_app_agent.h",
    "enterprise_app_agent.mm",
  ]

  deps = [
    ":enterprise_app_agent_ui",
    "//base",
    "//components/policy/core/common",
    "//ios/chrome/app:tests_hook",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/browser/first_run/ui_bundled:constants",
    "//ios/chrome/browser/first_run/ui_bundled:utils",
    "//ios/chrome/browser/policy/model",
    "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
    "//ios/chrome/browser/shared/model/application_context",
  ]
}

source_set("identity_confirmation_app_agent") {
  sources = [
    "identity_confirmation_app_agent.h",
    "identity_confirmation_app_agent.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/app/application_delegate:observing_app_state_agent",
    "//ios/chrome/app/strings",
    "//ios/chrome/browser/ntp/ui_bundled:feature_flags",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/model/prefs:pref_names",
    "//ios/chrome/browser/shared/model/profile",
    "//ios/chrome/browser/shared/public/features",
    "//ios/chrome/browser/shared/ui/util:snackbar_util",
    "//ios/chrome/browser/signin/model",
  ]
}

source_set("launch_screen_ui") {
  sources = [
    "launch_screen_view_controller.h",
    "launch_screen_view_controller.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/browser/first_run/ui_bundled:constants",
    "//ios/chrome/common/ui/colors",
  ]
}

source_set("enterprise_app_agent_ui") {
  sources = [
    "enterprise_loading_screen_view_controller.h",
    "enterprise_loading_screen_view_controller.mm",
  ]
  deps = [
    ":launch_screen_ui",
    "//base",
    "//ios/chrome/app/strings",
    "//ios/chrome/browser/first_run/ui_bundled:constants",
    "//ios/chrome/browser/shared/ui/util",
    "//ios/chrome/common/ui/colors",
    "//ios/chrome/common/ui/util",
    "//ios/chrome/common/ui/util:dynamic_type_util",
  ]
}

source_set("first_run_app_state_agent") {
  sources = [
    "first_run_app_state_agent.h",
    "first_run_app_state_agent.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/app:blocking_scene_commands",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/browser/blocking_overlay/ui_bundled",
    "//ios/chrome/browser/browser_view/ui_bundled",
    "//ios/chrome/browser/browsing_data/model",
    "//ios/chrome/browser/first_run/ui_bundled",
    "//ios/chrome/browser/first_run/ui_bundled:field_trial",
    "//ios/chrome/browser/first_run/ui_bundled:first_run_provider",
    "//ios/chrome/browser/first_run/ui_bundled:utils",
    "//ios/chrome/browser/geolocation/model",
    "//ios/chrome/browser/shared/coordinator/scene:observing_scene_agent",
    "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/public/commands:commands",
    "//ios/chrome/browser/shared/public/features",
    "//ios/chrome/browser/signin/model",
    "//ios/chrome/browser/ui/screen:screen_provider",
  ]
}

source_set("docking_promo_app_agent") {
  sources = [
    "docking_promo_app_agent.h",
    "docking_promo_app_agent.mm",
  ]
  deps = [
    "//base",
    "//components/prefs",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/browser/default_browser/model:utils",
    "//ios/chrome/browser/docking_promo/model:utils",
    "//ios/chrome/browser/promos_manager/model",
    "//ios/chrome/browser/promos_manager/model:constants",
    "//ios/chrome/browser/promos_manager/model:factory",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/model/prefs:pref_names",
    "//ios/chrome/browser/shared/model/profile",
    "//ios/chrome/browser/shared/public/features",
    "//ios/chrome/browser/start_surface/ui_bundled",
  ]
}

source_set("post_restore_app_agent") {
  sources = [
    "post_restore_app_agent.h",
    "post_restore_app_agent.mm",
  ]
  deps = [
    "//base",
    "//components/signin/public/identity_manager",
    "//components/signin/public/identity_manager/objc",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/browser/promos_manager/model",
    "//ios/chrome/browser/promos_manager/model:constants",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/signin/model",
    "//ios/chrome/browser/signin/model:signin_util",
  ]
}

source_set("search_engine_choice_app_agent") {
  sources = [
    "search_engine_choice_app_agent.h",
    "search_engine_choice_app_agent.mm",
  ]
  deps = [
    ":tests_hook",
    "//base",
    "//components/search_engines",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/app/application_delegate:observing_app_state_agent",
    "//ios/chrome/browser/policy/model",
    "//ios/chrome/browser/promos_manager/model",
    "//ios/chrome/browser/promos_manager/model:constants",
    "//ios/chrome/browser/promos_manager/model:factory",
    "//ios/chrome/browser/search_engine_choice/model",
    "//ios/chrome/browser/search_engines/model",
    "//ios/chrome/browser/search_engines/model:template_url_service_factory",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/public/features:system_flags",
    "//ios/chrome/browser/signin/model:signin_util",
    "//ios/chrome/browser/ui/search_engine_choice",
    "//ios/public/provider/chrome/browser/signin:choice_api",
  ]
}

source_set("feed_app_agent") {
  sources = [
    "feed_app_agent.h",
    "feed_app_agent.mm",
  ]
  deps = [
    ":constants",
    "//base",
    "//components/metrics",
    "//components/search_engines",
    "//components/signin/public/identity_manager",
    "//ios/chrome/app/application_delegate:app_state_header",
    "//ios/chrome/app/application_delegate:observing_app_state_agent",
    "//ios/chrome/app/profile",
    "//ios/chrome/browser/content_notification/model:util",
    "//ios/chrome/browser/discover_feed/model",
    "//ios/chrome/browser/discover_feed/model:discover_feed_factory",
    "//ios/chrome/browser/ntp/shared/metrics",
    "//ios/chrome/browser/push_notification/model:push_notification_client",
    "//ios/chrome/browser/push_notification/model:push_notification_service",
    "//ios/chrome/browser/search_engines/model:template_url_service_factory",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/model/profile",
    "//ios/chrome/browser/shared/model/utils",
    "//ios/chrome/browser/shared/public/features",
    "//ios/chrome/browser/signin/model",
  ]
  frameworks = [
    "BackgroundTasks.framework",
    "UserNotifications.framework",
  ]
}

source_set("app_internal") {
  sources = [
    "application_storage_metrics.h",
    "application_storage_metrics.mm",
    "chrome_overlay_window.h",
    "chrome_overlay_window.mm",
    "features.h",
    "features.mm",
    "main_application_delegate.h",
    "main_application_delegate.mm",
    "main_application_delegate_testing.h",
    "main_controller.h",
    "main_controller.mm",
    "memory_monitor.h",
    "memory_monitor.mm",
    "startup_tasks.h",
    "startup_tasks.mm",
  ]

  if (ios_enable_sandbox_dump) {
    sources += [
      "dump_documents_statistics.h",
      "dump_documents_statistics.mm",
    ]
  }

  deps = [
    ":app",
    ":app_metrics_app_state_agent",
    ":blocking_scene_commands",
    ":docking_promo_app_agent",
    ":enterprise_app_agent",
    ":fast_app_terminate_buildflags",
    ":feed_app_agent",
    ":first_run_app_state_agent",
    ":identity_confirmation_app_agent",
    ":launch_screen_ui",
    ":mode",
    ":post_restore_app_agent",
    ":safe_mode_app_state_agent",
    ":search_engine_choice_app_agent",
    ":tests_hook",
    ":variations_app_state_agent",
    "//base",
    "//build:branding_buildflags",
    "//components/bookmarks/browser",
    "//components/breadcrumbs/core",
    "//components/breadcrumbs/core:status",
    "//components/browser_sync",
    "//components/browsing_data/core",
    "//components/component_updater",
    "//components/component_updater/installer_policies",
    "//components/crash/core/common",
    "//components/download/public/background_service:public",
    "//components/enterprise/idle",
    "//components/favicon/core",
    "//components/favicon_base",
    "//components/feature_engagement",
    "//components/handoff",
    "//components/history/core/browser",
    "//components/infobars/core",
    "//components/keyed_service/core",
    "//components/keyed_service/ios",
    "//components/metrics",
    "//components/optimization_guide/core:features",
    "//components/password_manager/core/common",
    "//components/prefs",
    "//components/prefs/ios",
    "//components/previous_session_info",
    "//components/proxy_config",
    "//components/search_engines",
    "//components/send_tab_to_self",
    "//components/signin/internal/identity_manager",
    "//components/sync",
    "//components/web_resource",
    "//ios/chrome/app/application_delegate",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/app/application_delegate:tab_opening",
    "//ios/chrome/app/application_delegate:url_opener_params",
    "//ios/chrome/app/background_refresh",
    "//ios/chrome/app/profile",
    "//ios/chrome/app/spotlight",
    "//ios/chrome/app/startup",
    "//ios/chrome/app/startup:ios_enable_sandbox_dump_buildflags",
    "//ios/chrome/app/startup:startup_basic",
    "//ios/chrome/app/strings",
    "//ios/chrome/browser/accessibility/model",
    "//ios/chrome/browser/appearance/ui_bundled",
    "//ios/chrome/browser/bookmarks/model",
    "//ios/chrome/browser/browser_state/model",
    "//ios/chrome/browser/browser_state_metrics/model",
    "//ios/chrome/browser/browsing_data/model",
    "//ios/chrome/browser/commerce/model/push_notification",
    "//ios/chrome/browser/content_notification/model:util",
    "//ios/chrome/browser/content_settings/model",
    "//ios/chrome/browser/crash_report/model",
    "//ios/chrome/browser/crash_report/model:model_internal",
    "//ios/chrome/browser/crash_report/model/breadcrumbs",
    "//ios/chrome/browser/credential_provider/model:buildflags",
    "//ios/chrome/browser/default_browser/model:utils",
    "//ios/chrome/browser/download/model",
    "//ios/chrome/browser/download/model/background_service:background_service",
    "//ios/chrome/browser/download/ui_bundled",
    "//ios/chrome/browser/enterprise/model/idle",
    "//ios/chrome/browser/external_files/model",
    "//ios/chrome/browser/favicon/model",
    "//ios/chrome/browser/feature_engagement/model",
    "//ios/chrome/browser/first_run/model",
    "//ios/chrome/browser/first_run/ui_bundled",
    "//ios/chrome/browser/first_run/ui_bundled:utils",
    "//ios/chrome/browser/geolocation/model",
    "//ios/chrome/browser/history/model",
    "//ios/chrome/browser/keyboard/ui_bundled",
    "//ios/chrome/browser/mailto_handler/model",
    "//ios/chrome/browser/mailto_handler/model:mailto_handler_factory",
    "//ios/chrome/browser/main/model",
    "//ios/chrome/browser/memory/model",
    "//ios/chrome/browser/metrics/model",
    "//ios/chrome/browser/metrics/model:metrics_browser_agent",
    "//ios/chrome/browser/metrics/model:metrics_internal",
    "//ios/chrome/browser/ntp/ui_bundled:feature_flags",
    "//ios/chrome/browser/omaha/model",
    "//ios/chrome/browser/passwords/model",
    "//ios/chrome/browser/promos_manager/model:factory",
    "//ios/chrome/browser/push_notification/model:push_notification_service",
    "//ios/chrome/browser/reading_list/model",
    "//ios/chrome/browser/saved_tab_groups/model",
    "//ios/chrome/browser/screenshot/model",
    "//ios/chrome/browser/search_engines/model",
    "//ios/chrome/browser/search_engines/model:extension_search_engine_data_updater",
    "//ios/chrome/browser/search_engines/model:search_engines_util",
    "//ios/chrome/browser/search_engines/model:template_url_service_factory",
    "//ios/chrome/browser/sessions/model:features",
    "//ios/chrome/browser/sessions/model:session_restoration_service",
    "//ios/chrome/browser/sessions/model:session_restoration_service_factory",
    "//ios/chrome/browser/sessions/model:session_util",
    "//ios/chrome/browser/share_extension/model",
    "//ios/chrome/browser/shared/coordinator/scene",
    "//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
    "//ios/chrome/browser/shared/model/application_context",
    "//ios/chrome/browser/shared/model/browser_state",
    "//ios/chrome/browser/shared/model/paths",
    "//ios/chrome/browser/shared/model/prefs:pref_names",
    "//ios/chrome/browser/shared/model/profile",
    "//ios/chrome/browser/shared/model/web_state_list",
    "//ios/chrome/browser/shared/public/commands",
    "//ios/chrome/browser/shared/public/features",
    "//ios/chrome/browser/shared/public/features:system_flags",
    "//ios/chrome/browser/shared/ui/table_view",
    "//ios/chrome/browser/shared/ui/util",
    "//ios/chrome/browser/signin/model",
    "//ios/chrome/browser/snapshots/model",
    "//ios/chrome/browser/sync/model",
    "//ios/chrome/browser/tabs/ui_bundled",
    "//ios/chrome/browser/ui/authentication",
    "//ios/chrome/browser/ui/main",
    "//ios/chrome/browser/ui/tab_switcher/tab_grid",
    "//ios/chrome/browser/ui/tab_switcher/tab_grid:tab_grid_ui",
    "//ios/chrome/browser/ui/toolbar:toolbar_ui",
    "//ios/chrome/browser/upgrade/model:public",
    "//ios/chrome/browser/url_loading/model",
    "//ios/chrome/browser/variations/model:ios_chrome_ui_string_overrider_factory",
    "//ios/chrome/browser/voice/model",
    "//ios/chrome/browser/web/model",
    "//ios/chrome/browser/web_state_list/model/web_usage_enabler",
    "//ios/chrome/browser/webui/ui_bundled:webui_internal",
    "//ios/chrome/common/app_group",
    "//ios/chrome/common/app_group:main_app",
    "//ios/chrome/common/intents",
    "//ios/components/cookie_util",
    "//ios/net",
    "//ios/public/provider/chrome/browser/app_distribution:app_distribution_api",
    "//ios/public/provider/chrome/browser/overrides:overrides_api",
    "//ios/public/provider/chrome/browser/raccoon:raccoon_api",
    "//ios/public/provider/chrome/browser/signin:choice_api",
    "//ios/public/provider/chrome/browser/ui_utils:ui_utils_api",
    "//ios/public/provider/chrome/browser/user_feedback:user_feedback_api",
    "//ios/third_party/material_components_ios",
    "//ios/web/common:uikit",
    "//ios/web/public/webui",
    "//net",
    "//skia",
    "//ui/base",
    "//ui/gfx",
    "//ui/resources",
    "//ui/strings:ui_strings",
  ]

  if (ios_enable_credential_provider_extension) {
    deps += [
      ":credential_provider_migrator_app_agent",
      "//ios/chrome/browser/credential_provider/model",
    ]
  }

  frameworks = [
    "CoreSpotlight.framework",
    "MediaPlayer.framework",
  ]

  allow_circular_includes_from = [
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/browser/shared/coordinator/scene",
  ]
}

source_set("blocking_scene_commands") {
  sources = [ "blocking_scene_commands.h" ]

  deps = [ "//base" ]
}

source_set("mode") {
  sources = [ "application_mode.h" ]

  deps = [ "//base" ]
}

source_set("main") {
  sources = [ "chrome_exe_main.mm" ]

  deps = [
    ":app_internal",
    "//base",
    "//build:blink_buildflags",
    "//components/component_updater",
    "//components/crash/core/common",
    "//ios/chrome/app/startup:ios_enable_sandbox_dump_buildflags",
    "//ios/chrome/app/startup:startup_basic",
    "//ios/chrome/browser/crash_report/model",
    "//ios/chrome/browser/shared/model/paths",
    "//ios/chrome/common",
    "//ios/public/provider/chrome/browser/primes:primes_api",
  ]
  if (ios_chrome_privacy_manifest != "") {
    deps += [ ":privacy_manifest" ]
  }
  if (ios_enable_sandbox_dump) {
    deps += [ "//ios/chrome/app/startup:sandbox_dump" ]
  }
  if (ios_chrome_generate_order_file) {
    deps += [ "//ios/components/order_file" ]
  }
  assert_no_deps = []

  if (ios_chrome_links_with_material_components_framework) {
    deps += [
      "//ios/third_party/material_components_ios:material_components_ios+bundle",
      "//ios/third_party/material_components_ios:material_components_ios+link",
    ]
  } else {
    assert_no_deps += [
      "//ios/third_party/material_components_ios:material_components_ios+bundle",
      "//ios/third_party/material_components_ios:material_components_ios+link",
    ]
  }
}

if (ios_chrome_privacy_manifest != "") {
  bundle_data("privacy_manifest") {
    sources = [ ios_chrome_privacy_manifest ]
    outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
  }
}

source_set("multitasking_test_app_delegate") {
  sources = [
    "multitasking_test_application_delegate.h",
    "multitasking_test_application_delegate.mm",
    "multitasking_test_scene_delegate.h",
    "multitasking_test_scene_delegate.mm",
  ]
  deps = [
    ":app_internal",
    "//base",
    "//ios/chrome/app/application_delegate:application_delegate_internal",
    "//ios/chrome/browser/shared/coordinator/scene",
    "//ios/third_party/material_components_ios",
  ]
}

if (ios_partition_alloc_enabled) {
  ios_framework_bundle("early_partition_alloc_framework") {
    output_name = "EarlyMallocZoneRegistration"
    sources = [ "early_pa_registration.cc" ]
    info_plist = "//ios/chrome/app/resources/EarlyPAFrameworkInfo.plist"
    extra_substitutions =
        [ "BUNDLE_IDENTIFIER=$ios_app_bundle_id_prefix.$output_name" ]

    deps = [
      "//base/allocator:early_zone_registration_apple",
      "//base/allocator/partition_allocator:buildflags",
    ]
  }
}

chrome_app("chrome") {
  output_name = chromium_short_name

  entitlements_target = ":entitlements"
  info_plist_target = ":info_plist"
  bundle_identifier = "$ios_chromium_bundle_id"
  if (ios_chrome_orderfile != "") {
    orderfile_path = ios_chrome_orderfile
  }

  bundle_deps = [
    "//ios/chrome/app/resources",
    "//ios/chrome/app/resources:settings_resources",
  ]
  if (!is_chrome_branded || ios_chrome_app_variants == []) {
    assert(ios_application_icons_target != "",
           "ios_application_icons_target must be defined.")
    bundle_deps += [ ios_application_icons_target ]
    bundle_deps += ios_providers_resources_targets
  } else {
    variants = ios_chrome_app_variants
  }

  xcode_extra_attributes = {
    SUPPORTS_MACCATALYST = "YES"
  }

  deps = [
    ":main",

    # Use the provider API controlled by args.gn.
    ios_provider_target,
  ]

  if (ios_is_perf_test) {
    deps += [ ":perf_tests_hook" ]
  } else {
    deps += [ ":tests_fake_hook" ]
  }

  if (current_toolchain == default_toolchain) {
    if (ios_enable_search_widget_extension) {
      deps += [ ":search_widget_extension_bundle" ]
    }
    if (ios_enable_content_widget_extension) {
      deps += [ ":content_widget_extension_bundle" ]
    }
    if (ios_enable_share_extension) {
      deps += [ ":share_extension_bundle" ]
    }
    if (ios_enable_open_extension) {
      deps += [ ":open_extension_bundle" ]
    }
    if (ios_enable_credential_provider_extension) {
      deps += [ ":credential_provider_extension_bundle" ]
    }
    if (ios_enable_widget_kit_extension) {
      deps += [ ":widget_kit_extension_bundle" ]
    }
    if (ios_enable_intents_extension) {
      deps += [ ":intents_extension_bundle" ]
    }
    if (ios_enable_push_notification_service_extension) {
      deps += [ ":push_notification_service_extension_bundle" ]
    }
  }

  extra_substitutions = [
    "CONTENT_WIDGET_EXTENSION_BUNDLE_ID=$ios_chromium_bundle_id.ContentTodayExtension",
    "CHROMIUM_BUNDLE_ID=$ios_chromium_bundle_id",
    "CHROMIUM_HANDOFF_ID=$chromium_handoff_id",
    "CHROMIUM_SHORT_NAME=$chromium_short_name",
    "CHROMIUM_URL_SCHEME_1=$url_unsecure_scheme",
    "CHROMIUM_URL_SCHEME_2=$url_secure_scheme",
    "CHROMIUM_URL_SCHEME_3=$url_x_callback_scheme",
    "CHROMIUM_URL_CHANNEL_SCHEME=$url_channel_scheme",
    "SSOAUTH_URL_SCHEME=$url_ssoauth_scheme",
    "IOS_MOVE_TAB_ACTIVITY_TYPE=$ios_move_tab_activity_type",
  ]

  if (ios_encryption_export_compliance_code != "") {
    extra_substitutions += [ "ENCRYPTION_EXPORT_COMPLIANCE_CODE=" +
                             ios_encryption_export_compliance_code ]
  }

  assert_no_deps = ios_assert_no_deps + ios_chrome_extra_assert_no_deps

  if (ios_chrome_links_with_material_components_framework) {
    deps += [
      "//ios/third_party/material_components_ios:material_components_ios+bundle",
      "//ios/third_party/material_components_ios:material_components_ios+link",
    ]
  } else {
    assert_no_deps += [
      "//ios/third_party/material_components_ios:material_components_ios+bundle",
      "//ios/third_party/material_components_ios:material_components_ios+link",
    ]
  }

  # Lottie links with GLKit which does not support macCatalyst environment
  # (see https://crbug.com/1394553 for details of the build failure). This
  # is a stop-gap solution.
  if (target_environment == "catalyst" ||
      ios_provider_target !=
      "//ios/chrome/browser/providers:chromium_providers") {
    assert_no_deps += [
      "//ios/third_party/lottie:lottie+bundle",
      "//ios/third_party/lottie:lottie+link",
    ]
  }
}

if (current_toolchain == default_toolchain && !ios_chrome_generate_order_file) {
  _extension_toolchain = "${current_toolchain}_app_ext"
  if (ios_enable_search_widget_extension) {
    extension_bundle_data("search_widget_extension_bundle") {
      extension_name = "search_widget_extension.appex"
      extension_target = "//ios/chrome/search_widget_extension/appex(${_extension_toolchain}_13_4)"
    }
  }

  if (ios_enable_content_widget_extension) {
    extension_bundle_data("content_widget_extension_bundle") {
      extension_name = "content_widget_extension.appex"
      extension_target = "//ios/chrome/content_widget_extension/appex(${_extension_toolchain}_13_4)"
    }
  }

  if (ios_enable_share_extension) {
    extension_bundle_data("share_extension_bundle") {
      extension_name = "share_extension.appex"
      extension_target =
          "//ios/chrome/share_extension/appex(${_extension_toolchain})"
    }
  }

  if (ios_enable_open_extension) {
    extension_bundle_data("open_extension_bundle") {
      extension_name = "open_extension.appex"
      extension_target =
          "//ios/chrome/open_extension/appex(${_extension_toolchain})"
    }
  }

  if (ios_enable_credential_provider_extension) {
    extension_bundle_data("credential_provider_extension_bundle") {
      extension_name = "credential_provider_extension.appex"
      extension_target = "//ios/chrome/credential_provider_extension/appex(${_extension_toolchain})"
    }
  }

  if (ios_enable_widget_kit_extension) {
    extension_bundle_data("widget_kit_extension_bundle") {
      extension_name = "widget_kit_extension.appex"
      extension_target =
          "//ios/chrome/widget_kit_extension/appex(${_extension_toolchain})"
    }
  }

  if (ios_enable_intents_extension) {
    extension_bundle_data("intents_extension_bundle") {
      extension_name = "intents_extension.appex"
      extension_target =
          "//ios/chrome/intents_extension/appex(${_extension_toolchain})"
    }
  }

  if (ios_enable_push_notification_service_extension) {
    extension_bundle_data("push_notification_service_extension_bundle") {
      extension_name = "push_notification_service_extension.appex"
      extension_target = "//ios/chrome/push_notification_service_extension/appex(${_extension_toolchain})"
    }
  }
}

source_set("constants") {
  sources = [
    "background_refresh_constants.h",
    "background_refresh_constants.mm",
  ]
  deps = [ "//base" ]
}