chromium/chrome/browser/password_manager/android/BUILD.gn

# Copyright 2020 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("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/jni_zero/jni_zero.gni")
import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")

java_cpp_enum("android_backend_java_enums_srcjar") {
  sources = [ "chromesync_status_code.h" ]
}

# Wrap the java_cpp_enum in android_library so it can be used by both
# chrome_java and modules.
android_library("android_backend_java_enums") {
  deps = [ "//third_party/androidx:androidx_annotation_annotation_java" ]
  srcjar_deps = [ ":android_backend_java_enums_srcjar" ]
}

source_set("backend_public") {
  sources = [
    "password_manager_settings_service_android_impl.cc",
    "password_manager_settings_service_android_impl.h",
  ]

  deps = [
    ":backend",
    ":utils",
    "//chrome/browser/autofill",
    "//chrome/browser/profiles:profile",
    "//components/keyed_service/content:content",
    "//components/password_manager/core/browser:browser",
    "//components/password_manager/core/browser/features:password_features",
    "//components/prefs:prefs",
    "//components/sync/service",
    "//content/public/browser",
  ]
}

source_set("backend") {
  visibility = [
    ":backend_public",
    ":unit_tests",
    "//chrome/browser/password_manager:backend_factory",
    "//chrome/browser/ui",
  ]

  sources = [
    "android_backend_with_double_deletion.cc",
    "android_backend_with_double_deletion.h",
    "built_in_backend_to_android_backend_migrator.cc",
    "built_in_backend_to_android_backend_migrator.h",
    "password_manager_lifecycle_helper.cc",
    "password_manager_lifecycle_helper.h",
    "password_manager_lifecycle_helper_impl.cc",
    "password_manager_lifecycle_helper_impl.h",
    "password_settings_updater_android_bridge_helper.h",
    "password_settings_updater_android_bridge_helper_impl.cc",
    "password_settings_updater_android_bridge_helper_impl.h",
    "password_settings_updater_android_dispatcher_bridge.h",
    "password_settings_updater_android_dispatcher_bridge_impl.cc",
    "password_settings_updater_android_dispatcher_bridge_impl.h",
    "password_settings_updater_android_receiver_bridge.h",
    "password_settings_updater_android_receiver_bridge_impl.cc",
    "password_settings_updater_android_receiver_bridge_impl.h",
    "password_store_android_account_backend.cc",
    "password_store_android_account_backend.h",
    "password_store_android_backend.cc",
    "password_store_android_backend.h",
    "password_store_android_backend_bridge_helper.h",
    "password_store_android_backend_bridge_helper_impl.cc",
    "password_store_android_backend_bridge_helper_impl.h",
    "password_store_android_backend_dispatcher_bridge.h",
    "password_store_android_backend_dispatcher_bridge_impl.cc",
    "password_store_android_backend_dispatcher_bridge_impl.h",
    "password_store_android_backend_receiver_bridge.h",
    "password_store_android_backend_receiver_bridge_impl.cc",
    "password_store_android_backend_receiver_bridge_impl.h",
    "password_store_android_local_backend.cc",
    "password_store_android_local_backend.h",
    "password_store_backend_migration_decorator.cc",
    "password_store_backend_migration_decorator.h",
    "password_store_proxy_backend.cc",
    "password_store_proxy_backend.h",
    "password_sync_controller_delegate_android.cc",
    "password_sync_controller_delegate_android.h",
    "password_sync_controller_delegate_bridge.h",
    "password_sync_controller_delegate_bridge_impl.cc",
    "password_sync_controller_delegate_bridge_impl.h",
    "unified_password_manager_proto_utils.cc",
    "unified_password_manager_proto_utils.h",
  ]

  public_deps = [ "//base" ]

  deps = [
    ":jni_headers",
    ":unified_password_manager_proto",
    ":utils",
    "//components/autofill/core/common:autofill_regex",
    "//components/browser_sync",
    "//components/browser_ui/device_lock/android:android",
    "//components/password_manager/core/browser:browser",
    "//components/password_manager/core/browser:password_form",
    "//components/password_manager/core/browser/affiliation:affiliation_fetching",
    "//components/password_manager/core/browser/affiliation:affiliation_match_helper",
    "//components/password_manager/core/browser/features:password_features",
    "//components/password_manager/core/common:common",
    "//components/password_manager/core/common:features",
    "//components/prefs:prefs",
    "//components/sync/model:model",
    "//components/sync/protocol:protocol",
  ]
}

android_library("java") {
  deps = [
    ":android_backend_java_enums",
    ":java_resources",
    ":settings_interface_java",
    "$google_play_services_package:google_play_services_base_java",
    "$google_play_services_package:google_play_services_basement_java",
    "account_storage_notice:java",
    "//base:base_java",
    "//build/android:build_java",
    "//chrome/browser/device_reauth/android:java",
    "//chrome/browser/flags:java",
    "//chrome/browser/lifetime/android:java",
    "//chrome/browser/loading_modal/android:java",
    "//chrome/browser/notifications:java",
    "//chrome/browser/password_manager/android/access_loss:helper_java",
    "//chrome/browser/password_manager/android/access_loss:java",
    "//chrome/browser/preferences:java",
    "//chrome/browser/profiles/android:java",
    "//chrome/browser/settings:java",
    "//chrome/browser/signin/services/android:java",
    "//chrome/browser/sync/android:java",
    "//chrome/browser/ui/android/strings:ui_strings_grd",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/browser_ui/modaldialog/android:java",
    "//components/browser_ui/notifications/android:java",
    "//components/browser_ui/settings/android:java",
    "//components/browser_ui/settings/android:managed_prefs_java_resources",
    "//components/browser_ui/widget/android:java",
    "//components/browser_ui/widget/android:java_resources",
    "//components/device_reauth:device_reauth_java_enums",
    "//components/password_manager/core/browser:password_manager_java_enums",
    "//components/prefs/android:java",
    "//components/signin/public/android:java",
    "//components/strings:components_strings_grd",
    "//components/sync/android:sync_java",
    "//components/sync/protocol:protocol_java",
    "//components/user_prefs/android:java",
    "//content/public/android:content_java",
    "//third_party/android_deps:protobuf_lite_runtime_java",
    "//third_party/androidx:androidx_activity_activity_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_appcompat_appcompat_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/androidx:androidx_fragment_fragment_java",
    "//third_party/androidx:androidx_preference_preference_java",
    "//third_party/jni_zero:jni_zero_java",
    "//ui/android:ui_no_recycler_view_java",
    "//url:gurl_java",
  ]

  public_deps = [
    ":backend_interface_java",
    ":password_manager_resource_provider_java",
  ]

  srcjar_deps = [ ":jni_headers" ]
  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/ConfirmationDialogHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/OutdatedGmsCoreDialog.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientMetricsRecorder.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerAndroidBackendUtil.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerLifecycleHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerUtilBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordMetricsUtil.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterDispatcherBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterMetricsRecorder.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterReceiverBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendDispatcherBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendReceiverBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreCredential.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/CallbackDelayer.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/DialogManager.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ExportErrorDialogFragment.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ExportFlow.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ExportFlowInterface.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ExportWarningDialogFragment.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/NonCancelableProgressBar.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogBinder.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogCoordinator.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogFragment.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogMediator.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogProperties.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportFlowCoordinator.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossImportDialogCoordinator.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessReauthenticationHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordListObserver.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordManagerHandler.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordManagerHandlerProvider.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordReauthenticationFragment.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordUIView.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordsPreference.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ProgressBarDialogFragment.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/ReauthenticationManager.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/SavedPasswordEntry.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/SingleThreadBarrierClosure.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/TimedCallbackDelayer.java",
  ]

  resources_package = "org.chromium.chrome.browser.password_manager"
}

generate_jni("jni_headers") {
  visibility = [
    ":*",
    "//chrome/browser",
  ]
  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerLifecycleHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerUtilBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterDispatcherBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterReceiverBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendDispatcherBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendReceiverBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreBridge.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreCredential.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateBridgeImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordUIView.java",
  ]
}

java_group("javatests") {
  testonly = true
  deps = [
    "account_storage_notice:javatests",
    "pwd_migration:javatests",
  ]
}

robolectric_binary("password_manager_junit_tests") {
  testonly = true

  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportDialogCoordinatorTest.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossExportFlowCoordinatorTest.java",
    "java/src/org/chromium/chrome/browser/password_manager/settings/PasswordAccessLossImportDialogCoordinatorTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/ConfirmationDialogHelperTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/FakeCredentialManagerLauncherTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/FakePasswordManagerBackendSupportHelperTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/FakePasswordSettingsAccessorFactoryImplTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/FakePasswordStoreAndroidBackendTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/OutdatedGmsCoreDialogTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientMetricsRecorderTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerAndroidBackendUtilTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelperTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerLifecycleHelperTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordSettingsAccessorFactoryTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterDispatcherBridgeTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterMetricsRecorderTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordSettingsUpdaterReceiverBridgeTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendDispatcherBridgeTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendReceiverBridgeTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateBridgeTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/settings/PasswordReauthenticationFragmentTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/settings/ReauthenticationManagerTest.java",
    "junit/src/org/chromium/chrome/browser/password_manager/tests/utils/FakePasswordCheckupClientHelperTest.java",
  ]

  deps = [
    ":android_backend_java_enums",
    ":java",
    ":public_impl_java",
    ":settings_interface_java",
    ":test_support_java",
    ":unified_password_manager_proto_java",
    "$google_play_services_package:google_play_services_base_java",
    "$google_play_services_package:google_play_services_basement_java",
    "access_loss:junit",
    "account_storage_notice:junit",
    "add_username_dialog:junit",
    "bottom_sheet:junit",
    "pwd_migration:junit",
    "//base:base_java",
    "//base:base_java_test_support",
    "//base:base_java_test_support_uncommon",
    "//base:base_junit_test_support",
    "//chrome/browser/flags:java",
    "//chrome/browser/loading_modal/android:java",
    "//chrome/browser/password_manager/android/access_loss:helper_java",
    "//chrome/browser/password_manager/android/access_loss:java",
    "//chrome/browser/password_manager/android/pwd_migration:java",
    "//chrome/browser/preferences:java",
    "//chrome/browser/profiles/android:java",
    "//chrome/browser/safety_check/android:java",
    "//chrome/browser/settings:factory_java",
    "//chrome/browser/settings:internal_java",
    "//chrome/browser/signin/services/android:java",
    "//chrome/browser/sync/android:java",
    "//chrome/browser/sync/test/android:test_support_java",
    "//chrome/test/android:chrome_java_unit_test_support",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/browser_ui/settings/android:java",
    "//components/browser_ui/test/android:test_support_java",
    "//components/password_manager/core/browser:password_manager_java_enums",
    "//components/prefs/android:java",
    "//components/signin/public/android:java",
    "//components/signin/public/android:signin_java_test_support",
    "//components/sync/android:sync_java",
    "//components/sync/protocol:protocol_java",
    "//components/user_prefs/android:java",
    "//content/public/android:content_java",
    "//third_party/android_deps:espresso_java",
    "//third_party/android_deps:protobuf_lite_runtime_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_fragment_fragment_java",
    "//third_party/androidx:androidx_fragment_fragment_testing_java",
    "//third_party/androidx:androidx_test_core_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/hamcrest:hamcrest_core_java",
    "//third_party/hamcrest:hamcrest_library_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit",
    "//ui/android:ui_java_test_support",
    "//ui/android:ui_no_recycler_view_java",
  ]
}

android_resources("java_resources") {
  sources = [
    "java/res/drawable/ic_key_error.xml",
    "java/res/drawable/ic_vpn_key_blue.xml",
    "java/res/layout/confirmation_dialog_view.xml",
    "java/res/layout/password_access_loss_export_dialog_view.xml",
    "java/res/layout/passwords_error_dialog.xml",
    "java/res/layout/passwords_preference_error_widget.xml",
    "java/res/layout/passwords_progress_dialog.xml",
  ]
  deps = [
    "//chrome/browser/ui/android/strings:ui_strings_grd",
    "//components/browser_ui/strings/android:browser_ui_strings_grd",
    "//components/browser_ui/styles/android:java_resources",
  ]
}

android_library("settings_interface_java") {
  deps = [
    ":backend_interface_java",
    "//base:base_java",
    "//components/password_manager/core/browser:password_manager_java_enums",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
  ]

  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/CredentialManagerLauncher.java",
    "java/src/org/chromium/chrome/browser/password_manager/CredentialManagerLauncherFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/CredentialManagerLauncherFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientHelperFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientHelperFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerBackendSupportHelper.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerBackendSupportHelperImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsAccessor.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsAccessorFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsAccessorFactoryImpl.java",
  ]

  # Add the actual implementation where necessary so that downstream targets
  # can provide their own implementations.
  jar_excluded_patterns = [
    "*/CredentialManagerLauncherFactoryImpl.class",
    "*/PasswordSettingsAccessorFactoryImpl.class",
    "*/PasswordCheckupClientHelperFactoryImpl.class",
    "*/PasswordManagerBackendSupportHelperImpl.class",
  ]
}

android_library("backend_interface_java") {
  deps = [
    ":android_backend_java_enums",
    "//base:base_java",
    "//components/password_manager/core/browser:password_manager_java_enums",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
  ]
  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackend.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegate.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateFactoryImpl.java",
  ]

  # Add the actual implementation where necessary so that downstream targets
  # can provide their own implementations.
  jar_excluded_patterns = [
    "*/PasswordStoreAndroidBackendFactoryImpl.class",
    "*/PasswordSyncControllerDelegateFactoryImpl.class",
  ]
}

generate_jni("test_support_jni_headers") {
  testonly = true
  sources = [ "test_support/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerTestUtilsBridge.java" ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "password_manager_test_utils_bridge.cc",
    "password_manager_test_utils_bridge.h",
  ]

  deps = [
    ":test_support_jni_headers",
    "//base",
    "//components/password_manager/core/browser:browser",
  ]
}

android_library("test_support_java") {
  testonly = true
  srcjar_deps = [ ":test_support_jni_headers" ]
  sources = [
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakeCredentialManagerLauncher.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakeCredentialManagerLauncherFactoryImpl.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordCheckupClientHelper.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordCheckupClientHelperFactoryImpl.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordManagerBackendSupportHelper.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordManagerHandler.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordSettingsAccessor.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordSettingsAccessorFactoryImpl.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordStoreAndroidBackend.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordStoreAndroidBackendFactoryImpl.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordSyncControllerDelegate.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/FakePasswordSyncControllerDelegateFactoryImpl.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerTestHelper.java",
    "test_support/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerTestUtilsBridge.java",
  ]

  deps = [
    ":backend_interface_java",
    ":java",
    ":settings_interface_java",
    ":unified_password_manager_proto_java",
    "//base:base_java",
    "//build/android:build_java",
    "//chrome/browser/password_manager/android:settings_interface_java",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/password_manager/core/browser:password_manager_java_enums",
    "//components/signin/public/android:java",
    "//components/sync/protocol:protocol_java",
    "//content/public/android:content_main_dex_java",
    "//content/public/test/android:content_java_test_support",
    "//third_party/android_deps:protobuf_lite_runtime_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/jni_zero:jni_zero_java",
  ]
}

android_library("password_manager_resource_provider_java") {
  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerResourceProvider.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerResourceProviderFactory.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerResourceProviderImpl.java",
  ]

  deps = [
    "//chrome/android:chrome_app_java_resources",
    "//chrome/browser/flags:java",
    "//third_party/androidx:androidx_annotation_annotation_java",
  ]

  # Add the actual implementation where necessary so that downstream targets
  # can provide their own implementations.
  jar_excluded_patterns = [ "*/PasswordManagerResourceProviderImpl.class" ]

  resources_package = "org.chromium.chrome.browser.password_manager"
}

# Merged target of the password manager upstream-specific implementations.
android_library("public_impl_java") {
  sources = [
    "java/src/org/chromium/chrome/browser/password_manager/CredentialManagerLauncherFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordCheckupClientHelperFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerBackendSupportHelperImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordManagerResourceProviderImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSettingsAccessorFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordStoreAndroidBackendFactoryImpl.java",
    "java/src/org/chromium/chrome/browser/password_manager/PasswordSyncControllerDelegateFactoryImpl.java",
  ]

  deps = [
    ":backend_interface_java",
    ":password_manager_resource_provider_java",
    ":settings_interface_java",
    "//chrome/android:chrome_app_java_resources",
    "//chrome/browser/flags:java",
    "//third_party/androidx:androidx_annotation_annotation_java",
  ]

  resources_package = "org.chromium.chrome.browser.password_manager"
}

java_cpp_enum("java_enum_srcjar") {
  visibility = [ "//chrome/browser/password_manager/android/access_loss:*" ]
  sources = [ "password_manager_android_util.h" ]
}

source_set("utils") {
  sources = [
    "password_generation_element_data.cc",
    "password_generation_element_data.h",
    "password_manager_android_util.cc",
    "password_manager_android_util.h",
    "password_manager_eviction_util.cc",
    "password_manager_eviction_util.h",
    "password_manager_helper.cc",
    "password_manager_util_bridge.cc",
    "password_manager_util_bridge.h",
    "password_store_android_backend_api_error_codes.h",
  ]

  deps = [
    ":jni_headers",
    "//chrome/common:non_code_constants",
    "//components/autofill/core/common",
    "//components/browser_sync",
    "//components/password_manager/core/browser",
    "//components/password_manager/core/browser:password_manager_buildflags",
    "//components/password_manager/core/browser/features:password_features",
    "//components/password_manager/core/common:common",
    "//components/prefs:prefs",
    "//components/version_info/android:channel_getter",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "account_chooser_dialog_android_unittest.cc",
    "all_passwords_bottom_sheet_controller_unittest.cc",
    "all_passwords_bottom_sheet_helper_unittest.cc",
    "android_backend_with_double_deletion_unittest.cc",
    "auto_signin_first_run_dialog_android_unittest.cc",
    "built_in_backend_to_android_backend_migrator_unittest.cc",
    "cred_man_controller_unittest.cc",
    "credential_leak_controller_android_unittest.cc",
    "fake_password_manager_lifecycle_helper.cc",
    "fake_password_manager_lifecycle_helper.h",
    "generated_password_saved_message_delegate_unittest.cc",
    "mock_password_checkup_launcher_helper.cc",
    "mock_password_checkup_launcher_helper.h",
    "mock_password_manager_error_message_helper_bridge.cc",
    "mock_password_manager_error_message_helper_bridge.h",
    "mock_password_store_android_backend_bridge_helper.cc",
    "mock_password_store_android_backend_bridge_helper.h",
    "mock_password_sync_controller_delegate_bridge.cc",
    "mock_password_sync_controller_delegate_bridge.h",
    "password_generation_controller_impl_unittest.cc",
    "password_infobar_utils_unittest.cc",
    "password_manager_android_util_unittest.cc",
    "password_manager_error_message_delegate_unittest.cc",
    "password_manager_eviction_util_unittest.cc",
    "password_manager_settings_service_android_impl_unittest.cc",
    "password_manager_ui_util_android_unittest.cc",
    "password_settings_updater_android_bridge_helper_impl_unittest.cc",
    "password_store_android_account_backend_unittest.cc",
    "password_store_android_backend_bridge_helper_impl_unittest.cc",
    "password_store_android_local_backend_unittest.cc",
    "password_store_backend_migration_decorator_unittest.cc",
    "password_store_proxy_backend_unittest.cc",
    "password_sync_controller_delegate_android_unittest.cc",
    "save_update_password_message_delegate_unittest.cc",
    "unified_password_manager_proto_utils_unittest.cc",
  ]

  deps = [
    ":backend",
    ":backend_public",
    ":unified_password_manager_proto",
    ":utils",
    "//base/test:test_support",
    "//chrome/app:generated_resources",
    "//chrome/browser",
    "//chrome/browser/autofill",
    "//chrome/browser/keyboard_accessory/test_utils/android",
    "//chrome/browser/password_manager/android/add_username_dialog:android",
    "//chrome/browser/sync",
    "//chrome/browser/touch_to_fill/password_manager/password_generation/android:public",
    "//chrome/browser/touch_to_fill/password_manager/password_generation/android:test_support",
    "//chrome/test:test_support",
    "//components/affiliations/core/browser:test_support",
    "//components/autofill/core/browser",
    "//components/autofill/core/common",
    "//components/autofill/core/common:features",
    "//components/browser_sync",
    "//components/browser_ui/device_lock/android:android",
    "//components/device_reauth:device_reauth",
    "//components/device_reauth:test_support",
    "//components/messages/android:test_support",
    "//components/password_manager/content/browser",
    "//components/password_manager/content/browser:test_support",
    "//components/password_manager/core/browser",
    "//components/password_manager/core/browser:test_support",
    "//components/password_manager/core/browser/affiliation:affiliation_fetching",
    "//components/password_manager/core/browser/features:password_features",
    "//components/password_manager/core/browser/password_store:test_support",
    "//components/password_manager/core/common",
    "//components/plus_addresses:features",
    "//components/plus_addresses:test_support",
    "//components/plus_addresses/settings:test_support",
    "//components/safe_browsing/core/browser/password_protection:test_support",
    "//components/security_state/core",
    "//components/signin/public/identity_manager:test_support",
    "//components/strings:components_strings_grit",
    "//components/ukm:test_support",
    "//components/webauthn/android:android",
    "//content/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/abseil-cpp:absl",
    "//ui/android:android",
    "//ui/base:base",
  ]
}

fuzzable_proto_library("unified_password_manager_proto") {
  sources = [
    "protos/list_affiliated_passwords_result.proto",
    "protos/list_passwords_result.proto",
    "protos/password_info.proto",
    "protos/password_with_local_data.proto",
  ]
  deps = [ "//components/sync/protocol" ]
  proto_in_dir = "//"
}

proto_java_library("unified_password_manager_proto_java") {
  proto_path = "//"
  sources = [
    "protos/list_affiliated_passwords_result.proto",
    "protos/list_passwords_result.proto",
    "protos/password_info.proto",
    "protos/password_with_local_data.proto",
  ]
  deps = [ "//components/sync/protocol:protocol_java" ]
}