Commit 9a2fd169 authored by Manas Verma's avatar Manas Verma Committed by Commit Bot

[Autofill Auth] Remembering checkbox preference for WebAuthn offer.

On Android, ensuring that if user unchecks checkbox for WebAuthn offer, it
remains unchecked.

Bug: 949269
Change-Id: I7214abc01d40d916ba14b2b6d3bb55faa871608c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825796Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Manas Verma <manasverma@google.com>
Cr-Commit-Position: refs/heads/master@{#702968}
parent ddf069ec
...@@ -27,8 +27,8 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -27,8 +27,8 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, String title, public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, String title,
String instructions, String confirmButtonLabel, int iconId, String instructions, String confirmButtonLabel, int iconId,
boolean shouldRequestExpirationDate, boolean canStoreLocally, boolean shouldRequestExpirationDate, boolean canStoreLocally,
boolean defaultToStoringLocally, long successMessageDurationMilliseconds, boolean defaultToStoringLocally, boolean defaultUseScreenlockChecked,
WindowAndroid windowAndroid) { long successMessageDurationMilliseconds, WindowAndroid windowAndroid) {
mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid; mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid;
Activity activity = windowAndroid.getActivity().get(); Activity activity = windowAndroid.getActivity().get();
if (activity == null) { if (activity == null) {
...@@ -40,7 +40,7 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -40,7 +40,7 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
mCardUnmaskPrompt = new CardUnmaskPrompt(activity, this, title, instructions, mCardUnmaskPrompt = new CardUnmaskPrompt(activity, this, title, instructions,
confirmButtonLabel, ResourceId.mapToDrawableId(iconId), confirmButtonLabel, ResourceId.mapToDrawableId(iconId),
shouldRequestExpirationDate, canStoreLocally, defaultToStoringLocally, shouldRequestExpirationDate, canStoreLocally, defaultToStoringLocally,
successMessageDurationMilliseconds); defaultUseScreenlockChecked, successMessageDurationMilliseconds);
} }
} }
...@@ -48,11 +48,11 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -48,11 +48,11 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
private static CardUnmaskBridge create(long nativeUnmaskPrompt, String title, private static CardUnmaskBridge create(long nativeUnmaskPrompt, String title,
String instructions, String confirmButtonLabel, int iconId, String instructions, String confirmButtonLabel, int iconId,
boolean shouldRequestExpirationDate, boolean canStoreLocally, boolean shouldRequestExpirationDate, boolean canStoreLocally,
boolean defaultToStoringLocally, long successMessageDurationMilliseconds, boolean defaultToStoringLocally, boolean defaultUseScreenlockChecked,
WindowAndroid windowAndroid) { long successMessageDurationMilliseconds, WindowAndroid windowAndroid) {
return new CardUnmaskBridge(nativeUnmaskPrompt, title, instructions, confirmButtonLabel, return new CardUnmaskBridge(nativeUnmaskPrompt, title, instructions, confirmButtonLabel,
iconId, shouldRequestExpirationDate, canStoreLocally, defaultToStoringLocally, iconId, shouldRequestExpirationDate, canStoreLocally, defaultToStoringLocally,
successMessageDurationMilliseconds, windowAndroid); defaultUseScreenlockChecked, successMessageDurationMilliseconds, windowAndroid);
} }
@Override @Override
...@@ -91,8 +91,9 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate { ...@@ -91,8 +91,9 @@ public class CardUnmaskBridge implements CardUnmaskPromptDelegate {
*/ */
@CalledByNative @CalledByNative
private void show(WindowAndroid windowAndroid) { private void show(WindowAndroid windowAndroid) {
if (mCardUnmaskPrompt != null) if (mCardUnmaskPrompt != null) {
mCardUnmaskPrompt.show((ChromeActivity) (windowAndroid.getActivity().get())); mCardUnmaskPrompt.show((ChromeActivity) (windowAndroid.getActivity().get()));
}
} }
/** /**
......
...@@ -146,7 +146,8 @@ public class CardUnmaskPrompt ...@@ -146,7 +146,8 @@ public class CardUnmaskPrompt
public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title, public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
String instructions, String confirmButtonLabel, int drawableId, String instructions, String confirmButtonLabel, int drawableId,
boolean shouldRequestExpirationDate, boolean canStoreLocally, boolean shouldRequestExpirationDate, boolean canStoreLocally,
boolean defaultToStoringLocally, long successMessageDurationMilliseconds) { boolean defaultToStoringLocally, boolean defaultUseScreenlockChecked,
long successMessageDurationMilliseconds) {
mDelegate = delegate; mDelegate = delegate;
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
...@@ -166,6 +167,7 @@ public class CardUnmaskPrompt ...@@ -166,6 +167,7 @@ public class CardUnmaskPrompt
mStoreLocallyCheckbox = (CheckBox) v.findViewById(R.id.store_locally_checkbox); mStoreLocallyCheckbox = (CheckBox) v.findViewById(R.id.store_locally_checkbox);
mStoreLocallyCheckbox.setChecked(canStoreLocally && defaultToStoringLocally); mStoreLocallyCheckbox.setChecked(canStoreLocally && defaultToStoringLocally);
mUseScreenlockCheckbox = (CheckBox) v.findViewById(R.id.use_screenlock_checkbox); mUseScreenlockCheckbox = (CheckBox) v.findViewById(R.id.use_screenlock_checkbox);
mUseScreenlockCheckbox.setChecked(defaultUseScreenlockChecked);
if (canStoreLocally if (canStoreLocally
|| !ChromeFeatureList.isEnabled( || !ChromeFeatureList.isEnabled(
ChromeFeatureList.AUTOFILL_CREDIT_CARD_AUTHENTICATION)) { ChromeFeatureList.AUTOFILL_CREDIT_CARD_AUTHENTICATION)) {
...@@ -195,8 +197,9 @@ public class CardUnmaskPrompt ...@@ -195,8 +197,9 @@ public class CardUnmaskPrompt
mShouldRequestExpirationDate = shouldRequestExpirationDate; mShouldRequestExpirationDate = shouldRequestExpirationDate;
mThisYear = -1; mThisYear = -1;
mThisMonth = -1; mThisMonth = -1;
if (mShouldRequestExpirationDate) if (mShouldRequestExpirationDate) {
new CalendarTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new CalendarTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
// Set the max length of the CVC field. // Set the max length of the CVC field.
mCardUnmaskInput.setFilters( mCardUnmaskInput.setFilters(
......
...@@ -151,7 +151,7 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() { ...@@ -151,7 +151,7 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillCreditCardEnabled] = (*s_whitelist)[autofill::prefs::kAutofillCreditCardEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillCreditCardFIDOAuthEnabled] = (*s_whitelist)[autofill::prefs::kAutofillCreditCardFidoAuthEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[payments::kCanMakePaymentEnabled] = (*s_whitelist)[payments::kCanMakePaymentEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
......
...@@ -53,6 +53,7 @@ void CardUnmaskPromptViewAndroid::Show() { ...@@ -53,6 +53,7 @@ void CardUnmaskPromptViewAndroid::Show() {
confirm, ResourceMapper::MapFromChromiumId(controller_->GetCvcImageRid()), confirm, ResourceMapper::MapFromChromiumId(controller_->GetCvcImageRid()),
controller_->ShouldRequestExpirationDate(), controller_->ShouldRequestExpirationDate(),
controller_->CanStoreLocally(), controller_->GetStoreLocallyStartState(), controller_->CanStoreLocally(), controller_->GetStoreLocallyStartState(),
controller_->GetWebauthnOfferStartState(),
controller_->GetSuccessMessageDuration().InMilliseconds(), controller_->GetSuccessMessageDuration().InMilliseconds(),
view_android->GetWindowAndroid()->GetJavaObject())); view_android->GetWindowAndroid()->GetJavaObject()));
......
...@@ -33,6 +33,7 @@ class CardUnmaskPromptController { ...@@ -33,6 +33,7 @@ class CardUnmaskPromptController {
virtual bool ShouldRequestExpirationDate() const = 0; virtual bool ShouldRequestExpirationDate() const = 0;
virtual bool CanStoreLocally() const = 0; virtual bool CanStoreLocally() const = 0;
virtual bool GetStoreLocallyStartState() const = 0; virtual bool GetStoreLocallyStartState() const = 0;
virtual bool GetWebauthnOfferStartState() const = 0;
virtual base::TimeDelta GetSuccessMessageDuration() const = 0; virtual base::TimeDelta GetSuccessMessageDuration() const = 0;
virtual AutofillClient::PaymentsRpcResult GetVerificationResult() const = 0; virtual AutofillClient::PaymentsRpcResult GetVerificationResult() const = 0;
......
...@@ -134,6 +134,16 @@ void CardUnmaskPromptControllerImpl::OnUnmaskPromptAccepted( ...@@ -134,6 +134,16 @@ void CardUnmaskPromptControllerImpl::OnUnmaskPromptAccepted(
pending_details_.should_store_pan = false; pending_details_.should_store_pan = false;
} }
// The FIDO authentication checkbox is only shown when the local storage
// checkbox is not shown and the flag is turned on. If it is shown, then
// remember the last choice the user made on this device.
if (base::FeatureList::IsEnabled(
features::kAutofillCreditCardAuthentication) &&
!CanStoreLocally()) {
pref_service_->SetBoolean(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState, enable_fido_auth);
}
// There is a chance the delegate has disappeared (i.e. tab closed) before the // There is a chance the delegate has disappeared (i.e. tab closed) before the
// unmask response came in. Avoid a crash. // unmask response came in. Avoid a crash.
if (delegate_) if (delegate_)
...@@ -219,6 +229,11 @@ bool CardUnmaskPromptControllerImpl::GetStoreLocallyStartState() const { ...@@ -219,6 +229,11 @@ bool CardUnmaskPromptControllerImpl::GetStoreLocallyStartState() const {
prefs::kAutofillWalletImportStorageCheckboxState); prefs::kAutofillWalletImportStorageCheckboxState);
} }
bool CardUnmaskPromptControllerImpl::GetWebauthnOfferStartState() const {
return pref_service_->GetBoolean(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState);
}
bool CardUnmaskPromptControllerImpl::InputCvcIsValid( bool CardUnmaskPromptControllerImpl::InputCvcIsValid(
const base::string16& input_text) const { const base::string16& input_text) const {
base::string16 trimmed_text; base::string16 trimmed_text;
......
...@@ -48,6 +48,7 @@ class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController { ...@@ -48,6 +48,7 @@ class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController {
bool ShouldRequestExpirationDate() const override; bool ShouldRequestExpirationDate() const override;
bool CanStoreLocally() const override; bool CanStoreLocally() const override;
bool GetStoreLocallyStartState() const override; bool GetStoreLocallyStartState() const override;
bool GetWebauthnOfferStartState() const override;
bool InputCvcIsValid(const base::string16& input_text) const override; bool InputCvcIsValid(const base::string16& input_text) const override;
bool InputExpirationIsValid(const base::string16& month, bool InputExpirationIsValid(const base::string16& month,
const base::string16& year) const override; const base::string16& year) const override;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/autofill_test_utils.h"
...@@ -105,11 +106,12 @@ class CardUnmaskPromptControllerImplGenericTest { ...@@ -105,11 +106,12 @@ class CardUnmaskPromptControllerImplGenericTest {
AutofillClient::UNMASK_FOR_AUTOFILL, delegate_->GetWeakPtr()); AutofillClient::UNMASK_FOR_AUTOFILL, delegate_->GetWeakPtr());
} }
void ShowPromptAndSimulateResponse(bool should_store_pan) { void ShowPromptAndSimulateResponse(bool should_store_pan,
bool enable_fido_auth) {
ShowPrompt(); ShowPrompt();
controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"), controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"),
ASCIIToUTF16("2050"), should_store_pan, ASCIIToUTF16("2050"), should_store_pan,
/*enable_fido_auth=*/false); enable_fido_auth);
EXPECT_EQ(should_store_pan, EXPECT_EQ(should_store_pan,
pref_service_->GetBoolean( pref_service_->GetBoolean(
prefs::kAutofillWalletImportStorageCheckboxState)); prefs::kAutofillWalletImportStorageCheckboxState));
...@@ -121,6 +123,7 @@ class CardUnmaskPromptControllerImplGenericTest { ...@@ -121,6 +123,7 @@ class CardUnmaskPromptControllerImplGenericTest {
value); value);
} }
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<TestCardUnmaskPromptView> test_unmask_prompt_view_; std::unique_ptr<TestCardUnmaskPromptView> test_unmask_prompt_view_;
std::unique_ptr<TestingPrefServiceSimple> pref_service_; std::unique_ptr<TestingPrefServiceSimple> pref_service_;
std::unique_ptr<TestCardUnmaskPromptController> controller_; std::unique_ptr<TestCardUnmaskPromptController> controller_;
...@@ -144,6 +147,8 @@ class CardUnmaskPromptControllerImplTest ...@@ -144,6 +147,8 @@ class CardUnmaskPromptControllerImplTest
delegate_.reset(new TestCardUnmaskDelegate()); delegate_.reset(new TestCardUnmaskDelegate());
pref_service_->registry()->RegisterBooleanPref( pref_service_->registry()->RegisterBooleanPref(
prefs::kAutofillWalletImportStorageCheckboxState, false); prefs::kAutofillWalletImportStorageCheckboxState, false);
pref_service_->registry()->RegisterBooleanPref(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState, true);
} }
private: private:
...@@ -169,7 +174,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedNoAttempts) { ...@@ -169,7 +174,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedNoAttempts) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogClosedAbandonUnmasking) { TEST_F(CardUnmaskPromptControllerImplTest, LogClosedAbandonUnmasking) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -180,7 +186,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedAbandonUnmasking) { ...@@ -180,7 +186,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedAbandonUnmasking) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogClosedFailedToUnmaskRetriable) { TEST_F(CardUnmaskPromptControllerImplTest, LogClosedFailedToUnmaskRetriable) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
...@@ -198,7 +205,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedFailedToUnmaskRetriable) { ...@@ -198,7 +205,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogClosedFailedToUnmaskRetriable) {
TEST_F(CardUnmaskPromptControllerImplTest, TEST_F(CardUnmaskPromptControllerImplTest,
LogClosedFailedToUnmaskNonRetriable) { LogClosedFailedToUnmaskNonRetriable) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::PERMANENT_FAILURE); controller_->OnVerificationResult(AutofillClient::PERMANENT_FAILURE);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
...@@ -216,7 +224,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, ...@@ -216,7 +224,8 @@ TEST_F(CardUnmaskPromptControllerImplTest,
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardFirstAttempt) { TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardFirstAttempt) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::SUCCESS); controller_->OnVerificationResult(AutofillClient::SUCCESS);
...@@ -232,7 +241,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardFirstAttempt) { ...@@ -232,7 +241,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardFirstAttempt) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardAfterFailure) { TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardAfterFailure) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"), controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"),
ASCIIToUTF16("2050"), ASCIIToUTF16("2050"),
...@@ -249,7 +259,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardAfterFailure) { ...@@ -249,7 +259,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskedCardAfterFailure) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogSavedCardLocally) { TEST_F(CardUnmaskPromptControllerImplTest, LogSavedCardLocally) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/true); ShowPromptAndSimulateResponse(/*should_store_pan=*/true,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::SUCCESS); controller_->OnVerificationResult(AutofillClient::SUCCESS);
...@@ -262,7 +273,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogSavedCardLocally) { ...@@ -262,7 +273,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogSavedCardLocally) {
TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptIn) { TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptIn) {
SetImportCheckboxState(false); SetImportCheckboxState(false);
ShowPromptAndSimulateResponse(/*should_store_pan=*/true); ShowPromptAndSimulateResponse(/*should_store_pan=*/true,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -273,7 +285,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptIn) { ...@@ -273,7 +285,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptIn) {
TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptIn) { TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptIn) {
SetImportCheckboxState(false); SetImportCheckboxState(false);
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -284,7 +297,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptIn) { ...@@ -284,7 +297,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptIn) {
TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptOut) { TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptOut) {
SetImportCheckboxState(true); SetImportCheckboxState(true);
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -295,7 +309,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptOut) { ...@@ -295,7 +309,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidOptOut) {
TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptOut) { TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptOut) {
SetImportCheckboxState(true); SetImportCheckboxState(true);
ShowPromptAndSimulateResponse(/*should_store_pan=*/true); ShowPromptAndSimulateResponse(/*should_store_pan=*/true,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -306,7 +321,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptOut) { ...@@ -306,7 +321,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDidNotOptOut) {
TEST_F(CardUnmaskPromptControllerImplTest, DontLogForHiddenCheckbox) { TEST_F(CardUnmaskPromptControllerImplTest, DontLogForHiddenCheckbox) {
controller_->set_can_store_locally(false); controller_->set_can_store_locally(false);
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -324,6 +340,22 @@ TEST_F(CardUnmaskPromptControllerImplTest, DontLogForHiddenCheckbox) { ...@@ -324,6 +340,22 @@ TEST_F(CardUnmaskPromptControllerImplTest, DontLogForHiddenCheckbox) {
AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT, 0); AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT, 0);
} }
TEST_F(CardUnmaskPromptControllerImplTest,
FidoAuthOfferCheckboxStatePersistent) {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillCreditCardAuthentication);
controller_->set_can_store_locally(false);
ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/true);
EXPECT_TRUE(pref_service_->GetBoolean(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState));
ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
EXPECT_FALSE(pref_service_->GetBoolean(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState));
}
TEST_F(CardUnmaskPromptControllerImplTest, LogDurationNoAttempts) { TEST_F(CardUnmaskPromptControllerImplTest, LogDurationNoAttempts) {
ShowPrompt(); ShowPrompt();
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
...@@ -336,7 +368,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationNoAttempts) { ...@@ -336,7 +368,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationNoAttempts) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogDurationAbandonUnmasking) { TEST_F(CardUnmaskPromptControllerImplTest, LogDurationAbandonUnmasking) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -347,7 +380,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationAbandonUnmasking) { ...@@ -347,7 +380,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationAbandonUnmasking) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogDurationFailedToUnmaskRetriable) { TEST_F(CardUnmaskPromptControllerImplTest, LogDurationFailedToUnmaskRetriable) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
...@@ -360,7 +394,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationFailedToUnmaskRetriable) { ...@@ -360,7 +394,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationFailedToUnmaskRetriable) {
TEST_F(CardUnmaskPromptControllerImplTest, TEST_F(CardUnmaskPromptControllerImplTest,
LogDurationFailedToUnmaskNonRetriable) { LogDurationFailedToUnmaskNonRetriable) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::PERMANENT_FAILURE); controller_->OnVerificationResult(AutofillClient::PERMANENT_FAILURE);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
...@@ -372,7 +407,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, ...@@ -372,7 +407,8 @@ TEST_F(CardUnmaskPromptControllerImplTest,
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogDurationCardFirstAttempt) { TEST_F(CardUnmaskPromptControllerImplTest, LogDurationCardFirstAttempt) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::SUCCESS); controller_->OnVerificationResult(AutofillClient::SUCCESS);
...@@ -385,7 +421,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationCardFirstAttempt) { ...@@ -385,7 +421,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogDurationCardFirstAttempt) {
TEST_F(CardUnmaskPromptControllerImplTest, TEST_F(CardUnmaskPromptControllerImplTest,
LogDurationUnmaskedCardAfterFailure) { LogDurationUnmaskedCardAfterFailure) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
controller_->OnUnmaskPromptAccepted( controller_->OnUnmaskPromptAccepted(
base::ASCIIToUTF16("444"), base::ASCIIToUTF16("01"), base::ASCIIToUTF16("444"), base::ASCIIToUTF16("01"),
...@@ -402,7 +439,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, ...@@ -402,7 +439,8 @@ TEST_F(CardUnmaskPromptControllerImplTest,
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogTimeBeforeAbandonUnmasking) { TEST_F(CardUnmaskPromptControllerImplTest, LogTimeBeforeAbandonUnmasking) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnUnmaskDialogClosed(); controller_->OnUnmaskDialogClosed();
...@@ -412,7 +450,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogTimeBeforeAbandonUnmasking) { ...@@ -412,7 +450,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogTimeBeforeAbandonUnmasking) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanResultSuccess) { TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanResultSuccess) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::SUCCESS); controller_->OnVerificationResult(AutofillClient::SUCCESS);
...@@ -422,7 +461,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanResultSuccess) { ...@@ -422,7 +461,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanResultSuccess) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanTryAgainFailure) { TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanTryAgainFailure) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
...@@ -433,7 +473,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanTryAgainFailure) { ...@@ -433,7 +473,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogRealPanTryAgainFailure) {
} }
TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskingDurationResultSuccess) { TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskingDurationResultSuccess) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::SUCCESS); controller_->OnVerificationResult(AutofillClient::SUCCESS);
...@@ -446,7 +487,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskingDurationResultSuccess) { ...@@ -446,7 +487,8 @@ TEST_F(CardUnmaskPromptControllerImplTest, LogUnmaskingDurationResultSuccess) {
TEST_F(CardUnmaskPromptControllerImplTest, TEST_F(CardUnmaskPromptControllerImplTest,
LogUnmaskingDurationTryAgainFailure) { LogUnmaskingDurationTryAgainFailure) {
ShowPromptAndSimulateResponse(/*should_store_pan=*/false); ShowPromptAndSimulateResponse(/*should_store_pan=*/false,
/*enable_fido_auth=*/false);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE);
......
...@@ -43,14 +43,18 @@ int GetSyncTransportOptInBitFieldForAccount(const PrefService* prefs, ...@@ -43,14 +43,18 @@ int GetSyncTransportOptInBitFieldForAccount(const PrefService* prefs,
const char kAutofillAcceptSaveCreditCardPromptState[] = const char kAutofillAcceptSaveCreditCardPromptState[] =
"autofill.accept_save_credit_card_prompt_state"; "autofill.accept_save_credit_card_prompt_state";
// Boolean that is true if FIDO Authentication is enabled for card unmasking.
const char kAutofillCreditCardFIDOAuthEnabled[] =
"autofill.credit_card_fido_auth_enabled";
// Boolean that is true if Autofill is enabled and allowed to save credit card // Boolean that is true if Autofill is enabled and allowed to save credit card
// data. // data.
const char kAutofillCreditCardEnabled[] = "autofill.credit_card_enabled"; const char kAutofillCreditCardEnabled[] = "autofill.credit_card_enabled";
// Boolean that is true if FIDO Authentication is enabled for card unmasking.
const char kAutofillCreditCardFidoAuthEnabled[] =
"autofill.credit_card_fido_auth_enabled";
// Boolean that is true if FIDO Authentication is enabled for card unmasking.
const char kAutofillCreditCardFidoAuthOfferCheckboxState[] =
"autofill.credit_card_fido_auth_offer_checkbox_state";
// Number of times the credit card signin promo has been shown. // Number of times the credit card signin promo has been shown.
const char kAutofillCreditCardSigninPromoImpressionCount[] = const char kAutofillCreditCardSigninPromoImpressionCount[] =
"autofill.credit_card_signin_promo_impression_count"; "autofill.credit_card_signin_promo_impression_count";
...@@ -157,8 +161,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -157,8 +161,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF);
// Non-synced prefs. Used for per-device choices, e.g., signin promo. // Non-synced prefs. Used for per-device choices, e.g., signin promo.
registry->RegisterBooleanPref(prefs::kAutofillCreditCardFIDOAuthEnabled, registry->RegisterBooleanPref(prefs::kAutofillCreditCardFidoAuthEnabled,
false); false);
registry->RegisterBooleanPref(
prefs::kAutofillCreditCardFidoAuthOfferCheckboxState, true);
registry->RegisterIntegerPref( registry->RegisterIntegerPref(
prefs::kAutofillCreditCardSigninPromoImpressionCount, 0); prefs::kAutofillCreditCardSigninPromoImpressionCount, 0);
registry->RegisterBooleanPref(prefs::kAutofillJapanCityFieldMigrated, false); registry->RegisterBooleanPref(prefs::kAutofillJapanCityFieldMigrated, false);
...@@ -226,11 +232,11 @@ void SetAutofillEnabled(PrefService* prefs, bool enabled) { ...@@ -226,11 +232,11 @@ void SetAutofillEnabled(PrefService* prefs, bool enabled) {
} }
bool IsCreditCardFIDOAuthEnabled(PrefService* prefs) { bool IsCreditCardFIDOAuthEnabled(PrefService* prefs) {
return prefs->GetBoolean(kAutofillCreditCardFIDOAuthEnabled); return prefs->GetBoolean(kAutofillCreditCardFidoAuthEnabled);
} }
void SetCreditCardFIDOAuthEnabled(PrefService* prefs, bool enabled) { void SetCreditCardFIDOAuthEnabled(PrefService* prefs, bool enabled) {
prefs->SetBoolean(kAutofillCreditCardFIDOAuthEnabled, enabled); prefs->SetBoolean(kAutofillCreditCardFidoAuthEnabled, enabled);
} }
bool IsCreditCardAutofillEnabled(const PrefService* prefs) { bool IsCreditCardAutofillEnabled(const PrefService* prefs) {
......
...@@ -20,8 +20,9 @@ namespace prefs { ...@@ -20,8 +20,9 @@ namespace prefs {
// component. Keep alphabetized, and document each in the .cc file. // component. Keep alphabetized, and document each in the .cc file.
extern const char kAutofillAcceptSaveCreditCardPromptState[]; extern const char kAutofillAcceptSaveCreditCardPromptState[];
// Do not get/set the value of this pref directly. Use provided getter/setter. // Do not get/set the value of this pref directly. Use provided getter/setter.
extern const char kAutofillCreditCardFIDOAuthEnabled[];
extern const char kAutofillCreditCardEnabled[]; extern const char kAutofillCreditCardEnabled[];
extern const char kAutofillCreditCardFidoAuthEnabled[];
extern const char kAutofillCreditCardFidoAuthOfferCheckboxState[];
extern const char kAutofillCreditCardSigninPromoImpressionCount[]; extern const char kAutofillCreditCardSigninPromoImpressionCount[];
// Please use kAutofillCreditCardEnabled and kAutofillProfileEnabled instead. // Please use kAutofillCreditCardEnabled and kAutofillProfileEnabled instead.
extern const char kAutofillEnabledDeprecated[]; extern const char kAutofillEnabledDeprecated[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment