chromium/chrome/browser/autofill/BUILD.gn

# Copyright 2022 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/ui.gni")
import("//chrome/version.gni")
import("//components/optimization_guide/features.gni")
import("//extensions/buildflags/buildflags.gni")

assert(!is_fuchsia, "Fuchsia shouldn't use anything in //chrome")

static_library("autofill") {
  sources = [
    "address_normalizer_factory.cc",
    "address_normalizer_factory.h",
    "autocomplete_history_manager_factory.cc",
    "autocomplete_history_manager_factory.h",
    "autofill_image_fetcher_factory.cc",
    "autofill_image_fetcher_factory.h",
    "autofill_offer_manager_factory.cc",
    "autofill_offer_manager_factory.h",
    "autofill_optimization_guide_factory.cc",
    "autofill_optimization_guide_factory.h",
    "iban_manager_factory.cc",
    "iban_manager_factory.h",
    "merchant_promo_code_manager_factory.cc",
    "merchant_promo_code_manager_factory.h",
    "personal_data_manager_factory.cc",
    "personal_data_manager_factory.h",
    "strike_database_factory.cc",
    "strike_database_factory.h",
    "subkey_requester_factory.cc",
    "subkey_requester_factory.h",
    "ui/ui_util.cc",
    "ui/ui_util.h",
    "validation_rules_storage_factory.cc",
    "validation_rules_storage_factory.h",
  ]

  public_deps = [
    "//base",
    "//chrome/browser:browser_public_dependencies",
    "//chrome/browser/profiles:profile",
    "//components/autofill/core/browser",
    "//components/autofill/core/common",
    "//components/keyed_service/content",
    "//components/keyed_service/core",
    "//components/signin/public/identity_manager:identity_manager",
    "//content/public/browser",
    "//services/network/public/cpp",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//url",
  ]
  deps = [
    "//chrome/browser:browser_process",
    "//chrome/browser/profiles",
    "//chrome/browser/sync",
    "//chrome/common:constants",
    "//components/autofill/content/browser",
    "//components/image_fetcher/core",
    "//components/prefs",
    "//components/strings:components_strings_grit",
    "//components/variations/service",
    "//third_party/libphonenumber",
  ]
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  if (is_android) {
    sources += [
      "android/android_autofill_availability_status.h",
      "android/autofill_image_fetcher_impl.cc",
      "android/autofill_image_fetcher_impl.h",
      "android/personal_data_manager_android.cc",
      "android/personal_data_manager_android.h",
      "android/phone_number_util_android.cc",
      "android/save_update_address_profile_message_controller.cc",
      "android/save_update_address_profile_message_controller.h",
      "android/save_update_address_profile_prompt_controller.cc",
      "android/save_update_address_profile_prompt_controller.h",
      "android/save_update_address_profile_prompt_view.h",
      "manual_filling_view_interface.h",
    ]
    public_deps += [ "//components/messages/android" ]
    deps += [
      "//chrome/android:jni_headers",
      "//chrome/app:generated_resources",
      "//chrome/browser/autofill/android:jni_headers",
      "//chrome/browser/keyboard_accessory/android:public",
      "//components/autofill/android:autofill_core_browser_java_enums",
      "//components/autofill/android:payments_jni_headers",
      "//components/autofill/core/common:credit_card_number_validation",
      "//components/autofill/core/common/mojom:mojo_types",
      "//components/messages/android:feature_flags",
      "//components/password_manager/core/browser",
      "//third_party/libaddressinput",

      # TODO(crbug.com/352191610): Use //chrome/browser instead after fixing cyclic
      # dependency.
      "//chrome/browser/page_info:page_info_buildflags",
    ]
  } else {
    # !is_android
    sources += [
      "ui/autofill_image_fetcher_impl.cc",
      "ui/autofill_image_fetcher_impl.h",
    ]
    deps += [
      "//chrome/browser/image_fetcher",
      "//components/sync/base",
    ]
  }

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

static_library("test_support") {
  testonly = true

  sources = [
    "autofill_uitest_util.cc",
    "autofill_uitest_util.h",
    "mock_autofill_agent.cc",
    "mock_autofill_agent.h",
  ]

  deps = [
    "//chrome/browser/autofill:autofill",
    "//chrome/browser/profiles:profile",
    "//components/autofill/content/browser:browser",
    "//components/autofill/content/common/mojom",
    "//components/autofill/core/browser:test_support",
    "//content/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/gfx:test_support",
  ]

  public_deps = [
    "//base",
    "//chrome/browser/ui",
    "//components/autofill/core/browser",
  ]

  if (is_android) {
    sources += [
      "mock_manual_filling_view.cc",
      "mock_manual_filling_view.h",
    ]
    deps += [
      "//chrome/browser",
      "//chrome/browser/autofill",
      "//chrome/browser/keyboard_accessory/test_utils/android",
    ]
  }
}

if (!is_android) {
  source_set("browser_tests") {
    testonly = true

    sources = [
      "autocomplete_browsertest.cc",
      "autofill_across_iframes_browsertest.cc",
      "autofill_browsertest.cc",
      "autofill_metrics_browsertest.cc",
      "autofill_server_browsertest.cc",
      "form_structure_browsertest.cc",
    ]

    defines = [
      "HAS_OUT_OF_PROC_TEST_RUNNER",
      "CHROME_VERSION_MAJOR=" + chrome_version_major,
    ]

    deps = [
      "//chrome/browser/autofill",
      "//chrome/browser/ui:browser_navigator_params_headers",
      "//chrome/test:test_support",
      "//components/autofill/content/browser:test_support",
      "//components/autofill/core/common:test_support",
      "//components/password_manager/content/browser:test_support",
      "//components/ukm:test_support",
      "//testing/data_driven_testing",
    ]
  }
}

if (!is_android) {
  source_set("test_support_ui") {
    testonly = true

    sources = [
      "autofill_flow_test_util.cc",
      "autofill_flow_test_util.h",
      "autofill_uitest.cc",
      "autofill_uitest.h",
      "captured_sites_test_utils.cc",
      "captured_sites_test_utils.h",
    ]

    deps = [
      "//chrome/browser/autofill",
      "//chrome/test:test_support",
      "//chrome/test:test_support",
      "//chrome/test:test_support_ui",
      "//components/javascript_dialogs",
    ]
  }

  source_set("interactive_ui_tests") {
    testonly = true

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    sources = [ "autofill_interactive_uitest.cc" ]

    deps = [
      ":test_support",
      ":test_support_ui",
      "//base",
      "//base/test:test_support",
      "//build:chromeos_buildflags",
      "//chrome/browser",
      "//chrome/browser/profiles:profile",
      "//chrome/browser/ui",
      "//chrome/common:chrome_features",
      "//chrome/common:non_code_constants",
      "//chrome/test:test_support",
      "//chrome/test:test_support_ui",
      "//components/autofill/content/browser",
      "//components/autofill/content/browser:test_support",
      "//components/autofill/core/browser",
      "//components/autofill/core/browser:test_support",
      "//components/autofill/core/common",
      "//components/autofill/core/common:features",
      "//components/metrics:content",
      "//components/network_session_configurator/common",
      "//components/translate/core/browser",
      "//components/translate/core/common",
      "//content/public/browser",
      "//content/public/common",
      "//content/test:test_support",
      "//net",
      "//net:test_support",
      "//testing/gmock",
      "//testing/gtest",
      "//third_party/abseil-cpp:absl",
      "//third_party/blink/public/common:headers",
      "//ui/events:dom_keycode_converter",
      "//ui/events:events_base",
    ]

    if (is_chromeos_ash && enable_extensions) {
      deps += [
        "//chrome/browser/ash/accessibility",
        "//chrome/browser/ash/accessibility:test_support",
        "//extensions/browser:test_support",
        "//ui/base:test_support",
      ]
    }

    if (use_aura) {
      deps += [ "//chrome/browser/ui/aura/accessibility" ]
    }
  }
}

if (!is_android) {
  source_set("captured_sites_interactive_tests") {
    testonly = true

    sources = [ "autofill_captured_sites_interactive_uitest.cc" ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    deps = [
      "//chrome/browser/autofill:test_support_ui",
      "//chrome/test:test_support",
      "//components/autofill/core/common:autofill_regex",
    ]
  }
}