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

import("//build/config/features.gni")
import("//third_party/protobuf/proto_library.gni")

declare_args() {
  google_test_gaia_client_id = ""
  google_test_gaia_client_secret = ""
  google_staging_api_url = ""
  google_staging_lso_url = ""
  google_test_api_url = ""
  google_test_lso_url = ""
  google_test_oauth_client_id = ""
  google_test_oauth_client_secret = ""
  google_test_oauth_url = ""
  google_test_sync_url = ""
}

source_set("browser") {
  sources = [
    "app_startup_parameters.h",
    "app_startup_parameters.mm",
    "application_context.cc",
    "application_context.h",
    "arch_util.cc",
    "arch_util.h",
    "browser_about_rewriter.cc",
    "browser_about_rewriter.h",
    "chrome_constants.cc",
    "chrome_constants.h",
    "chrome_coordinator.h",
    "chrome_coordinator.mm",
    "chrome_paths.h",
    "chrome_paths.mm",
    "chrome_paths_internal.h",
    "chrome_switches.cc",
    "chrome_switches.h",
    "chrome_url_constants.cc",
    "chrome_url_constants.h",
    "chrome_url_util.h",
    "chrome_url_util.mm",
    "crash_loop_detection_util.h",
    "crash_loop_detection_util.mm",
    "experimental_flags.h",
    "experimental_flags.mm",
    "file_metadata_util.h",
    "file_metadata_util.mm",
    "install_time_util.h",
    "install_time_util.mm",
    "installation_notifier.h",
    "installation_notifier.mm",
    "ios_chrome_field_trials.cc",
    "ios_chrome_field_trials.h",
    "ios_chrome_io_thread.h",
    "ios_chrome_io_thread.mm",
    "notification_promo.cc",
    "notification_promo.h",
    "open_url_util.h",
    "open_url_util.mm",
    "pref_names.cc",
    "pref_names.h",
    "procedural_block_types.h",
    "root_coordinator.h",
    "root_coordinator.mm",
    "storekit_launcher.h",
    "tab_parenting_global_observer.cc",
    "tab_parenting_global_observer.h",
    "web_data_service_factory.cc",
    "web_data_service_factory.h",
    "xcallback_parameters.h",
    "xcallback_parameters.mm",
  ]
  deps = [
    "//base",
    "//components/autofill/core/browser",
    "//components/autofill/core/common",
    "//components/gcm_driver",
    "//components/handoff",
    "//components/keyed_service/core",
    "//components/keyed_service/ios",
    "//components/metrics",
    "//components/metrics_services_manager",
    "//components/net_log",
    "//components/network_session_configurator",
    "//components/ntp_tiles",
    "//components/pref_registry",
    "//components/prefs",
    "//components/proxy_config",
    "//components/search_engines",
    "//components/signin/core/browser",
    "//components/ssl_config",
    "//components/translate/core/browser",
    "//components/url_formatter",
    "//components/variations",
    "//components/variations/service",
    "//components/version_info",
    "//components/webdata_services",
    "//ios/chrome/browser/browser_state",
    "//ios/chrome/browser/sync/glue",
    "//ios/chrome/common",
    "//ios/net",
    "//ios/public/provider/chrome/browser",
    "//ios/web",
    "//ios/web:user_agent",
    "//net",
    "//url",
  ]
  allow_circular_includes_from = [
    "//ios/chrome/browser/sync/glue",
    "//ios/chrome/browser/browser_state",
  ]
  libs = [ "UIKit.framework" ]
}

source_set("browser_impl") {
  sources = [
    "application_context_impl.cc",
    "application_context_impl.h",
    "ios_chrome_main_parts.h",
    "ios_chrome_main_parts.mm",
  ]
  deps = [
    ":about_flags",
    ":browser",
    "//base",
    "//components/component_updater",
    "//components/content_settings/core/browser",
    "//components/content_settings/core/common",
    "//components/flags_ui",
    "//components/gcm_driver",
    "//components/history/core/browser",
    "//components/keyed_service/core",
    "//components/language_usage_metrics",
    "//components/metrics:profiler_ios",
    "//components/metrics_services_manager",
    "//components/net_log",
    "//components/network_time",
    "//components/open_from_clipboard",
    "//components/physical_web/data_source",
    "//components/prefs",
    "//components/rappor",
    "//components/task_scheduler_util",
    "//components/translate/core/browser",
    "//components/update_client",
    "//components/variations",
    "//components/variations/field_trial_config",
    "//components/variations/service",
    "//ios/chrome/browser/browser_state",
    "//ios/chrome/browser/browser_state:browser_state_impl",
    "//ios/chrome/browser/component_updater",
    "//ios/chrome/browser/first_run",
    "//ios/chrome/browser/history",
    "//ios/chrome/browser/metrics",
    "//ios/chrome/browser/net",
    "//ios/chrome/browser/open_from_clipboard",
    "//ios/chrome/browser/physical_web",
    "//ios/chrome/browser/prefs",
    "//ios/chrome/browser/services/gcm",
    "//ios/chrome/browser/translate",
    "//ios/chrome/browser/update_client",
    "//ios/chrome/browser/web_resource",
    "//ios/chrome/common",
    "//ios/public/provider/chrome/browser",
    "//ios/web",
    "//ios/web/public/app",
    "//net",
    "//ui/base",
  ]

  if (enable_rlz) {
    deps += [ "//ios/chrome/browser/rlz" ]
  }
}

# This is a separate target so that the 'defines' does not leak to the
# other files (which would increase the compilation time when changing
# the value).
source_set("about_flags") {
  sources = [
    "about_flags.h",
    "about_flags.mm",
  ]

  deps = [
    ":browser",
    "//base",
    "//components/autofill/core/common",
    "//components/dom_distiller/core",
    "//components/flags_ui",
    "//components/flags_ui:switches",
    "//components/ntp_tiles",
    "//components/strings",
    "//components/sync",
    "//components/variations",
    "//google_apis",
    "//ios/chrome/app/strings",
    "//ios/web",
    "//ios/web:user_agent",
  ]

  defines = [
    "GOOGLE_STAGING_API_URL=\"$google_staging_api_url\"",
    "GOOGLE_STAGING_LSO_URL=\"$google_staging_lso_url\"",
    "GOOGLE_TEST_API_URL=\"$google_test_api_url\"",
    "GOOGLE_TEST_LSO_URL=\"$google_test_lso_url\"",
    "GOOGLE_TEST_OAUTH_CLIENT_ID=\"$google_test_oauth_client_id\"",
    "GOOGLE_TEST_OAUTH_CLIENT_SECRET=\"$google_test_oauth_client_secret\"",
    "GOOGLE_TEST_OAUTH_URL=\"$google_test_oauth_url\"",
    "GOOGLE_TEST_SYNC_URL=\"$google_test_sync_url\"",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "chrome_url_util_unittest.mm",
    "crash_loop_detection_util_unittest.mm",
    "install_time_util_unittest.mm",
    "installation_notifier_unittest.mm",
    "ios_chrome_io_thread_unittest.mm",
    "notification_promo_unittest.cc",
  ]
  deps = [
    ":browser",
    "//base",
    "//base/test:test_support",
    "//components/prefs",
    "//components/prefs:test_support",
    "//components/proxy_config",
    "//components/ssl_config",
    "//components/variations",
    "//ios/web:test_support",
    "//net",
    "//net:test_support",
    "//testing/gtest",
    "//url",
  ]
}
