chromium/components/autofill/core/browser/payments/test_payments_autofill_client.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/payments/test_payments_autofill_client.h"

#include <memory>

#include "base/check_deref.h"
#include "base/functional/callback.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/merchant_promo_code_manager.h"
#include "components/autofill/core/browser/payments/autofill_offer_manager.h"
#include "components/autofill/core/browser/payments/credit_card_cvc_authenticator.h"
#include "components/autofill/core/browser/payments/credit_card_otp_authenticator.h"
#include "components/autofill/core/browser/payments/mandatory_reauth_manager.h"
#include "components/autofill/core/browser/payments/test/mock_payments_window_manager.h"
#include "components/autofill/core/browser/payments/virtual_card_enrollment_manager.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/touch_to_fill_delegate.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "base/test/gmock_callback_support.h"
#endif  // BUILDFLAG(IS_ANDROID)

#if !BUILDFLAG(IS_IOS)
#include "components/autofill/core/browser/payments/test_internal_authenticator.h"
#include "components/webauthn/core/browser/internal_authenticator.h"
#endif  // !BUILDFLAG(IS_IOS)

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "components/autofill/core/browser/payments/local_card_migration_manager.h"
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

namespace autofill::payments {

TestPaymentsAutofillClient::TestPaymentsAutofillClient(AutofillClient* client)
    :{}

TestPaymentsAutofillClient::~TestPaymentsAutofillClient() = default;

void TestPaymentsAutofillClient::LoadRiskData(
    base::OnceCallback<void(const std::string&)> callback) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void TestPaymentsAutofillClient::ShowLocalCardMigrationDialog(
    base::OnceClosure show_migration_dialog_closure) {}

void TestPaymentsAutofillClient::ConfirmMigrateLocalCardToCloud(
    const LegalMessageLines& legal_message_lines,
    const std::string& user_email,
    const std::vector<MigratableCreditCard>& migratable_credit_cards,
    PaymentsAutofillClient::LocalCardMigrationCallback
        start_migrating_cards_callback) {}

void TestPaymentsAutofillClient::ConfirmSaveIbanLocally(
    const Iban& iban,
    bool should_show_prompt,
    payments::PaymentsAutofillClient::SaveIbanPromptCallback callback) {}

void TestPaymentsAutofillClient::ConfirmUploadIbanToCloud(
    const Iban& iban,
    LegalMessageLines legal_message_lines,
    bool should_show_prompt,
    payments::PaymentsAutofillClient::SaveIbanPromptCallback callback) {}

bool TestPaymentsAutofillClient::CloseWebauthnDialog() {}
#else   // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
void TestPaymentsAutofillClient::ConfirmAccountNameFixFlow(
    base::OnceCallback<void(const std::u16string&)> callback) {
  credit_card_name_fix_flow_bubble_was_shown_ = true;
  std::move(callback).Run(std::u16string(u"Gaia Name"));
}

void TestPaymentsAutofillClient::ConfirmExpirationDateFixFlow(
    const CreditCard& card,
    base::OnceCallback<void(const std::u16string&, const std::u16string&)>
        callback) {
  credit_card_name_fix_flow_bubble_was_shown_ = true;
  std::move(callback).Run(
      std::u16string(u"03"),
      std::u16string(base::ASCIIToUTF16(test::NextYear().c_str())));
}
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

TestPaymentsNetworkInterface*
TestPaymentsAutofillClient::GetPaymentsNetworkInterface() {}

void TestPaymentsAutofillClient::ShowAutofillProgressDialog(
    AutofillProgressDialogType autofill_progress_dialog_type,
    base::OnceClosure cancel_callback) {}

void TestPaymentsAutofillClient::CloseAutofillProgressDialog(
    bool show_confirmation_before_closing,
    base::OnceClosure no_user_perceived_authentication_callback) {}

void TestPaymentsAutofillClient::ShowAutofillErrorDialog(
    AutofillErrorDialogContext context) {}

void TestPaymentsAutofillClient::ShowCardUnmaskOtpInputDialog(
    const CardUnmaskChallengeOption& challenge_option,
    base::WeakPtr<OtpUnmaskDelegate> delegate) {}

PaymentsWindowManager* TestPaymentsAutofillClient::GetPaymentsWindowManager() {}

VirtualCardEnrollmentManager*
TestPaymentsAutofillClient::GetVirtualCardEnrollmentManager() {}

CreditCardCvcAuthenticator& TestPaymentsAutofillClient::GetCvcAuthenticator() {}

CreditCardOtpAuthenticator* TestPaymentsAutofillClient::GetOtpAuthenticator() {}

TestCreditCardRiskBasedAuthenticator*
TestPaymentsAutofillClient::GetRiskBasedAuthenticator() {}

void TestPaymentsAutofillClient::ShowMandatoryReauthOptInPrompt(
    base::OnceClosure accept_mandatory_reauth_callback,
    base::OnceClosure cancel_mandatory_reauth_callback,
    base::RepeatingClosure close_mandatory_reauth_callback) {}

MockIbanManager* TestPaymentsAutofillClient::GetIbanManager() {}

MockIbanAccessManager* TestPaymentsAutofillClient::GetIbanAccessManager() {}

void TestPaymentsAutofillClient::ShowMandatoryReauthOptInConfirmation() {}

MerchantPromoCodeManager*
TestPaymentsAutofillClient::GetMerchantPromoCodeManager() {}

AutofillOfferManager* TestPaymentsAutofillClient::GetAutofillOfferManager() {}

bool TestPaymentsAutofillClient::ShowTouchToFillCreditCard(
    base::WeakPtr<TouchToFillDelegate> delegate,
    base::span<const autofill::CreditCard> cards_to_suggest,
    base::span<const Suggestion> suggestions) {}

#if !BUILDFLAG(IS_IOS)
std::unique_ptr<webauthn::InternalAuthenticator>
TestPaymentsAutofillClient::CreateCreditCardInternalAuthenticator(
    AutofillDriver* driver) {}
#endif

MockMandatoryReauthManager*
TestPaymentsAutofillClient::GetOrCreatePaymentsMandatoryReauthManager() {}

bool TestPaymentsAutofillClient::GetMandatoryReauthOptInPromptWasShown() {}

bool TestPaymentsAutofillClient::GetMandatoryReauthOptInPromptWasReshown() {}

void TestPaymentsAutofillClient::set_virtual_card_enrollment_manager(
    std::unique_ptr<VirtualCardEnrollmentManager> vcem) {}

void TestPaymentsAutofillClient::set_otp_authenticator(
    std::unique_ptr<CreditCardOtpAuthenticator> authenticator) {}

MockMerchantPromoCodeManager*
TestPaymentsAutofillClient::GetMockMerchantPromoCodeManager() {}

#if BUILDFLAG(IS_ANDROID)
void TestPaymentsAutofillClient::
    SetUpDeviceBiometricAuthenticatorSuccessOnAutomotive() {
  if (!base::android::BuildInfo::GetInstance()->is_automotive()) {
    return;
  }

  payments::MockMandatoryReauthManager& mandatory_reauth_manager =
      *GetOrCreatePaymentsMandatoryReauthManager();

  ON_CALL(mandatory_reauth_manager, GetAuthenticationMethod)
      .WillByDefault(testing::Return(
          payments::MandatoryReauthAuthenticationMethod::kBiometric));

  ON_CALL(mandatory_reauth_manager, Authenticate)
      .WillByDefault(testing::WithArg<0>(
          testing::Invoke([](base::OnceCallback<void(bool)> callback) {
            std::move(callback).Run(true);
          })));
}
#endif

}  // namespace autofill::payments