chromium/components/webauthn/android/BUILD.gn

# Copyright 2021 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("//third_party/jni_zero/jni_zero.gni")

generate_jni("jni_headers") {
  sources = [
    "java/src/org/chromium/components/webauthn/Fido2Api.java",
    "java/src/org/chromium/components/webauthn/Fido2CredentialRequest.java",
    "java/src/org/chromium/components/webauthn/InternalAuthenticator.java",
    "java/src/org/chromium/components/webauthn/WebauthnBrowserBridge.java",
    "java/src/org/chromium/components/webauthn/WebauthnModeProvider.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManSupportProvider.java",
  ]
}

java_cpp_enum("java_enums_srcjar") {
  sources = [
    "cred_man_support.h",
    "webauthn_mode.h",
  ]
  visibility = [ ":*" ]
}

android_library("java") {
  srcjar_deps = [
    ":java_enums_srcjar",
    ":jni_headers",
  ]
  sources = [
    "java/src/org/chromium/components/webauthn/AuthenticationContextProvider.java",
    "java/src/org/chromium/components/webauthn/AuthenticatorFactory.java",
    "java/src/org/chromium/components/webauthn/AuthenticatorImpl.java",
    "java/src/org/chromium/components/webauthn/Barrier.java",
    "java/src/org/chromium/components/webauthn/CreateConfirmationUiDelegate.java",
    "java/src/org/chromium/components/webauthn/Fido2Api.java",
    "java/src/org/chromium/components/webauthn/Fido2ApiCall.java",
    "java/src/org/chromium/components/webauthn/Fido2ApiCallHelper.java",
    "java/src/org/chromium/components/webauthn/Fido2CredentialRequest.java",
    "java/src/org/chromium/components/webauthn/FidoErrorResponseCallback.java",
    "java/src/org/chromium/components/webauthn/FidoIntentSender.java",
    "java/src/org/chromium/components/webauthn/GetAssertionResponseCallback.java",
    "java/src/org/chromium/components/webauthn/GetMatchingCredentialIdsResponseCallback.java",
    "java/src/org/chromium/components/webauthn/GmsCoreUtils.java",
    "java/src/org/chromium/components/webauthn/GpmBrowserOptionsHelper.java",
    "java/src/org/chromium/components/webauthn/InternalAuthenticator.java",
    "java/src/org/chromium/components/webauthn/IsUvpaaResponseCallback.java",
    "java/src/org/chromium/components/webauthn/MakeCredentialResponseCallback.java",
    "java/src/org/chromium/components/webauthn/WebauthnBrowserBridge.java",
    "java/src/org/chromium/components/webauthn/WebauthnCredentialDetails.java",
    "java/src/org/chromium/components/webauthn/WebauthnModeProvider.java",
    "java/src/org/chromium/components/webauthn/cred_man/AppCredManRequestDecorator.java",
    "java/src/org/chromium/components/webauthn/cred_man/BrowserCredManRequestDecorator.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManCreateCredentialRequestHelper.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManGetCredentialRequestHelper.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManHelper.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManMetricsHelper.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManRequestDecorator.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManSupportProvider.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManUiRecommender.java",
    "java/src/org/chromium/components/webauthn/cred_man/CredManUiRecommenderProvider.java",
    "java/src/org/chromium/components/webauthn/cred_man/GpmCredManRequestDecorator.java",
  ]

  deps = [
    "$google_play_services_package:google_play_services_base_java",
    "$google_play_services_package:google_play_services_basement_java",
    "$google_play_services_package:google_play_services_tasks_java",
    "//base:base_java",
    "//base/version_info/android:version_constants_java",
    "//build/android:build_java",
    "//components/externalauth/android:java",
    "//content/public/android:content_java",
    "//content/public/common:common_java",
    "//mojo/public/java:bindings_java",
    "//mojo/public/java:system_java",
    "//mojo/public/mojom/base:base_java",
    "//net/android:net_java",
    "//services/device/public/java:device_feature_list_java",
    "//services/service_manager/public/java:service_manager_java",
    "//third_party/androidx:androidx_annotation_annotation_experimental_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/blink/public/mojom:android_mojo_bindings_java",
    "//third_party/jni_zero:jni_zero_java",
    "//ui/android:ui_no_recycler_view_java",
    "//url:gurl_java",
    "//url/mojom:url_mojom_gurl_java",
  ]

  resources_package = "org.chromium.components.webauthn"
}

static_library("test_support") {
  testonly = true
  sources = [
    "mock_webauthn_cred_man_delegate.cc",
    "mock_webauthn_cred_man_delegate.h",
    "webauthn_cred_man_delegate_factory_test_api.h",
  ]
  deps = [
    ":android",
    "//base:base",
    "//testing/gmock",
  ]
}

android_library("test_support_java") {
  testonly = true
  sources = [
    "java/src/org/chromium/components/webauthn/Fido2ApiTestHelper.java",
    "java/src/org/chromium/components/webauthn/MockFido2CredentialRequest.java",
  ]
  deps = [
    ":java",
    "//base:base_java_test_support",
    "//components/payments/content/android:feature_list_java",
    "//components/payments/mojom:mojom_java",
    "//content/public/android:content_java",
    "//mojo/public/mojom/base:base_java",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/blink/public/mojom:android_mojo_bindings_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit:junit",
    "//url:gurl_java",
    "//url/mojom:url_mojom_gurl_java",
    "//url/mojom:url_mojom_origin_java",
  ]
}

source_set("android") {
  sources = [
    "cred_man_support.h",
    "fido2api_native_android.cc",
    "fido2credentialrequest_native_android.cc",
    "internal_authenticator_android.cc",
    "internal_authenticator_android.h",
    "webauthn_browser_bridge.cc",
    "webauthn_browser_bridge.h",
    "webauthn_client_android.cc",
    "webauthn_client_android.h",
    "webauthn_cred_man_delegate.cc",
    "webauthn_cred_man_delegate.h",
    "webauthn_cred_man_delegate_factory.cc",
    "webauthn_cred_man_delegate_factory.h",
    "webauthn_mode.h",
    "webauthn_mode_provider.cc",
  ]
  deps = [
    ":jni_headers",
    "//base",
    "//components/cbor",
    "//components/webauthn/core/browser",
    "//components/webauthn/json",
    "//content/public/browser",
    "//device/fido",
    "//third_party/blink/public/mojom:android_mojo_bindings_blink",
    "//third_party/boringssl",
    "//url",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "webauthn_cred_man_delegate_factory_unittest.cc",
    "webauthn_cred_man_delegate_unittest.cc",
  ]
  deps = [
    ":android",
    "//base/test:test_support",
    "//content/public/browser",
    "//content/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

robolectric_library("junit") {
  sources = [
    "junit/src/org/chromium/components/webauthn/BarrierTest.java",
    "junit/src/org/chromium/components/webauthn/Fido2CredentialRequestRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/ShadowWebContentStatics.java",
    "junit/src/org/chromium/components/webauthn/WebauthnModeProviderRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/CredManCreateCredentialRequestHelperRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/CredManGetCredentialRequestHelperRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/CredManHelperRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/CredManUiRecommenderProviderRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/GpmCredManRequestDecoratorRobolectricTest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCreateCredentialException.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCreateCredentialRequest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCreateCredentialResponse.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCredential.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCredentialManager.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowCredentialOption.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowGetCredentialException.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowGetCredentialRequest.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowGetCredentialResponse.java",
    "junit/src/org/chromium/components/webauthn/cred_man/ShadowPrepareGetCredentialResponse.java",
  ]
  deps = [
    ":java",
    ":test_support_java",
    "$google_play_services_package:google_play_services_tasks_java",
    "//base:base_java",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//content/public/android:content_java",
    "//net/android:net_java",
    "//services/device/public/java:device_feature_list_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/blink/public/mojom:android_mojo_bindings_java",
    "//third_party/google-truth:google_truth_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit",
    "//third_party/mockito:mockito_java",
    "//ui/android:ui_no_recycler_view_java",
    "//url:gurl_java",
  ]
}