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

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

Issue 2607043002: [Autofill] Credit Card Autofill Last Used Date Experiment (Closed)
Patch Set: Cleaned up included header Created 3 years, 10 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 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/string16.h"
(...skipping 10 matching lines...) Expand all
21 #include "google_apis/gaia/gaia_auth_util.h" 21 #include "google_apis/gaia/gaia_auth_util.h"
22 #include "grit/components_strings.h" 22 #include "grit/components_strings.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 24
25 namespace autofill { 25 namespace autofill {
26 26
27 const base::Feature kAutofillCreditCardAssist{ 27 const base::Feature kAutofillCreditCardAssist{
28 "AutofillCreditCardAssist", base::FEATURE_DISABLED_BY_DEFAULT}; 28 "AutofillCreditCardAssist", base::FEATURE_DISABLED_BY_DEFAULT};
29 const base::Feature kAutofillScanCardholderName{ 29 const base::Feature kAutofillScanCardholderName{
30 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT}; 30 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT};
31 const base::Feature kAutofillCreditCardPopupLayout{ 31 const base::Feature kAutofillCreditCardPopupLayout{
Mathieu 2017/02/04 02:37:58 As discussed, you can reuse this feature instead o
jiahuiguo 2017/02/08 01:21:39 Keep the feature for this version, will create a m
32 "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT}; 32 "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT};
33 const base::Feature kAutofillCreditCardLastUsedDateDisplay{
34 "AutofillCreditCardLastUsedDateDisplay", base::FEATURE_DISABLED_BY_DEFAULT};
35 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit";
33 const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color"; 36 const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color";
34 const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color"; 37 const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color";
35 const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold"; 38 const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold";
36 const char kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey[] = 39 const char kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey[] =
37 "is_value_and_label_in_single_line"; 40 "is_value_and_label_in_single_line";
38 const char kAutofillPopupDropdownItemHeightKey[] = 41 const char kAutofillPopupDropdownItemHeightKey[] = "dropdown_item_height";
39 "dropdown_item_height";
40 const char kAutofillCreditCardPopupIsIconAtStartKey[] = 42 const char kAutofillCreditCardPopupIsIconAtStartKey[] =
41 "is_credit_card_icon_at_start"; 43 "is_credit_card_icon_at_start";
42 const char kAutofillPopupMarginKey[] = "margin"; 44 const char kAutofillPopupMarginKey[] = "margin";
45 const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[] =
46 "show_expiration_date";
47 const char kAutofillCreditCardLastUsedDateShowTimeDetailKey[] =
48 "show_time_detail";
43 49
44 namespace { 50 namespace {
45 51
46 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if 52 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if
47 // parameter is not specified. 53 // parameter is not specified.
48 unsigned int GetCreditCardPopupParameterUintValue( 54 unsigned int GetCreditCardPopupParameterUintValue(
49 const std::string& param_name) { 55 const std::string& param_name) {
50 unsigned int value; 56 unsigned int value;
51 const std::string param_value = variations::GetVariationParamValueByFeature( 57 const std::string param_value = variations::GetVariationParamValueByFeature(
52 kAutofillCreditCardPopupLayout, param_name); 58 kAutofillCreditCardPopupLayout, param_name);
(...skipping 19 matching lines...) Expand all
72 return false; 78 return false;
73 #else 79 #else
74 return base::FeatureList::IsEnabled(kAutofillCreditCardAssist); 80 return base::FeatureList::IsEnabled(kAutofillCreditCardAssist);
75 #endif 81 #endif
76 } 82 }
77 83
78 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { 84 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() {
79 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); 85 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout);
80 } 86 }
81 87
88 bool IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled() {
89 return base::FeatureList::IsEnabled(kAutofillCreditCardLastUsedDateDisplay);
90 }
91
82 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is 92 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is
83 // not specified. 0 == |SK_ColorTRANSPARENT|. 93 // not specified. 0 == |SK_ColorTRANSPARENT|.
84 SkColor GetCreditCardPopupBackgroundColor() { 94 SkColor GetCreditCardPopupBackgroundColor() {
85 return GetCreditCardPopupParameterUintValue( 95 return GetCreditCardPopupParameterUintValue(
86 kAutofillCreditCardPopupBackgroundColorKey); 96 kAutofillCreditCardPopupBackgroundColorKey);
87 } 97 }
88 98
89 SkColor GetCreditCardPopupDividerColor() { 99 SkColor GetCreditCardPopupDividerColor() {
90 return GetCreditCardPopupParameterUintValue( 100 return GetCreditCardPopupParameterUintValue(
91 kAutofillCreditCardPopupDividerColorKey); 101 kAutofillCreditCardPopupDividerColorKey);
92 } 102 }
93 103
94 bool IsCreditCardPopupValueBold() { 104 bool IsCreditCardPopupValueBold() {
95 const std::string param_value = variations::GetVariationParamValueByFeature( 105 const std::string param_value = variations::GetVariationParamValueByFeature(
96 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); 106 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey);
97 return param_value == "true"; 107 return param_value == "true";
98 } 108 }
99 109
100 unsigned int GetPopupDropdownItemHeight() { 110 unsigned int GetPopupDropdownItemHeight() {
101 return GetCreditCardPopupParameterUintValue( 111 return GetCreditCardPopupParameterUintValue(
102 kAutofillPopupDropdownItemHeightKey); 112 kAutofillPopupDropdownItemHeightKey);
103 } 113 }
104 114
105 bool IsIconInCreditCardPopupAtStart() { 115 bool IsIconInCreditCardPopupAtStart() {
106 const std::string param_value = variations::GetVariationParamValueByFeature( 116 const std::string param_value = variations::GetVariationParamValueByFeature(
107 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey); 117 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey);
108 return param_value == "true"; 118 return param_value == "true";
109 } 119 }
110 120
121 bool ShowExpirationDateInAutofillCreditCardLastUsedDate() {
122 const std::string param_value = variations::GetVariationParamValueByFeature(
123 kAutofillCreditCardLastUsedDateDisplay,
124 kAutofillCreditCardLastUsedDateShowExpirationDateKey);
125 return param_value == "true";
126 }
127
128 bool ShowTimeDetailInAutofillCreditCardLastUsedDate() {
129 const std::string param_value = variations::GetVariationParamValueByFeature(
130 kAutofillCreditCardLastUsedDateDisplay,
131 kAutofillCreditCardLastUsedDateShowTimeDetailKey);
132 return param_value == "true";
133 }
134
111 // Modifies |suggestion| as follows if experiment to display value and label in 135 // Modifies |suggestion| as follows if experiment to display value and label in
112 // a single line is enabled. 136 // a single line is enabled.
113 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date). 137 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date).
114 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|. 138 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|.
115 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) { 139 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) {
116 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled()); 140 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled());
117 const std::string param_value = variations::GetVariationParamValueByFeature( 141 const std::string param_value = variations::GetVariationParamValueByFeature(
118 kAutofillCreditCardPopupLayout, 142 kAutofillCreditCardPopupLayout,
119 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey); 143 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey);
120 if (param_value == "true") { 144 if (param_value == "true") {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 226 }
203 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 227 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
204 switches::kDisableOfferUploadCreditCards)) { 228 switches::kDisableOfferUploadCreditCards)) {
205 return false; 229 return false;
206 } 230 }
207 231
208 return !group_name.empty() && group_name != "Disabled"; 232 return !group_name.empty() && group_name != "Disabled";
209 } 233 }
210 234
211 } // namespace autofill 235 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698