#include "components/autofill/core/browser/payments/virtual_card_enrollment_manager.h"
#include <string>
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/payments/virtual_card_enrollment_metrics.h"
#include "components/autofill/core/browser/payments/autofill_payments_feature_availability.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_util.h"
#include "components/autofill/core/browser/payments/virtual_card_enrollment_flow.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/strike_databases/payments/virtual_card_enrollment_strike_database.h"
#include "components/autofill/core/browser/strike_databases/strike_database.h"
#include "components/autofill/core/browser/strike_databases/strike_database_base.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
namespace autofill {
namespace {
PaymentsRpcResult;
}
VirtualCardEnrollmentFields::VirtualCardEnrollmentFields() = default;
VirtualCardEnrollmentFields::VirtualCardEnrollmentFields(
const VirtualCardEnrollmentFields&) = default;
VirtualCardEnrollmentFields& VirtualCardEnrollmentFields::operator=(
const VirtualCardEnrollmentFields&) = default;
VirtualCardEnrollmentFields::~VirtualCardEnrollmentFields() = default;
bool VirtualCardEnrollmentFields::operator==(
const VirtualCardEnrollmentFields&) const = default;
VirtualCardEnrollmentProcessState::VirtualCardEnrollmentProcessState() =
default;
VirtualCardEnrollmentProcessState::VirtualCardEnrollmentProcessState(
const VirtualCardEnrollmentProcessState&) = default;
VirtualCardEnrollmentProcessState& VirtualCardEnrollmentProcessState::operator=(
const VirtualCardEnrollmentProcessState&) = default;
VirtualCardEnrollmentProcessState::~VirtualCardEnrollmentProcessState() =
default;
VirtualCardEnrollmentManager::VirtualCardEnrollmentManager(
PersonalDataManager* personal_data_manager,
payments::PaymentsNetworkInterface* payments_network_interface,
AutofillClient* autofill_client)
: … { … }
VirtualCardEnrollmentManager::~VirtualCardEnrollmentManager() = default;
void VirtualCardEnrollmentManager::InitVirtualCardEnroll(
const CreditCard& credit_card,
VirtualCardEnrollmentSource virtual_card_enrollment_source,
std::optional<payments::PaymentsNetworkInterface::
GetDetailsForEnrollmentResponseDetails>
get_details_for_enrollment_response_details,
PrefService* user_prefs,
RiskAssessmentFunction risk_assessment_function,
VirtualCardEnrollmentFieldsLoadedCallback
virtual_card_enrollment_fields_loaded_callback) { … }
void VirtualCardEnrollmentManager::Enroll(
std::optional<VirtualCardEnrollmentUpdateResponseCallback>
virtual_card_enrollment_update_response_callback) { … }
void VirtualCardEnrollmentManager::Unenroll(
int64_t instrument_id,
std::optional<VirtualCardEnrollmentUpdateResponseCallback>
virtual_card_enrollment_update_response_callback) { … }
bool VirtualCardEnrollmentManager::ShouldBlockVirtualCardEnrollment(
const std::string& instrument_id,
VirtualCardEnrollmentSource virtual_card_enrollment_source) const { … }
void VirtualCardEnrollmentManager::
AddStrikeToBlockOfferingVirtualCardEnrollment(
const std::string& instrument_id) { … }
void VirtualCardEnrollmentManager::
RemoveAllStrikesToBlockOfferingVirtualCardEnrollment(
const std::string& instrument_id) { … }
void VirtualCardEnrollmentManager::SetSaveCardBubbleAcceptedTimestamp(
base::Time save_card_bubble_accepted_timestamp) { … }
void VirtualCardEnrollmentManager::ClearAllStrikesForTesting() { … }
void VirtualCardEnrollmentManager::OnDidGetUpdateVirtualCardEnrollmentResponse(
VirtualCardEnrollmentRequestType type,
PaymentsRpcResult result) { … }
void VirtualCardEnrollmentManager::OnVirtualCardEnrollCompleted(
PaymentsRpcResult result) { … }
void VirtualCardEnrollmentManager::Reset() { … }
VirtualCardEnrollmentStrikeDatabase*
VirtualCardEnrollmentManager::GetVirtualCardEnrollmentStrikeDatabase() const { … }
void VirtualCardEnrollmentManager::LoadRiskDataAndContinueFlow(
PrefService* user_prefs,
base::OnceCallback<void(const std::string&)> callback) { … }
void VirtualCardEnrollmentManager::ShowVirtualCardEnrollBubble() { … }
void VirtualCardEnrollmentManager::OnVirtualCardEnrollmentBubbleCancelled() { … }
void VirtualCardEnrollmentManager::OnRiskDataLoadedForVirtualCard(
const std::string& risk_data) { … }
void VirtualCardEnrollmentManager::GetDetailsForEnroll() { … }
void VirtualCardEnrollmentManager::OnDidGetDetailsForEnrollResponse(
PaymentsRpcResult result,
const payments::PaymentsNetworkInterface::
GetDetailsForEnrollmentResponseDetails& response) { … }
void VirtualCardEnrollmentManager::SetGetDetailsForEnrollmentResponseDetails(
const payments::PaymentsNetworkInterface::
GetDetailsForEnrollmentResponseDetails& response) { … }
void VirtualCardEnrollmentManager::EnsureCardArtImageIsSetBeforeShowingUI() { … }
void VirtualCardEnrollmentManager::SetInitialVirtualCardEnrollFields(
const CreditCard& credit_card,
VirtualCardEnrollmentSource virtual_card_enrollment_source) { … }
bool VirtualCardEnrollmentManager::
IsValidGetDetailsForEnrollmentResponseDetails(
const payments::PaymentsNetworkInterface::
GetDetailsForEnrollmentResponseDetails&
get_details_for_enrollment_response_details) { … }
}