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

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

Issue 1545683003: Check user state and settings *before* forcing credit card upload on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash in tests Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_experiments.cc
diff --git a/components/autofill/core/browser/autofill_experiments.cc b/components/autofill/core/browser/autofill_experiments.cc
index 23a6e25ba7ba89cda5840417e42c906116285f85..707fda41c984252694b2b7d433bce06f9eeef5a8 100644
--- a/components/autofill/core/browser/autofill_experiments.cc
+++ b/components/autofill/core/browser/autofill_experiments.cc
@@ -51,28 +51,37 @@ bool OfferStoreUnmaskedCards() {
bool IsCreditCardUploadEnabled(const PrefService* pref_service,
const std::string& user_email) {
- // Query the field trial before checking command line flags to ensure UMA
- // reports the correct group.
+ // Query the field trial first to ensure UMA always reports the correct group.
std::string group_name =
base::FieldTrialList::FindFullName("OfferUploadCreditCards");
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOfferUploadCreditCards))
- return true;
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableOfferUploadCreditCards))
+ // Check user settings.
+ if (!pref_service->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled) ||
+ !pref_service->GetBoolean(prefs::kAutofillWalletImportEnabled)) {
return false;
+ }
- if (group_name.empty() || group_name == "Disabled")
+ // Check that the user is logged into a supported domain.
+ if (user_email.empty())
return false;
+ std::string domain = gaia::ExtractDomainName(user_email);
+ if (!(domain == "googlemail.com" || domain == "gmail.com" ||
+ domain == "google.com")) {
+ return false;
+ }
Ilya Sherman 2015/12/22 21:32:05 What Finch/variations group do you expect to be re
Justin Donnelly 2015/12/22 21:38:29 My (limited, possibly incorrect) understanding is
Ilya Sherman 2015/12/22 21:52:02 Yes, your understanding is correct, and I see your
- if (!pref_service->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled) ||
- !pref_service->GetBoolean(prefs::kAutofillWalletImportEnabled))
+ // With the user settings and logged in state verified, now we can consult the
+ // command-line flags and experiment settings.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableOfferUploadCreditCards)) {
+ return true;
+ }
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
Evan Stade 2015/12/29 17:46:44 this one can still be above
Justin Donnelly 2015/12/29 18:35:19 True. But I prefer to keep it with the other comma
+ switches::kDisableOfferUploadCreditCards)) {
return false;
+ }
- std::string domain = gaia::ExtractDomainName(user_email);
- return domain == "googlemail.com" || domain == "gmail.com" ||
- domain == "google.com";
+ return !group_name.empty() && group_name != "Disabled";
}
} // namespace autofill
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698