Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2146823003: Autofill Credit Card Signin Promo: Put behind Feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 04650708eb405ab020c84a21e309541af5932329..45bc868b8bbceebd0a3ff27f6e31bd648e6eca89 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -222,6 +222,10 @@ AutofillManager::~AutofillManager() {}
// static
void AutofillManager::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
+ // This pref is not synced because it's for a signin promo, which by
+ // definition will not be synced.
+ registry->RegisterIntegerPref(
+ prefs::kAutofillCreditCardSigninPromoImpressionCount, 0);
registry->RegisterBooleanPref(
prefs::kAutofillEnabled,
true,
@@ -275,11 +279,30 @@ bool AutofillManager::ShouldShowScanCreditCard(const FormData& form,
bool AutofillManager::ShouldShowCreditCardSigninPromo(
const FormData& form,
const FormFieldData& field) {
+ if (!IsAutofillCreditCardSigninPromoEnabled())
+ return false;
+
// Check whether we are dealing with a credit card field and whether it's
// appropriate to show the promo (e.g. the platform is supported).
AutofillField* autofill_field = GetAutofillField(form, field);
- return autofill_field && autofill_field->Type().group() == CREDIT_CARD &&
- client_->ShouldShowSigninPromo();
+ if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD ||
+ !client_->ShouldShowSigninPromo())
+ return false;
+
+ // The last step is checking if we are under the limit of impressions (a limit
+ // of 0 means there is no limit);
+ int impression_limit = GetCreditCardSigninPromoImpressionLimit();
+ int impression_count = client_->GetPrefs()->GetInteger(
+ prefs::kAutofillCreditCardSigninPromoImpressionCount);
+ if (impression_limit == 0 || impression_count < impression_limit) {
+ // The promo is guaranteed to be shown. Increment the impression count.
sebsg 2016/07/14 15:32:13 Nit: I'm not sure about the phrasing. From what I
Mathieu 2016/07/14 21:51:44 Done.
+ client_->GetPrefs()->SetInteger(
+ prefs::kAutofillCreditCardSigninPromoImpressionCount,
+ impression_count + 1);
+ return true;
+ }
+
+ return false;
}
void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,

Powered by Google App Engine
This is Rietveld 408576698