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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_experiments.h" 5 #include "components/autofill/core/browser/autofill_experiments.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 switches::kDisableOfferStoreUnmaskedWalletCards)) 44 switches::kDisableOfferStoreUnmaskedWalletCards))
45 return false; 45 return false;
46 46
47 // Otherwise use the field trial to show the checkbox or not. 47 // Otherwise use the field trial to show the checkbox or not.
48 return group_name != "Disabled"; 48 return group_name != "Disabled";
49 #endif 49 #endif
50 } 50 }
51 51
52 bool IsCreditCardUploadEnabled(const PrefService* pref_service, 52 bool IsCreditCardUploadEnabled(const PrefService* pref_service,
53 const std::string& user_email) { 53 const std::string& user_email) {
54 // Query the field trial before checking command line flags to ensure UMA 54 // Query the field trial first to ensure UMA always reports the correct group.
55 // reports the correct group.
56 std::string group_name = 55 std::string group_name =
57 base::FieldTrialList::FindFullName("OfferUploadCreditCards"); 56 base::FieldTrialList::FindFullName("OfferUploadCreditCards");
58 57
58 // Check user settings.
59 if (!pref_service->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled) ||
60 !pref_service->GetBoolean(prefs::kAutofillWalletImportEnabled)) {
61 return false;
62 }
63
64 // Check that the user is logged into a supported domain.
65 if (user_email.empty())
66 return false;
67 std::string domain = gaia::ExtractDomainName(user_email);
68 if (!(domain == "googlemail.com" || domain == "gmail.com" ||
69 domain == "google.com")) {
70 return false;
71 }
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
72
73 // With the user settings and logged in state verified, now we can consult the
74 // command-line flags and experiment settings.
59 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 75 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
60 switches::kEnableOfferUploadCreditCards)) 76 switches::kEnableOfferUploadCreditCards)) {
61 return true; 77 return true;
78 }
62 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 79 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
63 switches::kDisableOfferUploadCreditCards)) 80 switches::kDisableOfferUploadCreditCards)) {
64 return false; 81 return false;
82 }
65 83
66 if (group_name.empty() || group_name == "Disabled") 84 return !group_name.empty() && group_name != "Disabled";
67 return false;
68
69 if (!pref_service->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled) ||
70 !pref_service->GetBoolean(prefs::kAutofillWalletImportEnabled))
71 return false;
72
73 std::string domain = gaia::ExtractDomainName(user_email);
74 return domain == "googlemail.com" || domain == "gmail.com" ||
75 domain == "google.com";
76 } 85 }
77 86
78 } // namespace autofill 87 } // namespace autofill
OLDNEW
« 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