# 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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//tools/json_to_struct/json_to_struct.gni")
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
static_library("search_engines") {
sources = [
"choice_made_location.h",
"default_search_manager.cc",
"default_search_manager.h",
"eea_countries_ids.h",
"enterprise/default_search_policy_handler.cc",
"enterprise/default_search_policy_handler.h",
"enterprise/enterprise_site_search_manager.cc",
"enterprise/enterprise_site_search_manager.h",
"keyword_table.cc",
"keyword_table.h",
"keyword_web_data_service.cc",
"keyword_web_data_service.h",
"search_engine_choice/search_engine_choice_metrics_service_accessor.h",
"search_engine_choice/search_engine_choice_service.cc",
"search_engine_choice/search_engine_choice_service.h",
"search_engine_choice/search_engine_choice_utils.cc",
"search_engine_choice/search_engine_choice_utils.h",
"search_engines_pref_names.h",
"search_host_to_urls_map.cc",
"search_host_to_urls_map.h",
"search_terms_data.cc",
"search_terms_data.h",
"template_url.cc",
"template_url.h",
"template_url_data.cc",
"template_url_data.h",
"template_url_data_util.cc",
"template_url_data_util.h",
"template_url_fetcher.cc",
"template_url_fetcher.h",
"template_url_id.h",
"template_url_parser.cc",
"template_url_parser.h",
"template_url_prepopulate_data.cc",
"template_url_prepopulate_data.h",
"template_url_service.cc",
"template_url_service.h",
"template_url_service_client.h",
"template_url_service_observer.h",
"template_url_starter_pack_data.cc",
"template_url_starter_pack_data.h",
"util.cc",
"util.h",
]
public_deps = [
":prepopulated_engines",
":search_engine_type",
":search_engine_utils",
":search_engines_switches",
"//base",
"//components/google/core/common",
"//components/keyed_service/core",
"//components/prefs",
"//components/sync",
"//components/webdata/common",
"//third_party/metrics_proto",
"//third_party/omnibox_proto",
]
deps = [
"//base:i18n",
"//components/country_codes",
"//components/crash/core/common:crash_key",
"//components/database_utils",
"//components/infobars/core",
"//components/lens:lens",
"//components/lens/proto/server:proto",
"//components/metrics",
"//components/omnibox/common",
"//components/policy:generated",
"//components/policy/core/browser",
"//components/pref_registry",
"//components/search_provider_logos:switches",
"//components/signin/public/base",
"//components/strings",
"//components/url_formatter",
"//components/variations",
"//google_apis",
"//net",
"//services/data_decoder/public/cpp",
"//services/network/public/cpp",
"//services/network/public/mojom",
"//sql",
"//third_party/metrics_proto",
"//third_party/omnibox_proto",
"//ui/base",
"//ui/gfx",
"//ui/gfx/geometry",
"//url",
]
if (!is_fuchsia) {
deps += [ "//components/variations/service" ]
}
if (is_android) {
sources += [
"android/search_engines_feature_map.cc",
"android/template_url_android.cc",
"android/template_url_android.h",
"android/template_url_service_android.cc",
"android/template_url_service_android.h",
]
deps += [
"//components/search_engines/android:features_jni_headers",
"//components/search_engines/android:jni_headers",
]
}
if (!is_android) {
sources += [ "search_engine_choice/generated_marketing_snippets.cc" ]
deps += [
":generate_search_engine_icons",
"//components/resources:components_scaled_resources_grit",
"//ui/resources",
]
}
if (is_linux || is_win || is_mac || is_chromeos) {
sources += [
"enterprise/site_search_policy_handler.cc",
"enterprise/site_search_policy_handler.h",
]
}
if (is_chromeos_lacros) {
deps += [
"//chromeos/crosapi/mojom",
"//chromeos/lacros",
]
}
}
source_set("search_engine_utils") {
sources = [
"search_engine_utils.cc",
"search_engine_utils.h",
]
public_deps = [
":prepopulated_engines",
":search_engine_type",
"//components/google/core/common",
]
deps = [ "//url" ]
}
source_set("search_engine_type") {
sources = [ "search_engine_type.h" ]
}
static_library("test_support") {
testonly = true
sources = [
"search_engines_test_environment.cc",
"search_engines_test_environment.h",
"search_engines_test_util.cc",
"search_engines_test_util.h",
"template_url_service_test_util.cc",
"template_url_service_test_util.h",
"testing_search_terms_data.cc",
"testing_search_terms_data.h",
]
public_deps = [
":search_engines",
"//base",
"//base/test:test_support",
"//components/country_codes",
"//components/metrics:metrics_pref_names",
"//components/prefs:test_support",
"//components/sync_preferences:test_support",
"//testing/gtest",
]
}
source_set("unit_tests") {
testonly = true
sources = [
"default_search_manager_unittest.cc",
"enterprise/enterprise_site_search_manager_unittest.cc",
"keyword_table_unittest.cc",
"search_engine_choice/search_engine_choice_service_unittest.cc",
"search_engine_choice/search_engine_choice_utils_unittest.cc",
"search_host_to_urls_map_unittest.cc",
"template_url_data_unittest.cc",
"template_url_prepopulate_data_unittest.cc",
"template_url_service_unittest.cc",
"template_url_service_util_unittest.cc",
"template_url_unittest.cc",
]
deps = [
":prepopulated_engines",
":test_support",
"//base",
"//base/test:test_support",
"//components/country_codes",
"//components/google/core/common",
"//components/metrics",
"//components/omnibox/common",
"//components/policy/core/common",
"//components/policy/core/common:test_support",
"//components/pref_registry:pref_registry",
"//components/prefs",
"//components/prefs:test_support",
"//components/sync:test_support",
"//components/sync_preferences:test_support",
"//components/variations:test_support",
"//components/webdata/common",
"//net:net",
"//services/network:test_support",
"//services/network/public/cpp",
"//sql",
"//testing/gmock",
"//testing/gtest",
"//ui/base",
"//url",
]
if (is_linux || is_win || is_mac || is_chromeos) {
sources += [ "enterprise/site_search_policy_handler_unittest.cc" ]
}
if (!is_ios) {
sources += [ "enterprise/default_search_policy_handler_unittest.cc" ]
deps += [
"//components/policy:generated",
"//components/policy/core/browser:test_support",
]
}
if (is_android) {
sources += [ "android/template_url_service_android_unittest.cc" ]
deps += [
"//components/search_engines/android:jni_headers",
"//components/search_engines/android:test_utils_jni_headers",
]
}
}
json_to_struct("prepopulated_engines") {
visibility = [ ":*" ]
source = "prepopulated_engines.json"
schema_file = "prepopulated_engines_schema.json"
namespace = "TemplateURLPrepopulateData"
deps = [ ":search_engine_type" ]
}
if (is_android) {
java_cpp_enum("search_engine_enums_java") {
sources = [
"choice_made_location.h",
"search_engine_type.h",
]
}
}
component("search_engines_switches") {
output_name = "search_engines_switches"
defines = [ "IS_SEARCH_ENGINES_SWITCHES_IMPL" ]
sources = [
"search_engines_switches.cc",
"search_engines_switches.h",
]
deps = [ "//base" ]
}
if (!is_android) {
action("generate_search_engine_icons") {
script = "//tools/search_engine_choice/generate_search_engine_icons.py"
inputs = [
"//tools/search_engine_choice/generate_search_engine_icons_config.json",
"//components/search_engines/prepopulated_engines.json",
"//components/search_engines/search_engine_countries-inc.cc",
"//tools/json_comment_eater/json_comment_eater.py",
"//tools/search_engine_choice/generate_search_engine_icons.py",
"//tools/search_engine_choice/search_engine_icons_utils.py",
]
outputs = [
"$root_gen_dir/chrome/browser/ui/webui/search_engine_choice/generated_icon_utils-inc.cc",
"$target_gen_dir/generated_search_engine_resource_ids-inc.cc",
]
args = [
rebase_path("//", root_build_dir),
rebase_path("$target_gen_dir/generated_search_engine_resource_ids-inc.cc",
root_build_dir),
rebase_path(
"$target_gen_dir/../../chrome/browser/ui/webui/search_engine_choice/generated_icon_utils-inc.cc",
root_build_dir),
]
}
}