chromium/components/autofill/android/BUILD.gn

# Copyright 2016 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/android/rules.gni")
import("//build/config/locales.gni")
import("//third_party/jni_zero/jni_zero.gni")
import("//tools/grit/grit_rule.gni")

static_library("keyboard_suppressor") {
  sources = [
    "touch_to_fill_keyboard_suppressor.cc",
    "touch_to_fill_keyboard_suppressor.h",
  ]
  public_deps = [
    "//base",
    "//components/autofill/content/browser",
    "//components/autofill/core/browser",
  ]
  deps = [
    "//components/autofill/core/common",
    "//content/public/browser",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [ "touch_to_fill_keyboard_suppressor_unittest.cc" ]
  deps = [
    ":keyboard_suppressor",
    "//base",
    "//components/autofill/content/browser:test_support",
    "//components/autofill/core/browser",
    "//components/autofill/core/browser:test_support",
    "//components/autofill/core/common",
    "//content/public/browser",
    "//content/public/common",
    "//content/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

java_strings_grd("autofill_strings_grd") {
  grd_file = "java/strings/autofill_strings.grd"
  outputs = [ "values/autofill_strings.xml" ] +
            process_file_template(
                android_bundle_locales_as_resources,
                [ "values-{{source_name_part}}/autofill_strings.xml" ])
}

android_resources("autofill_payments_java_resources") {
  sources = [
    "payments/java/res/drawable-hdpi/amex_card.png",
    "payments/java/res/drawable-hdpi/amex_metadata_card.png",
    "payments/java/res/drawable-hdpi/capitalone_metadata_card.png",
    "payments/java/res/drawable-hdpi/diners_card.png",
    "payments/java/res/drawable-hdpi/diners_metadata_card.png",
    "payments/java/res/drawable-hdpi/discover_metadata_card.png",
    "payments/java/res/drawable-hdpi/elo_metadata_card.png",
    "payments/java/res/drawable-hdpi/ic_metadata_credit_card.png",
    "payments/java/res/drawable-hdpi/jcb_card.png",
    "payments/java/res/drawable-hdpi/jcb_metadata_card.png",
    "payments/java/res/drawable-hdpi/mc_card.png",
    "payments/java/res/drawable-hdpi/mc_metadata_card.png",
    "payments/java/res/drawable-hdpi/mir_metadata_card.png",
    "payments/java/res/drawable-hdpi/troy_card.png",
    "payments/java/res/drawable-hdpi/troy_metadata_card.png",
    "payments/java/res/drawable-hdpi/unionpay_card.png",
    "payments/java/res/drawable-hdpi/unionpay_metadata_card.png",
    "payments/java/res/drawable-hdpi/verve_card.png",
    "payments/java/res/drawable-hdpi/verve_metadata_card.png",
    "payments/java/res/drawable-hdpi/visa_metadata_card.png",
    "payments/java/res/drawable-mdpi/amex_card.png",
    "payments/java/res/drawable-mdpi/amex_metadata_card.png",
    "payments/java/res/drawable-mdpi/capitalone_metadata_card.png",
    "payments/java/res/drawable-mdpi/diners_card.png",
    "payments/java/res/drawable-mdpi/diners_metadata_card.png",
    "payments/java/res/drawable-mdpi/discover_metadata_card.png",
    "payments/java/res/drawable-mdpi/elo_metadata_card.png",
    "payments/java/res/drawable-mdpi/ic_metadata_credit_card.png",
    "payments/java/res/drawable-mdpi/jcb_card.png",
    "payments/java/res/drawable-mdpi/jcb_metadata_card.png",
    "payments/java/res/drawable-mdpi/mc_card.png",
    "payments/java/res/drawable-mdpi/mc_metadata_card.png",
    "payments/java/res/drawable-mdpi/mir_metadata_card.png",
    "payments/java/res/drawable-mdpi/troy_card.png",
    "payments/java/res/drawable-mdpi/troy_metadata_card.png",
    "payments/java/res/drawable-mdpi/unionpay_card.png",
    "payments/java/res/drawable-mdpi/unionpay_metadata_card.png",
    "payments/java/res/drawable-mdpi/verve_card.png",
    "payments/java/res/drawable-mdpi/verve_metadata_card.png",
    "payments/java/res/drawable-mdpi/visa_metadata_card.png",
    "payments/java/res/drawable-xhdpi/amex_card.png",
    "payments/java/res/drawable-xhdpi/amex_metadata_card.png",
    "payments/java/res/drawable-xhdpi/capitalone_metadata_card.png",
    "payments/java/res/drawable-xhdpi/diners_card.png",
    "payments/java/res/drawable-xhdpi/diners_metadata_card.png",
    "payments/java/res/drawable-xhdpi/discover_metadata_card.png",
    "payments/java/res/drawable-xhdpi/elo_metadata_card.png",
    "payments/java/res/drawable-xhdpi/ic_metadata_credit_card.png",
    "payments/java/res/drawable-xhdpi/jcb_card.png",
    "payments/java/res/drawable-xhdpi/jcb_metadata_card.png",
    "payments/java/res/drawable-xhdpi/mc_card.png",
    "payments/java/res/drawable-xhdpi/mc_metadata_card.png",
    "payments/java/res/drawable-xhdpi/mir_metadata_card.png",
    "payments/java/res/drawable-xhdpi/troy_card.png",
    "payments/java/res/drawable-xhdpi/troy_metadata_card.png",
    "payments/java/res/drawable-xhdpi/unionpay_card.png",
    "payments/java/res/drawable-xhdpi/unionpay_metadata_card.png",
    "payments/java/res/drawable-xhdpi/verve_card.png",
    "payments/java/res/drawable-xhdpi/verve_metadata_card.png",
    "payments/java/res/drawable-xhdpi/visa_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/amex_card.png",
    "payments/java/res/drawable-xxhdpi/amex_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/capitalone_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/diners_card.png",
    "payments/java/res/drawable-xxhdpi/diners_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/discover_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/elo_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/ic_metadata_credit_card.png",
    "payments/java/res/drawable-xxhdpi/jcb_card.png",
    "payments/java/res/drawable-xxhdpi/jcb_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/mc_card.png",
    "payments/java/res/drawable-xxhdpi/mc_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/mir_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/troy_card.png",
    "payments/java/res/drawable-xxhdpi/troy_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/unionpay_card.png",
    "payments/java/res/drawable-xxhdpi/unionpay_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/verve_card.png",
    "payments/java/res/drawable-xxhdpi/verve_metadata_card.png",
    "payments/java/res/drawable-xxhdpi/visa_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/amex_card.png",
    "payments/java/res/drawable-xxxhdpi/amex_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/capitalone_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/diners_card.png",
    "payments/java/res/drawable-xxxhdpi/diners_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/discover_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/elo_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/ic_metadata_credit_card.png",
    "payments/java/res/drawable-xxxhdpi/jcb_card.png",
    "payments/java/res/drawable-xxxhdpi/jcb_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/mc_card.png",
    "payments/java/res/drawable-xxxhdpi/mc_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/mir_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/troy_card.png",
    "payments/java/res/drawable-xxxhdpi/troy_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/unionpay_card.png",
    "payments/java/res/drawable-xxxhdpi/unionpay_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/verve_card.png",
    "payments/java/res/drawable-xxxhdpi/verve_metadata_card.png",
    "payments/java/res/drawable-xxxhdpi/visa_metadata_card.png",
    "payments/java/res/drawable/discover_card.xml",
    "payments/java/res/drawable/elo_card.xml",
    "payments/java/res/drawable/iban_icon.xml",
    "payments/java/res/drawable/ic_credit_card_black.xml",
    "payments/java/res/drawable/ic_credit_card_primary.xml",
    "payments/java/res/drawable/ic_offer_tag.xml",
    "payments/java/res/drawable/mir_card.xml",
    "payments/java/res/drawable/visa_card.xml",
  ]
  deps = [ "//ui/android:ui_java_resources" ]
}

android_resources("autofill_java_resources") {
  sources = [
    "java/res/layout/autofill_dropdown_item.xml",
    "java/res/values/colors.xml",
    "java/res/values/dimens.xml",
  ]
  deps = [
    ":autofill_strings_grd",
    "//components/browser_ui/widget/android/shared_with_webview:java_resources",
    "//ui/android:ui_java_resources",
  ]
}

java_cpp_enum("autofill_core_browser_java_enums") {
  sources = [
    "../core/browser/data_model/autofill_profile.h",
    "../core/browser/data_model/autofill_structured_address_component.h",
    "../core/browser/data_model/credit_card.h",
    "../core/browser/data_model/iban.h",
    "../core/browser/field_types.h",
    "../core/browser/metrics/payments/mandatory_reauth_metrics.h",
    "../core/browser/metrics/payments/virtual_card_enrollment_metrics.h",
    "../core/browser/payments/card_unmask_challenge_option.h",
    "../core/browser/ui/payments/payments_bubble_closed_reasons.h",
    "../core/browser/ui/suggestion.h",
    "../core/browser/ui/suggestion_type.h",
  ]
}

java_cpp_enum("payments_autofill_core_browser_java_enums") {
  sources = [
    "../core/browser/data_model/bank_account.h",
    "../core/browser/data_model/payment_instrument.h",
  ]
}

java_cpp_features("java_features_srcjar") {
  visibility = [ ":*" ]
  sources = [
    "//components/autofill/core/common/autofill_features.cc",
    "//components/autofill/core/common/autofill_payments_features.cc",
  ]
  template =
      "//components/autofill/android/java_templates/AutofillFeatures.java.tmpl"
}

java_cpp_strings("java_switches_srcjar") {
  visibility = [ ":*" ]
  sources = [ "//components/autofill/core/common/autofill_switches.cc" ]
  template = "java_templates/AutofillSwitches.java.tmpl"
}

# We intentionally do not include :autofill_payments_java_resources not to
# bloat targets that may not require it.
android_library("main_autofill_java") {
  deps = [
    ":autofill_java_resources",
    ":payments_autofill_java",
    "//base:base_java",
    "//content/public/android:content_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/jni_zero:jni_zero_java",
    "//ui/android:ui_no_recycler_view_java",
    "//url:gurl_java",
  ]
  sources = [
    "java/src/org/chromium/components/autofill/AddressNormalizer.java",
    "java/src/org/chromium/components/autofill/AutofillDelegate.java",
    "java/src/org/chromium/components/autofill/AutofillDropdownAdapter.java",
    "java/src/org/chromium/components/autofill/AutofillPopup.java",
    "java/src/org/chromium/components/autofill/AutofillProfile.java",
    "java/src/org/chromium/components/autofill/AutofillSuggestion.java",
    "java/src/org/chromium/components/autofill/SubKeyRequester.java",
  ]
  srcjar_deps = [
    ":autofill_core_browser_java_enums",
    ":main_autofill_jni_headers",
  ]
  resources_package = "org.chromium.components.autofill"
}

generate_jni("main_autofill_jni_headers") {
  sources = [
    "java/src/org/chromium/components/autofill/AddressNormalizer.java",
    "java/src/org/chromium/components/autofill/AutofillProfile.java",
    "java/src/org/chromium/components/autofill/SubKeyRequester.java",
  ]
}

# A minimal library used to expose autofill features to webview.
android_library("autofill_features_java") {
  srcjar_deps = [ ":java_features_srcjar" ]
}

# A minimal library used to expose autofill switches to java.
android_library("autofill_switches_java") {
  srcjar_deps = [ ":java_switches_srcjar" ]
}

# A library containing the minimal deps for payments, so that ui_java_resources
# doesn't have to be pulled in.
android_library("payments_autofill_java") {
  sources = [
    "java/src/org/chromium/components/autofill/Completable.java",
    "java/src/org/chromium/components/autofill/EditableOption.java",
    "java/src/org/chromium/components/autofill/payments/AutofillSaveCardUiInfo.java",
    "java/src/org/chromium/components/autofill/payments/AutofillSaveIbanUiInfo.java",
    "java/src/org/chromium/components/autofill/payments/BankAccount.java",
    "java/src/org/chromium/components/autofill/payments/CardDetail.java",
    "java/src/org/chromium/components/autofill/payments/LegalMessageLine.java",
    "java/src/org/chromium/components/autofill/payments/PaymentInstrument.java",
  ]
  deps = [
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/jni_zero:jni_zero_java",
    "//url:gurl_java",
  ]
  srcjar_deps = [
    ":payments_autofill_core_browser_java_enums",
    ":payments_jni_headers",
  ]
}

robolectric_library("payments_autofill_junit_tests") {
  sources = [
    "javatests/src/org/chromium/components/autofill/payments/AutofillSaveCardUiInfoTest.java",
    "javatests/src/org/chromium/components/autofill/payments/AutofillSaveIbanUiInfoTest.java",
    "javatests/src/org/chromium/components/autofill/payments/BankAccountTest.java",
    "javatests/src/org/chromium/components/autofill/payments/CardDetailTest.java",
    "javatests/src/org/chromium/components/autofill/payments/LegalMessageLineTest.java",
    "javatests/src/org/chromium/components/autofill/payments/PaymentInstrumentTest.java",
  ]
  deps = [
    ":payments_autofill_java",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//third_party/android_deps:guava_android_java",
    "//third_party/google-truth:google_truth_java",
    "//third_party/hamcrest:hamcrest_core_java",
    "//third_party/hamcrest:hamcrest_library_java",
    "//third_party/junit:junit",
    "//third_party/mockito:mockito_java",
    "//url:url_java",
  ]
}

generate_jni("payments_jni_headers") {
  sources = [
    "java/src/org/chromium/components/autofill/payments/AutofillSaveCardUiInfo.java",
    "java/src/org/chromium/components/autofill/payments/AutofillSaveIbanUiInfo.java",
    "java/src/org/chromium/components/autofill/payments/BankAccount.java",
    "java/src/org/chromium/components/autofill/payments/LegalMessageLine.java",
    "java/src/org/chromium/components/autofill/payments/PaymentInstrument.java",
  ]
}

static_library("payments_autofill_cc") {
  sources = [
    "payments/legal_message_line_android.cc",
    "payments/legal_message_line_android.h",
  ]
  deps = [
    ":payments_jni_headers",
    "//base",
    "//components/autofill/core/browser:legal_message_line",
  ]
}

java_group("autofill_java") {
  deps = [
    ":main_autofill_java",
    ":payments_autofill_java",
  ]
}