chromium/ios/chrome/credential_provider_extension/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/buildflag_header.gni")
import("//build/config/locales.gni")
import("//ios/build/chrome_build.gni")
import("//ios/chrome/extension_repack.gni")
import("//ios/chrome/tools/strings/generate_localizable_strings.gni")

assert(
    ios_enable_credential_provider_extension,
    "ios_enable_credential_provider_extension must be true to depend on //ios/chrome/credential_provider_extension")

group("resources") {
  deps = [ "//ios/chrome/credential_provider_extension/strings" ]
}

extension_repack_all_locales("packed_resources") {
  extension = "credential_provider_extension"
  input_locales = platform_pak_locales
  output_locales = locales_as_apple_outputs
}

source_set("credential_provider") {
  sources = [
    "credential_provider_view_controller.h",
    "credential_provider_view_controller.mm",
  ]

  deps = [
    ":account_verification_provider",
    ":metrics_util",
    ":passkey_util",
    ":reauthentication_handler",
    ":system_strings",
    "//base",
    "//components/webauthn/core/browser:passkey_model",
    "//ios/chrome/common/app_group",
    "//ios/chrome/common/app_group:client",
    "//ios/chrome/common/crash_report",
    "//ios/chrome/common/credential_provider",
    "//ios/chrome/common/credential_provider:ui",
    "//ios/chrome/common/ui/colors",
    "//ios/chrome/common/ui/confirmation_alert",
    "//ios/chrome/common/ui/reauthentication",
    "//ios/chrome/credential_provider_extension/resources",
    "//ios/chrome/credential_provider_extension/ui",
    "//ios/chrome/credential_provider_extension/ui:feature_flags",
  ]

  frameworks = [
    "AuthenticationServices.framework",
    "Foundation.framework",
    "UIKit.framework",
  ]
}

generate_localizable_strings("system_strings") {
  visibility = [ "//ios/chrome/credential_provider_extension/*" ]
  _packed_resources_target = ":packed_resources"
  config_file = "credential_provider_extension_localize_strings_config.plist"
  datapack_dir = get_label_info(_packed_resources_target, "target_gen_dir")
  packed_locales = locales_as_apple_outputs
  output_filenames = [ "Localizable.strings" ]
  deps = [ _packed_resources_target ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "metrics_util_unittest.mm",
    "passkey_util_unittest.mm",
  ]
  deps = [
    ":metrics_util",
    ":passkey_util",
    "//base",
    "//base/test:test_support",
    "//ios/chrome/common/app_group",
    "//ios/chrome/common/credential_provider",
    "//testing/gtest",
  ]
}

source_set("reauthentication_handler") {
  sources = [
    "reauthentication_handler.h",
    "reauthentication_handler.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/common/app_group",
    "//ios/chrome/common/app_group:command",
    "//ios/chrome/common/ui/reauthentication",
  ]
}

buildflag_header("password_spec_fetcher_buildflags") {
  header = "password_spec_fetcher_buildflags.h"
  flags = [ "GOOGLE_API_KEY=@\"$ios_credential_provider_extension_api_key\"" ]
}

source_set("passkey_util") {
  sources = [
    "passkey_util.h",
    "passkey_util.mm",
  ]
  deps = [
    "//base",
    "//components/sync/protocol",
    "//components/webauthn/core/browser:passkey_model",
    "//ios/chrome/common/credential_provider:ui",
  ]
  frameworks = [ "Foundation.framework" ]
}

source_set("password_util") {
  sources = [
    "password_util.h",
    "password_util.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/common/app_group",
    "//ios/chrome/credential_provider_extension:metrics_util",
    "//ios/components/credential_provider_extension:password_util",
  ]
  frameworks = [ "Foundation.framework" ]
}

source_set("metrics_util") {
  sources = [
    "metrics_util.h",
    "metrics_util.mm",
  ]
  deps = [
    "//base",
    "//ios/chrome/common/app_group",
  ]
  frameworks = [ "Foundation.framework" ]
}

source_set("account_verification_provider") {
  public_deps = [ ":account_verification_provider_header" ]
  deps = [ ios_account_verification_provider_target ]
  assert_no_deps = [ "//ios/chrome/browser/*" ]
  frameworks = [ "Foundation.framework" ]
}

source_set("account_verification_provider_header") {
  sources = [ "account_verification_provider.h" ]
  assert_no_deps = [ "//ios/chrome/browser/*" ]
  frameworks = [ "Foundation.framework" ]
}

source_set("account_verification_provider_implementation") {
  sources = [ "account_verification_provider.mm" ]
  deps = [ ":account_verification_provider_header" ]
  assert_no_deps = [ "//ios/chrome/browser/*" ]
  frameworks = [ "Foundation.framework" ]
}