1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_TEST_AUTHENTICATION_REQUESTER_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_TEST_AUTHENTICATION_REQUESTER_H_
#include <string>
#include "build/build_config.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/credit_card_risk_based_authenticator.h"
#include "components/autofill/core/browser/payments/full_card_request.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_request_details.h"
#if !BUILDFLAG(IS_IOS)
#include "components/autofill/core/browser/payments/credit_card_fido_authenticator.h"
#endif
namespace autofill {
// Test class for requesting authentication from CreditCardCvcAuthenticator or
// CreditCardFidoAuthenticator.
#if BUILDFLAG(IS_IOS)
class TestAuthenticationRequester
: public CreditCardCvcAuthenticator::Requester,
public CreditCardOtpAuthenticator::Requester,
public CreditCardRiskBasedAuthenticator::Requester {
#else
class TestAuthenticationRequester
: public CreditCardCvcAuthenticator::Requester,
public CreditCardFidoAuthenticator::Requester,
public CreditCardOtpAuthenticator::Requester,
public CreditCardRiskBasedAuthenticator::Requester {
#endif
public:
TestAuthenticationRequester();
~TestAuthenticationRequester() override;
// CreditCardCvcAuthenticator::Requester:
void OnCvcAuthenticationComplete(
const CreditCardCvcAuthenticator::CvcAuthenticationResponse& response)
override;
#if BUILDFLAG(IS_ANDROID)
bool ShouldOfferFidoAuth() const override;
bool UserOptedInToFidoFromSettingsPageOnMobile() const override;
#endif
#if !BUILDFLAG(IS_IOS)
// CreditCardFidoAuthenticator::Requester:
void OnFIDOAuthenticationComplete(
const CreditCardFidoAuthenticator::FidoAuthenticationResponse& response)
override;
void OnFidoAuthorizationComplete(bool did_succeed) override;
void IsUserVerifiableCallback(bool is_user_verifiable);
#endif
// CreditCardOtpAuthenticator::Requester:
void OnOtpAuthenticationComplete(
const CreditCardOtpAuthenticator::OtpAuthenticationResponse& response)
override;
// CreditCardRiskBasedAuthenticator::Requester:
void OnRiskBasedAuthenticationResponseReceived(
const CreditCardRiskBasedAuthenticator::RiskBasedAuthenticationResponse&
response) override;
base::WeakPtr<TestAuthenticationRequester> GetWeakPtr();
std::optional<bool> is_user_verifiable() { return is_user_verifiable_; }
std::optional<bool> did_succeed() { return did_succeed_; }
std::u16string number() { return number_; }
CreditCard::RecordType record_type() { return record_type_; }
CreditCardRiskBasedAuthenticator::RiskBasedAuthenticationResponse&
risk_based_authentication_response() {
return risk_based_authentication_response_;
}
payments::FullCardRequest::FailureType failure_type() {
return failure_type_;
}
private:
// Set when CreditCardFidoAuthenticator invokes IsUserVerifiableCallback().
std::optional<bool> is_user_verifiable_;
// Is set to true if authentication was successful.
std::optional<bool> did_succeed_;
// The failure type of the full card request. Set when the request is
// finished.
payments::FullCardRequest::FailureType failure_type_ =
payments::FullCardRequest::UNKNOWN;
// The card number returned from On*AuthenticationComplete().
std::u16string number_;
// The card record type returned from On*AuthenticationComplete().
CreditCard::RecordType record_type_;
// Authentication response returned from CreditCardRiskBasedAuthenticator.
CreditCardRiskBasedAuthenticator::RiskBasedAuthenticationResponse
risk_based_authentication_response_;
base::WeakPtrFactory<TestAuthenticationRequester> weak_ptr_factory_{this};
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_TEST_AUTHENTICATION_REQUESTER_H_
|