#include "components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h"
#include <stddef.h>
#include "base/check_deref.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/ui/payments/card_unmask_prompt_view.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/autofill/core/common/credit_card_network_identifiers.h"
#include "components/grit/components_scaled_resources.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill {
namespace {
PaymentsRpcResult;
std::u16string GetSideOfCardTranslationString(bool is_cvc_in_front) { … }
#if BUILDFLAG(IS_IOS)
bool VirtualCardFeatureEnabled() {
return base::FeatureList::IsEnabled(features::kAutofillEnableVirtualCards);
}
#endif
}
CardUnmaskPromptControllerImpl::CardUnmaskPromptControllerImpl(
PrefService* pref_service,
const CreditCard& card,
const CardUnmaskPromptOptions& card_unmask_prompt_options,
base::WeakPtr<CardUnmaskDelegate> delegate)
: … { … }
CardUnmaskPromptControllerImpl::~CardUnmaskPromptControllerImpl() { … }
void CardUnmaskPromptControllerImpl::ShowPrompt(
CardUnmaskPromptViewFactory card_unmask_view_factory) { … }
void CardUnmaskPromptControllerImpl::OnVerificationResult(
PaymentsRpcResult result) { … }
void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() { … }
void CardUnmaskPromptControllerImpl::OnUnmaskPromptAccepted(
const std::u16string& cvc,
const std::u16string& exp_month,
const std::u16string& exp_year,
bool enable_fido_auth,
bool was_checkbox_visible) { … }
void CardUnmaskPromptControllerImpl::NewCardLinkClicked() { … }
#if BUILDFLAG(IS_IOS)
std::u16string CardUnmaskPromptControllerImpl::GetNavigationTitle() const {
return l10n_util::GetStringUTF16(
VirtualCardFeatureEnabled()
? IDS_AUTOFILL_CARD_UNMASK_PROMPT_NAVIGATION_TITLE_VERIFICATION
: IDS_AUTOFILL_CARD_UNMASK_PROMPT_NAVIGATION_TITLE);
}
#endif
std::u16string CardUnmaskPromptControllerImpl::GetWindowTitle() const { … }
std::u16string CardUnmaskPromptControllerImpl::GetInstructionsMessage() const { … }
std::u16string CardUnmaskPromptControllerImpl::GetOkButtonLabel() const { … }
int CardUnmaskPromptControllerImpl::GetCvcImageRid() const { … }
bool CardUnmaskPromptControllerImpl::ShouldRequestExpirationDate() const { … }
#if BUILDFLAG(IS_ANDROID)
Suggestion::Icon CardUnmaskPromptControllerImpl::GetCardIcon() const {
return card_.CardIconForAutofillSuggestion();
}
std::u16string CardUnmaskPromptControllerImpl::GetCardName() const {
return card_.CardNameForAutofillDisplay();
}
std::u16string CardUnmaskPromptControllerImpl::GetCardLastFourDigits() const {
return card_.ObfuscatedNumberWithVisibleLastFourDigits();
}
std::u16string CardUnmaskPromptControllerImpl::GetCardExpiration() const {
return card_.AbbreviatedExpirationDateForDisplay(false);
}
const GURL& CardUnmaskPromptControllerImpl::GetCardArtUrl() const {
return card_.card_art_url();
}
int CardUnmaskPromptControllerImpl::GetGooglePayImageRid() const {
return IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER;
}
bool CardUnmaskPromptControllerImpl::ShouldOfferWebauthn() const {
return delegate_ && delegate_->ShouldOfferFidoAuth();
}
bool CardUnmaskPromptControllerImpl::GetWebauthnOfferStartState() const {
return pref_service_->GetBoolean(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState);
}
std::u16string CardUnmaskPromptControllerImpl::GetCvcImageAnnouncement() const {
return l10n_util::GetStringUTF16(
IsCvcInFront() ? IDS_AUTOFILL_CARD_UNMASK_CVC_IMAGE_ANNOUNCEMENT_AMEX
: IDS_AUTOFILL_CARD_UNMASK_CVC_IMAGE_ANNOUNCEMENT);
}
#endif
bool CardUnmaskPromptControllerImpl::InputCvcIsValid(
const std::u16string& input_text) const { … }
bool CardUnmaskPromptControllerImpl::InputExpirationIsValid(
const std::u16string& month,
const std::u16string& year) const { … }
int CardUnmaskPromptControllerImpl::GetExpectedCvcLength() const { … }
bool CardUnmaskPromptControllerImpl::IsChallengeOptionPresent() const { … }
base::TimeDelta CardUnmaskPromptControllerImpl::GetSuccessMessageDuration()
const { … }
PaymentsRpcResult CardUnmaskPromptControllerImpl::GetVerificationResult()
const { … }
bool CardUnmaskPromptControllerImpl::IsVirtualCard() const { … }
const CreditCard& CardUnmaskPromptControllerImpl::GetCreditCard() const { … }
#if !BUILDFLAG(IS_IOS)
int CardUnmaskPromptControllerImpl::GetCvcTooltipResourceId() { … }
#endif
bool CardUnmaskPromptControllerImpl::AllowsRetry(PaymentsRpcResult result) { … }
bool CardUnmaskPromptControllerImpl::IsCvcInFront() const { … }
bool CardUnmaskPromptControllerImpl::ShouldDismissUnmaskPromptUponResult(
PaymentsRpcResult result) { … }
void CardUnmaskPromptControllerImpl::LogOnCloseEvents() { … }
AutofillMetrics::UnmaskPromptEvent
CardUnmaskPromptControllerImpl::GetCloseReasonEvent() { … }
}