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

Side by Side Diff: components/autofill/core/browser/autofill_experiments.cc

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Adds clarification for SkColor Created 4 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
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/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "components/autofill/core/browser/suggestion.h"
13 #include "components/autofill/core/common/autofill_pref_names.h" 16 #include "components/autofill/core/common/autofill_pref_names.h"
14 #include "components/autofill/core/common/autofill_switches.h" 17 #include "components/autofill/core/common/autofill_switches.h"
15 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
16 #include "components/security_state/core/switches.h" 19 #include "components/security_state/core/switches.h"
17 #include "components/sync/driver/sync_service.h" 20 #include "components/sync/driver/sync_service.h"
18 #include "components/variations/variations_associated_data.h" 21 #include "components/variations/variations_associated_data.h"
19 #include "google_apis/gaia/gaia_auth_util.h" 22 #include "google_apis/gaia/gaia_auth_util.h"
23 #include "grit/components_strings.h"
24 #include "ui/base/l10n/l10n_util.h"
20 25
21 namespace autofill { 26 namespace autofill {
22 27
23 const base::Feature kAutofillCreditCardAssist{ 28 const base::Feature kAutofillCreditCardAssist{
24 "AutofillCreditCardAssist", base::FEATURE_DISABLED_BY_DEFAULT}; 29 "AutofillCreditCardAssist", base::FEATURE_DISABLED_BY_DEFAULT};
25 const base::Feature kAutofillCreditCardSigninPromo{ 30 const base::Feature kAutofillCreditCardSigninPromo{
26 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT}; 31 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT};
27 const base::Feature kAutofillProfileCleanup{"AutofillProfileCleanup", 32 const base::Feature kAutofillProfileCleanup{"AutofillProfileCleanup",
28 base::FEATURE_DISABLED_BY_DEFAULT}; 33 base::FEATURE_DISABLED_BY_DEFAULT};
29 const base::Feature kAutofillScanCardholderName{ 34 const base::Feature kAutofillScanCardholderName{
30 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT}; 35 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT};
36 const base::Feature kAutofillCreditCardPopupLayout{
37 "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT};
31 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; 38 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit";
39 const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color";
40 const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color";
41 const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold";
42 const char kAutofillCreditCardPopupDropdownItemHeightKey[] =
43 "dropdown_item_height";
44 const char kAutofillCreditCardPopupIsIconAtLeftKey[] =
45 "is_credit_card_icon_at_left";
32 46
33 bool IsAutofillEnabled(const PrefService* pref_service) { 47 bool IsAutofillEnabled(const PrefService* pref_service) {
34 return pref_service->GetBoolean(prefs::kAutofillEnabled); 48 return pref_service->GetBoolean(prefs::kAutofillEnabled);
35 } 49 }
36 50
37 bool IsInAutofillSuggestionsDisabledExperiment() { 51 bool IsInAutofillSuggestionsDisabledExperiment() {
38 std::string group_name = 52 std::string group_name =
39 base::FieldTrialList::FindFullName("AutofillEnabled"); 53 base::FieldTrialList::FindFullName("AutofillEnabled");
40 return group_name == "Disabled"; 54 return group_name == "Disabled";
41 } 55 }
(...skipping 18 matching lines...) Expand all
60 int impression_limit; 74 int impression_limit;
61 std::string param_value = variations::GetVariationParamValueByFeature( 75 std::string param_value = variations::GetVariationParamValueByFeature(
62 kAutofillCreditCardSigninPromo, 76 kAutofillCreditCardSigninPromo,
63 kCreditCardSigninPromoImpressionLimitParamKey); 77 kCreditCardSigninPromoImpressionLimitParamKey);
64 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit)) 78 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit))
65 return impression_limit; 79 return impression_limit;
66 80
67 return 0; 81 return 0;
68 } 82 }
69 83
84 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() {
85 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout);
86 }
87
88 int GetCreditCardPopupBackgroundColor() {
89 int background_color;
Mathieu 2016/11/30 21:27:35 lines 89-94 could be an anonymous function to be r
csashi 2016/12/01 01:13:43 Done.
90 const std::string param_value = variations::GetVariationParamValueByFeature(
91 kAutofillCreditCardPopupLayout,
92 kAutofillCreditCardPopupBackgroundColorKey);
93 if (!param_value.empty() &&
94 base::StringToUint(param_value, &background_color))
95 return background_color;
96
97 return 0;
98 }
99
100 int GetCreditCardPopupDividerColor() {
101 int background_color;
102 const std::string param_value = variations::GetVariationParamValueByFeature(
103 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupDividerColorKey);
104 if (!param_value.empty() &&
105 base::StringToUint(param_value, &background_color))
106 return background_color;
107
108 return 0;
109 }
110
111 bool IsCreditCardPopupValueBold() {
112 const std::string param_value = variations::GetVariationParamValueByFeature(
113 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey);
114 return param_value.compare("true") == 0;
Mathieu 2016/11/30 21:27:35 what about return param_value == "true"?
csashi 2016/12/01 01:13:43 Done.
115 }
116
117 int GetCreditCardPopupDropdownItemHeight() {
118 int dropdown_item_height;
119 const std::string param_value = variations::GetVariationParamValueByFeature(
120 kAutofillCreditCardPopupLayout,
121 kAutofillCreditCardPopupDropdownItemHeightKey);
122 if (!param_value.empty() &&
123 base::StringToInt(param_value, &dropdown_item_height))
124 return dropdown_item_height;
125 return -1;
126 }
127
128 bool IsCreditCardIconInPopupAtLeft() {
129 const std::string param_value = variations::GetVariationParamValueByFeature(
130 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtLeftKey);
131 return param_value.compare("true") == 0;
132 }
133
134 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) {
Mathieu 2016/11/30 21:27:34 Add a comment detailing the final result (it's a b
csashi 2016/12/01 01:13:43 Done.
135 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) {
Mathieu 2016/11/30 21:27:34 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEn
csashi 2016/12/01 01:13:43 Done.
136 suggestion->value.append(base::ASCIIToUTF16(", "));
137 suggestion->value.append(l10n_util::GetStringUTF16(
138 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_LABEL));
139 suggestion->value.append(base::ASCIIToUTF16(" "));
140 suggestion->value.append(suggestion->label);
141 suggestion->label.clear();
142 }
143 }
144
70 bool OfferStoreUnmaskedCards() { 145 bool OfferStoreUnmaskedCards() {
71 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 146 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
72 // The checkbox can be forced on with a flag, but by default we don't store 147 // The checkbox can be forced on with a flag, but by default we don't store
73 // on Linux due to lack of system keychain integration. See crbug.com/162735 148 // on Linux due to lack of system keychain integration. See crbug.com/162735
74 return base::CommandLine::ForCurrentProcess()->HasSwitch( 149 return base::CommandLine::ForCurrentProcess()->HasSwitch(
75 switches::kEnableOfferStoreUnmaskedWalletCards); 150 switches::kEnableOfferStoreUnmaskedWalletCards);
76 #else 151 #else
77 // Query the field trial before checking command line flags to ensure UMA 152 // Query the field trial before checking command line flags to ensure UMA
78 // reports the correct group. 153 // reports the correct group.
79 std::string group_name = 154 std::string group_name =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 219
145 bool IsCreditCardAutofillHttpWarningEnabled() { 220 bool IsCreditCardAutofillHttpWarningEnabled() {
146 std::string choice = 221 std::string choice =
147 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 222 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
148 security_state::switches::kMarkHttpAs); 223 security_state::switches::kMarkHttpAs);
149 return choice == security_state::switches:: 224 return choice == security_state::switches::
150 kMarkHttpWithPasswordsOrCcWithChipAndFormWarning; 225 kMarkHttpWithPasswordsOrCcWithChipAndFormWarning;
151 } 226 }
152 227
153 } // namespace autofill 228 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698