chromium/components/omnibox/browser/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/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//components/optimization_guide/features.gni")
import("//components/vector_icons/vector_icons.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//extensions/buildflags/buildflags.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

buildflag_header("buildflags") {
  header = "buildflags.h"
  flags = [ "ENABLE_VR=$enable_vr" ]
}

aggregate_vector_icons("omnibox_vector_icons") {
  icon_directory = "vector_icons"

  sources = [
    "answer_calculator.icon",
    "answer_currency.icon",
    "answer_currency_chrome_refresh.icon",
    "answer_default.icon",
    "answer_dictionary.icon",
    "answer_dictionary_chrome_refresh.icon",
    "answer_finance.icon",
    "answer_finance_chrome_refresh.icon",
    "answer_sunrise.icon",
    "answer_sunrise_chrome_refresh.icon",
    "answer_translation.icon",
    "answer_translation_chrome_refresh.icon",
    "answer_when_is.icon",
    "answer_when_is_chrome_refresh.icon",
    "arrow_down_chrome_refresh.icon",
    "arrow_up_chrome_refresh.icon",
    "bookmark.icon",
    "bookmark_chrome_refresh.icon",
    "calculator.icon",
    "calculator_chrome_refresh.icon",
    "chevron.icon",
    "clear.icon",
    "clock.icon",
    "clock_chrome_refresh.icon",
    "cookie_chrome_refresh.icon",
    "dino.icon",
    "dino_cr2023.icon",
    "drive_docs.icon",
    "drive_folder.icon",
    "drive_forms.icon",
    "drive_image.icon",
    "drive_logo.icon",
    "drive_pdf.icon",
    "drive_sheets.icon",
    "drive_slides.icon",
    "drive_video.icon",
    "enterprise.icon",
    "extension_app.icon",
    "find_in_page_chrome_refresh.icon",
    "http.icon",
    "http_chrome_refresh.icon",
    "incognito.icon",
    "incognito_cr2023.icon",
    "install_desktop.icon",
    "journeys.icon",
    "journeys_chrome_refresh.icon",
    "offline_pin.icon",
    "page.icon",
    "page_chrome_refresh.icon",
    "pedal.icon",
    "price_tracking_disabled.icon",
    "price_tracking_disabled_refresh.icon",
    "price_tracking_enabled_refresh.icon",
    "product.icon",
    "product_chrome_refresh.icon",
    "product_specifications_add.icon",
    "product_specifications_added.icon",
    "search_spark.icon",
    "secure_page_info_chrome_refresh.icon",
    "share.icon",
    "share_chrome_refresh.icon",
    "spark.icon",
    "star.icon",
    "star_active.icon",
    "star_active_chrome_refresh.icon",
    "star_chrome_refresh.icon",
    "switch.icon",
    "switch_cr2023.icon",
    "tab.icon",
    "trending_up.icon",
    "trending_up_chrome_refresh.icon",
  ]

  if (is_mac) {
    sources += [
      "share_mac.icon",
      "share_mac_chrome_refresh.icon",
    ]
  }

  if (is_win) {
    sources += [
      "share_win.icon",
      "share_win_chrome_refresh.icon",
    ]
  }

  if (is_linux) {
    sources += [ "share_linux_chrome_refresh.icon" ]
  }
}

static_library("vector_icons") {
  sources = get_target_outputs(":omnibox_vector_icons")
  deps = [
    ":omnibox_vector_icons",
    "//components/vector_icons",
    "//skia",
    "//ui/gfx",
  ]
}

static_library("browser") {
  sources = [
    "actions/omnibox_action.cc",
    "actions/omnibox_action.h",
    "actions/omnibox_action_concepts.h",
    "actions/omnibox_action_in_suggest.cc",
    "actions/omnibox_action_in_suggest.h",
    "actions/omnibox_answer_action.cc",
    "actions/omnibox_answer_action.h",
    "actions/omnibox_pedal.cc",
    "actions/omnibox_pedal.h",
    "actions/omnibox_pedal_concepts.h",
    "actions/omnibox_pedal_provider.cc",
    "actions/omnibox_pedal_provider.h",
    "actions/tab_switch_action.cc",
    "actions/tab_switch_action.h",
    "answers_cache.cc",
    "answers_cache.h",
    "autocomplete_classifier.cc",
    "autocomplete_classifier.h",
    "autocomplete_controller.cc",
    "autocomplete_controller.h",
    "autocomplete_controller_emitter.cc",
    "autocomplete_controller_emitter.h",
    "autocomplete_controller_metrics.cc",
    "autocomplete_controller_metrics.h",
    "autocomplete_grouper_groups.cc",
    "autocomplete_grouper_groups.h",
    "autocomplete_grouper_sections.cc",
    "autocomplete_grouper_sections.h",
    "autocomplete_i18n.h",
    "autocomplete_match.cc",
    "autocomplete_match.h",
    "autocomplete_match_classification.cc",
    "autocomplete_match_classification.h",
    "autocomplete_match_type.cc",
    "autocomplete_match_type.h",
    "autocomplete_provider.cc",
    "autocomplete_provider.h",
    "autocomplete_provider_client.cc",
    "autocomplete_provider_client.h",
    "autocomplete_provider_debouncer.cc",
    "autocomplete_provider_debouncer.h",
    "autocomplete_provider_listener.h",
    "autocomplete_result.cc",
    "autocomplete_result.h",
    "autocomplete_scoring_signals_annotator.h",
    "base_search_provider.cc",
    "base_search_provider.h",
    "bookmark_provider.cc",
    "bookmark_provider.h",
    "bookmark_scoring_signals_annotator.cc",
    "bookmark_scoring_signals_annotator.h",
    "builtin_provider.cc",
    "builtin_provider.h",
    "calculator_provider.cc",
    "calculator_provider.h",
    "clipboard_provider.cc",
    "clipboard_provider.h",
    "document_provider.cc",
    "document_provider.h",
    "document_suggestions_service.cc",
    "document_suggestions_service.h",
    "favicon_cache.cc",
    "favicon_cache.h",
    "history_fuzzy_provider.cc",
    "history_fuzzy_provider.h",
    "history_match.cc",
    "history_match.h",
    "history_provider.cc",
    "history_provider.h",
    "history_quick_provider.cc",
    "history_quick_provider.h",
    "history_scoring_signals_annotator.cc",
    "history_scoring_signals_annotator.h",
    "history_url_provider.cc",
    "history_url_provider.h",
    "in_memory_url_index.cc",
    "in_memory_url_index.h",
    "in_memory_url_index_types.cc",
    "in_memory_url_index_types.h",
    "inline_autocompletion_util.cc",
    "inline_autocompletion_util.h",
    "intranet_redirector_state.cc",
    "intranet_redirector_state.h",
    "keyword_extensions_delegate.cc",
    "keyword_extensions_delegate.h",
    "keyword_provider.cc",
    "keyword_provider.h",
    "local_history_zero_suggest_provider.cc",
    "local_history_zero_suggest_provider.h",
    "match_compare.h",
    "most_visited_sites_provider.cc",
    "most_visited_sites_provider.h",
    "omnibox_client.cc",
    "omnibox_client.h",
    "omnibox_controller.cc",
    "omnibox_controller.h",
    "omnibox_edit_model.cc",
    "omnibox_edit_model.h",
    "omnibox_event_global_tracker.cc",
    "omnibox_event_global_tracker.h",
    "omnibox_feature_configs.cc",
    "omnibox_feature_configs.h",
    "omnibox_field_trial.cc",
    "omnibox_field_trial.h",
    "omnibox_log.cc",
    "omnibox_log.h",
    "omnibox_metrics_provider.cc",
    "omnibox_metrics_provider.h",
    "omnibox_navigation_observer.h",
    "omnibox_popup_selection.cc",
    "omnibox_popup_selection.h",
    "omnibox_popup_view.cc",
    "omnibox_popup_view.h",
    "omnibox_prefs.cc",
    "omnibox_prefs.h",
    "omnibox_triggered_feature_service.cc",
    "omnibox_triggered_feature_service.h",
    "omnibox_view.cc",
    "omnibox_view.h",
    "on_device_head_model.cc",
    "on_device_head_model.h",
    "on_device_head_provider.cc",
    "on_device_head_provider.h",
    "on_device_model_update_listener.cc",
    "on_device_model_update_listener.h",
    "on_device_tail_tokenizer.cc",
    "on_device_tail_tokenizer.h",
    "open_tab_provider.cc",
    "open_tab_provider.h",
    "page_classification_functions.cc",
    "page_classification_functions.h",
    "provider_state_service.cc",
    "provider_state_service.h",
    "remote_suggestions_service.cc",
    "remote_suggestions_service.h",
    "scored_history_match.cc",
    "scored_history_match.h",
    "scoring_functor.cc",
    "scoring_functor.h",
    "search_provider.cc",
    "search_provider.h",
    "search_scoring_signals_annotator.cc",
    "search_scoring_signals_annotator.h",
    "search_suggestion_parser.cc",
    "search_suggestion_parser.h",
    "shortcuts_backend.cc",
    "shortcuts_backend.h",
    "shortcuts_constants.cc",
    "shortcuts_constants.h",
    "shortcuts_database.cc",
    "shortcuts_database.h",
    "shortcuts_provider.cc",
    "shortcuts_provider.h",
    "suggestion_answer.cc",
    "suggestion_answer.h",
    "suggestion_group_util.cc",
    "suggestion_group_util.h",
    "tab_matcher.cc",
    "tab_matcher.h",
    "tailored_word_break_iterator.cc",
    "tailored_word_break_iterator.h",
    "titled_url_match_utils.cc",
    "titled_url_match_utils.h",
    "url_index_private_data.cc",
    "url_index_private_data.h",
    "url_prefix.cc",
    "url_prefix.h",
    "url_scoring_signals_annotator.cc",
    "url_scoring_signals_annotator.h",
    "verbatim_match.cc",
    "verbatim_match.h",
    "voice_suggest_provider.cc",
    "voice_suggest_provider.h",
    "zero_suggest_cache_service.cc",
    "zero_suggest_cache_service.h",
    "zero_suggest_provider.cc",
    "zero_suggest_provider.h",
    "zero_suggest_verbatim_match_provider.cc",
    "zero_suggest_verbatim_match_provider.h",
  ]

  public_deps = [
    ":buildflags",
    ":location_bar",
    ":mojo_bindings",
    "//base",
    "//base:i18n",
    "//components/history/core/browser",
    "//components/lens/proto/server:proto",
    "//components/omnibox/common",
    "//components/omnibox/resources:omnibox_pedal_synonyms",
    "//components/security_state/core",
    "//third_party/metrics_proto",
    "//third_party/omnibox_proto",
    "//url",
  ]

  deps = [
    "//build:branding_buildflags",
    "//components/bookmarks/browser",
    "//components/component_updater",
    "//components/dom_distiller/core:core",
    "//components/favicon/core",
    "//components/favicon_base",
    "//components/keyed_service/core",
    "//components/metrics",
    "//components/navigation_metrics",
    "//components/open_from_clipboard",
    "//components/optimization_guide:machine_learning_tflite_buildflags",
    "//components/optimization_guide/core:core",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/pref_registry",
    "//components/prefs",
    "//components/query_parser",
    "//components/resources",
    "//components/search",
    "//components/search_engines",
    "//components/sessions",
    "//components/signin/public/identity_manager",
    "//components/strings",
    "//components/sync",
    "//components/url_formatter",
    "//components/variations",
    "//components/variations/net",
    "//extensions/buildflags",
    "//net",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//skia",
    "//sql",
    "//third_party/protobuf:protobuf_lite",
    "//third_party/re2",
    "//ui/base",
    "//ui/gfx",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  if (is_android) {
    sources += [
      "actions/omnibox_action_factory_android.cc",
      "actions/omnibox_action_factory_android.h",
      "autocomplete_match_android.cc",
      "autocomplete_result_android.cc",
    ]
    deps += [
      ":jni_headers",
      "//url",
    ]
  } else {
    deps += [ "//components/keep_alive_registry" ]
  }

  if ((!is_android || enable_vr) && !is_ios) {
    deps += [ ":vector_icons" ]
  }

  if (is_chrome_branded) {
    deps += [ "//components/vector_icons" ]
  }

  if (!is_ios) {
    sources += [
      "history_embeddings_provider.cc",
      "history_embeddings_provider.h",
    ]
    deps += [
      "//components/history_embeddings",
      "//ui/base/clipboard",
    ]
  }

  if (use_blink) {
    sources += [
      "actions/history_clusters_action.cc",
      "actions/history_clusters_action.h",
      "history_cluster_provider.cc",
      "history_cluster_provider.h",
    ]
    deps += [
      "//components/history_clusters/core",
      "//components/history_embeddings",
      "//components/keyed_service/content",
      "//content/public/browser",
    ]
  }

  if (!is_android && !is_ios) {
    sources += [
      "featured_search_provider.cc",
      "featured_search_provider.h",
    ]
  }

  if (enable_extensions) {
    deps += [ "//extensions/common:common_constants" ]
    sources += [
      "omnibox_input_watcher.cc",
      "omnibox_input_watcher.h",
      "omnibox_suggestions_watcher.cc",
      "omnibox_suggestions_watcher.h",
    ]
  }

  if (build_with_tflite_lib) {
    sources += [
      "autocomplete_scoring_model_executor.cc",
      "autocomplete_scoring_model_executor.h",
      "autocomplete_scoring_model_handler.cc",
      "autocomplete_scoring_model_handler.h",
      "autocomplete_scoring_model_service.cc",
      "autocomplete_scoring_model_service.h",
      "on_device_tail_model_executor.cc",
      "on_device_tail_model_executor.h",
      "on_device_tail_model_service.cc",
      "on_device_tail_model_service.h",
    ]
    public_deps += [
      "//third_party/tflite",
      "//third_party/tflite:tflite_public_headers",
      "//third_party/tflite_support",
      "//third_party/tflite_support:tflite_support_proto",
    ]
  }
}

# A target that contains the minimal amount of code necessary for displaying a
# smart location bar. This code provides special processing of URLs without
# bringing in many extra dependencies.
static_library("location_bar") {
  sources = [
    "autocomplete_input.cc",
    "autocomplete_input.h",
    "autocomplete_scheme_classifier.h",
    "location_bar_model.h",
    "location_bar_model_delegate.cc",
    "location_bar_model_delegate.h",
    "location_bar_model_impl.cc",
    "location_bar_model_impl.h",
    "location_bar_model_util.cc",
    "location_bar_model_util.h",
  ]

  public_deps = [
    "//base",
    "//components/omnibox/common",
    "//components/security_state/core",
    "//third_party/metrics_proto",
    "//url",
  ]
  deps = [
    ":buildflags",
    "//build:chromeos_buildflags",
    "//components/dom_distiller/core:core",
    "//components/lens/proto/server:proto",
    "//components/safe_browsing/core/common:common",
    "//components/search_engines",
    "//components/strings",
    "//components/url_formatter",
    "//net",
    "//third_party/protobuf:protobuf_lite",
    "//third_party/re2",
    "//ui/base",
    "//ui/gfx",
  ]

  if (is_chromeos) {
    deps += [ "//chromeos/crosapi/cpp:cpp" ]
  }

  if (is_chromeos_ash) {
    deps += [ "//chromeos/constants" ]
  }

  if ((!is_android || enable_vr) && !is_ios) {
    deps += [ ":vector_icons" ]
  }

  if (is_android) {
    sources += [
      "autocomplete_scheme_classifier_android.cc",
      "autocomplete_scheme_classifier_android.h",
      "omnibox_url_emphasizer.cc",
    ]
    deps += [ ":scheme_classifier_jni" ]
  }
}

if (is_android) {
  android_resources("java_resources") {
    sources = [
      "android/java/res/drawable-hdpi/omnibox_https_valid.png",
      "android/java/res/drawable-hdpi/omnibox_info.png",
      "android/java/res/drawable-hdpi/omnibox_not_secure_warning.png",
      "android/java/res/drawable-mdpi/omnibox_https_valid.png",
      "android/java/res/drawable-mdpi/omnibox_info.png",
      "android/java/res/drawable-mdpi/omnibox_not_secure_warning.png",
      "android/java/res/drawable-xhdpi/omnibox_https_valid.png",
      "android/java/res/drawable-xhdpi/omnibox_info.png",
      "android/java/res/drawable-xhdpi/omnibox_not_secure_warning.png",
      "android/java/res/drawable-xxhdpi/omnibox_https_valid.png",
      "android/java/res/drawable-xxhdpi/omnibox_info.png",
      "android/java/res/drawable-xxhdpi/omnibox_not_secure_warning.png",
      "android/java/res/drawable-xxxhdpi/omnibox_https_valid.png",
      "android/java/res/drawable-xxxhdpi/omnibox_info.png",
      "android/java/res/drawable-xxxhdpi/omnibox_not_secure_warning.png",
      "android/java/res/drawable/action_call.xml",
      "android/java/res/drawable/action_directions.xml",
      "android/java/res/drawable/action_reviews.xml",
      "android/java/res/drawable/omnibox_dangerous.xml",
      "android/java/res/drawable/omnibox_https_valid_refresh.xml",
      "android/java/res/values/colors.xml",
      "android/java/res/values/drawables.xml",
    ]
    deps = [
      "//components/browser_ui/strings/android:browser_ui_strings_grd",
      "//ui/android:ui_java_resources",
    ]
  }

  generate_jni("scheme_classifier_jni") {
    sources = [
      "android/java/src/org/chromium/components/omnibox/AutocompleteSchemeClassifier.java",
      "android/java/src/org/chromium/components/omnibox/OmniboxUrlEmphasizer.java",
    ]
  }

  android_library("scheme_classifier_java") {
    resources_package = "org.chromium.components.omnibox"
    srcjar_deps = [ ":scheme_classifier_jni" ]
    sources = [
      "android/java/src/org/chromium/components/omnibox/AutocompleteSchemeClassifier.java",
      "android/java/src/org/chromium/components/omnibox/OmniboxUrlEmphasizer.java",
      "android/java/src/org/chromium/components/omnibox/SecurityStatusIcon.java",
    ]
    deps = [
      ":java_resources",
      "//chrome/browser/flags:java",
      "//components/embedder_support/android:util_java",
      "//components/security_state/core:security_state_enums_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  android_library("browser_java") {
    sources = [
      "android/java/src/org/chromium/components/omnibox/AutocompleteMatch.java",
      "android/java/src/org/chromium/components/omnibox/AutocompleteResult.java",
      "android/java/src/org/chromium/components/omnibox/SecurityButtonAnimationDelegate.java",
      "android/java/src/org/chromium/components/omnibox/SuggestionAnswer.java",
      "android/java/src/org/chromium/components/omnibox/action/OmniboxAction.java",
      "android/java/src/org/chromium/components/omnibox/action/OmniboxActionDelegate.java",
      "android/java/src/org/chromium/components/omnibox/action/OmniboxActionFactory.java",
      "android/java/src/org/chromium/components/omnibox/suggestions/OmniboxSuggestionUiType.java",
    ]

    resources_package = "org.chromium.components.omnibox"
    deps = [
      ":java_resources",
      "//base:base_java",
      "//build/android:build_java",
      "//components/browser_ui/settings/android:java",
      "//components/browser_ui/styles/android:java_resources",
      "//components/browser_ui/widget/android:java",
      "//components/embedder_support/android:util_java",
      "//components/security_state/core:security_state_enums_java",
      "//content/public/android:content_java",
      "//third_party/android_deps:protobuf_lite_runtime_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_collection_collection_java",
      "//third_party/androidx:androidx_core_core_java",
      "//third_party/androidx:androidx_interpolator_interpolator_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/metrics_proto:metrics_proto_java",
      "//ui/android:ui_full_java",
      "//url:gurl_java",
    ]

    public_deps = [
      ":scheme_classifier_java",
      "//third_party/omnibox_proto:omnibox_proto_java",
    ]

    srcjar_deps = [
      ":browser_java_enums_srcjar",
      ":jni_headers",
    ]
  }

  robolectric_library("junit") {
    resources_package = "org.chromium.components.omnibox"
    sources = [ "android/java/src/org/chromium/components/omnibox/AutocompleteResultUnitTest.java" ]
    deps = [
      ":browser_java",
      ":java_resources",
      ":junit_test_support",
      "//base:base_java",
      "//base:base_java_test_support",
      "//base:base_junit_test_support",
      "//components/browser_ui/settings/android:java",
      "//components/browser_ui/styles/android:java_resources",
      "//components/embedder_support/android:util_java",
      "//third_party/android_deps:protobuf_lite_runtime_java",
      "//third_party/junit:junit",
      "//third_party/mockito:mockito_java",
    ]
  }

  android_library("junit_test_support") {
    resources_package = "org.chromium.components.omnibox"
    testonly = true
    sources = [
      "//components/omnibox/browser/android/java/src/org/chromium/components/omnibox/AutocompleteMatchBuilder.java",
      "//components/omnibox/browser/android/java/src/org/chromium/components/omnibox/GroupConfigTestSupport.java",
    ]
    deps = [
      "//components/omnibox/browser:browser_java",
      "//third_party/android_deps:protobuf_lite_runtime_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_collection_collection_java",
      "//url:gurl_java",
      "//url:gurl_junit_test_support",
    ]
  }

  java_cpp_enum("browser_java_enums_srcjar") {
    sources = [
      "actions/omnibox_action_concepts.h",
      "actions/omnibox_action_in_suggest.cc",
      "actions/omnibox_pedal_concepts.h",
      "autocomplete_match.h",
      "autocomplete_match_type.h",
      "most_visited_sites_provider.cc",
      "suggestion_answer.h",
    ]
  }

  generate_jni("jni_headers") {
    sources = [
      "android/java/src/org/chromium/components/omnibox/AutocompleteMatch.java",
      "android/java/src/org/chromium/components/omnibox/AutocompleteResult.java",
      "android/java/src/org/chromium/components/omnibox/SuggestionAnswer.java",
      "android/java/src/org/chromium/components/omnibox/action/OmniboxAction.java",
      "android/java/src/org/chromium/components/omnibox/action/OmniboxActionFactory.java",
    ]
  }
}

static_library("test_support") {
  testonly = true
  sources = [
    "fake_autocomplete_provider.cc",
    "fake_autocomplete_provider.h",
    "fake_autocomplete_provider_client.cc",
    "fake_autocomplete_provider_client.h",
    "fake_tab_matcher.cc",
    "fake_tab_matcher.h",
    "history_test_util.cc",
    "history_test_util.h",
    "mock_autocomplete_provider_client.cc",
    "mock_autocomplete_provider_client.h",
    "mock_tab_matcher.cc",
    "mock_tab_matcher.h",
    "shortcuts_provider_test_util.cc",
    "shortcuts_provider_test_util.h",
    "test_location_bar_model.cc",
    "test_location_bar_model.h",
    "test_omnibox_client.cc",
    "test_omnibox_client.h",
    "test_omnibox_edit_model.cc",
    "test_omnibox_edit_model.h",
    "test_omnibox_view.cc",
    "test_omnibox_view.h",
    "test_scheme_classifier.cc",
    "test_scheme_classifier.h",
  ]

  public_deps = [
    ":browser",
    "//base",
  ]

  deps = [
    "//base/test:test_support",
    "//components/bookmarks/browser",
    "//components/bookmarks/test",
    "//components/history/core/browser",
    "//components/history/core/test",
    "//components/optimization_guide/core:core",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/prefs:test_support",
    "//components/resources",
    "//components/search_engines",
    "//components/search_engines:test_support",
    "//components/sessions",
    "//net",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/metrics_proto",
    "//ui/base",
    "//ui/gfx",
  ]

  if (toolkit_views) {
    # Needed to get the TOOLKIT_VIEWS define.
    deps += [ "//ui/views" ]
  }

  if (build_with_tflite_lib) {
    sources += [
      "fake_autocomplete_scoring_model_service.cc",
      "fake_autocomplete_scoring_model_service.h",
      "fake_on_device_tail_model_service.cc",
      "fake_on_device_tail_model_service.h",
    ]
  }

  if (!is_ios) {
    deps += [ "//components/history_embeddings" ]
  }
}

bundle_data("unit_tests_bundle_data") {
  visibility = [ ":unit_tests" ]
  testonly = true
  sources = [
    "//components/test/data/omnibox/Shortcuts.no_fill_into_edit.sql",
    "//components/test/data/omnibox/Shortcuts.v0.sql",
    "//components/test/data/omnibox/Shortcuts.v1.sql",
    "//components/test/data/omnibox/adder.tflite",
    "//components/test/data/omnibox/badword_hashes_test.txt",
    "//components/test/data/omnibox/denylist_test.txt",
    "//components/test/data/omnibox/in_memory_url_index_test.sql",
    "//components/test/data/omnibox/in_memory_url_index_test_limited.sql",
    "//components/test/data/omnibox/on_device_head_test_deep_model.bin",
    "//components/test/data/omnibox/on_device_head_test_model_index.bin",
    "//components/test/data/omnibox/test_tail_model.tflite",
    "//components/test/data/omnibox/vocab_i18n_test.txt",
    "//components/test/data/omnibox/vocab_test.txt",
  ]
  outputs = [ "{{bundle_resources_dir}}/" +
              "{{source_root_relative_dir}}/{{source_file_part}}" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "actions/omnibox_action_in_suggest_unittest.cc",
    "actions/omnibox_answer_action_unittest.cc",
    "actions/omnibox_pedal_provider_unittest.cc",
    "actions/omnibox_pedal_unittest.cc",
    "answers_cache_unittest.cc",
    "autocomplete_controller_metrics_unittest.cc",
    "autocomplete_controller_unittest.cc",
    "autocomplete_grouper_groups_unittest.cc",
    "autocomplete_grouper_sections_unittest.cc",
    "autocomplete_input_unittest.cc",
    "autocomplete_match_type_unittest.cc",
    "autocomplete_match_unittest.cc",
    "autocomplete_provider_unittest.cc",
    "autocomplete_result_unittest.cc",
    "base_search_provider_unittest.cc",
    "bookmark_provider_unittest.cc",
    "bookmark_scoring_signals_annotator_unittest.cc",
    "builtin_provider_unittest.cc",
    "calculator_provider_unittest.cc",
    "clipboard_provider_unittest.cc",
    "document_provider_unittest.cc",
    "document_suggestions_service_unittest.cc",
    "fake_autocomplete_controller.cc",
    "fake_autocomplete_controller.h",
    "favicon_cache_unittest.cc",
    "history_fuzzy_provider_unittest.cc",
    "history_provider_unittest.cc",
    "history_quick_provider_unittest.cc",
    "history_scoring_signals_annotator_unittest.cc",
    "history_url_provider_unittest.cc",
    "in_memory_url_index_types_unittest.cc",
    "in_memory_url_index_unittest.cc",
    "inline_autocompletion_util_unittest.cc",
    "keyword_provider_unittest.cc",
    "local_history_zero_suggest_provider_unittest.cc",
    "location_bar_model_impl_unittest.cc",
    "omnibox_controller_unittest.cc",
    "omnibox_edit_model_unittest.cc",
    "omnibox_field_trial_unittest.cc",
    "omnibox_metrics_provider_unittest.cc",
    "omnibox_popup_selection_unittest.cc",
    "omnibox_prefs_unittest.cc",
    "omnibox_triggered_feature_service_unittest.cc",
    "omnibox_view_unittest.cc",
    "on_device_head_model_unittest.cc",
    "on_device_head_provider_unittest.cc",
    "on_device_model_update_listener_unittest.cc",
    "on_device_tail_tokenizer_unittest.cc",
    "remote_suggestions_service_unittest.cc",
    "scored_history_match_unittest.cc",
    "search_suggestion_parser_unittest.cc",
    "shortcuts_backend_unittest.cc",
    "shortcuts_database_unittest.cc",
    "shortcuts_provider_unittest.cc",
    "suggestion_answer_unittest.cc",
    "suggestion_group_unittest.cc",
    "tailored_word_break_iterator_unittest.cc",
    "titled_url_match_utils_unittest.cc",
    "url_prefix_unittest.cc",
    "url_scoring_signals_annotator_unittest.cc",
    "voice_suggest_provider_unittest.cc",
    "zero_suggest_cache_service_unittest.cc",
    "zero_suggest_provider_unittest.cc",
    "zero_suggest_verbatim_match_provider_unittest.cc",
  ]

  if (is_android || is_ios) {
    sources += [ "most_visited_sites_provider_unittest.cc" ]
  }

  if ((!is_android || enable_vr) && !is_ios) {
    sources += [ "location_bar_model_util_unittest.cc" ]
  }
  if (build_with_tflite_lib) {
    sources += [
      "autocomplete_scoring_model_executor_unittest.cc",
      "autocomplete_scoring_model_handler_unittest.cc",
      "on_device_tail_model_executor_unittest.cc",
      "on_device_tail_model_service_unittest.cc",
    ]
  }

  if (!is_android && !is_ios) {
    sources += [ "featured_search_provider_unittest.cc" ]
  }

  deps = [
    ":browser",
    ":test_support",
    ":unit_tests_bundle_data",
    "//base",
    "//base/test:test_support",
    "//build:blink_buildflags",
    "//components/bookmarks/browser",
    "//components/bookmarks/test",
    "//components/dom_distiller/core:core",
    "//components/favicon/core/test:test_support",
    "//components/history/core/test",
    "//components/memory_pressure:test_support",
    "//components/ntp_tiles:ntp_tiles",
    "//components/omnibox/common",
    "//components/open_from_clipboard:test_support",
    "//components/optimization_guide/core:test_support",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/prefs:test_support",
    "//components/safe_browsing/core/common:common",
    "//components/search",
    "//components/search_engines",
    "//components/search_engines:test_support",
    "//components/sessions",
    "//components/signin/public/identity_manager:test_support",
    "//components/strings",
    "//components/sync_preferences:test_support",
    "//components/ukm:test_support",
    "//components/url_formatter",
    "//components/variations",
    "//components/variations:test_support",
    "//components/variations/net:net",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/network:test_support",
    "//sql",
    "//sql:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/base:test_support",
    "//ui/gfx:test_support",
    "//url",
  ]

  if ((!is_android || enable_vr) && !is_ios) {
    deps += [
      ":buildflags",
      "//components/omnibox/browser:vector_icons",
      "//components/vector_icons",
    ]
  }

  if (!is_ios) {
    sources += [
      "actions/history_clusters_action_unittest.cc",
      "history_cluster_provider_unittest.cc",
      "history_embeddings_provider_unittest.cc",
    ]
    deps += [
      "//components/history_embeddings",
      "//components/history_embeddings:unit_tests",
      "//ui/base/clipboard:clipboard_test_support",
    ]
  }

  if (is_chromeos) {
    deps += [ "//chromeos/constants:constants" ]
  }

  if (use_blink) {
    deps += [ "//components/history_clusters/core:test_support" ]
  }
}

fuzzer_test("autocomplete_input_fuzzer") {
  sources = [ "autocomplete_input_fuzzer.cc" ]
  deps = [
    ":browser",
    ":test_support",
    "//base",
    "//base:i18n",
    "//third_party/metrics_proto:metrics_proto",
  ]
}

fuzzer_test("omnibox_view_fuzzer") {
  sources = [ "omnibox_view_fuzzer.cc" ]
  deps = [
    ":browser",
    "//base",
  ]
}

fuzzer_test("search_suggestion_parser_fuzzer") {
  sources = [ "search_suggestion_parser_fuzzer.cc" ]
  deps = [
    ":browser",
    ":test_support",
    "//base",
    "//base:i18n",
    "//third_party/icu:icui18n",
    "//third_party/metrics_proto:metrics_proto",
  ]
  seed_corpus = "fuzz_corpus_suggest"
}

mojom("mojo_bindings") {
  sources = [ "omnibox.mojom" ]
  webui_module_path = "/"

  public_deps = [ "//mojo/public/mojom/base" ]
}