Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 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 kAutofillCreditCardSigninPromo{ | 29 const base::Feature kAutofillCreditCardSigninPromo{ |
| 30 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT}; | 30 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 31 const base::Feature kAutofillScanCardholderName{ | 31 const base::Feature kAutofillScanCardholderName{ |
| 32 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT}; | 32 "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 33 const base::Feature kAutofillCreditCardPopupLayout{ | 33 const base::Feature kAutofillCreditCardPopupLayout{ |
| 34 "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT}; | 34 "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 35 const base::Feature kAutofillCreditCardLastUsedDateDisplay{ | |
| 36 "AutofillCreditCardLastUsedDateDisplay", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 35 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; | 37 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; |
| 36 const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color"; | 38 const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color"; |
| 37 const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color"; | 39 const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color"; |
| 38 const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold"; | 40 const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold"; |
| 39 const char kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey[] = | 41 const char kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey[] = |
| 40 "is_value_and_label_in_single_line"; | 42 "is_value_and_label_in_single_line"; |
| 41 const char kAutofillPopupDropdownItemHeightKey[] = | 43 const char kAutofillPopupDropdownItemHeightKey[] = "dropdown_item_height"; |
| 42 "dropdown_item_height"; | |
| 43 const char kAutofillCreditCardPopupIsIconAtStartKey[] = | 44 const char kAutofillCreditCardPopupIsIconAtStartKey[] = |
| 44 "is_credit_card_icon_at_start"; | 45 "is_credit_card_icon_at_start"; |
| 46 const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[] = | |
| 47 "show_expiration_date"; | |
| 48 const char kAutofillCreditCardLastUsedDateShowTimeDetailKey[] = | |
|
Jared Saul
2017/01/18 18:43:44
The previous file (and later in this one) calls th
jiahuiguo
2017/01/18 22:18:12
Consist to showTimeDetail, otherwise the feature v
| |
| 49 "show_time_detail"; | |
| 45 | 50 |
| 46 namespace { | 51 namespace { |
| 47 | 52 |
| 48 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if | 53 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if |
| 49 // parameter is not specified. | 54 // parameter is not specified. |
| 50 unsigned int GetCreditCardPopupParameterUintValue( | 55 unsigned int GetCreditCardPopupParameterUintValue( |
| 51 const std::string& param_name) { | 56 const std::string& param_name) { |
| 52 unsigned int value; | 57 unsigned int value; |
| 53 const std::string param_value = variations::GetVariationParamValueByFeature( | 58 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 54 kAutofillCreditCardPopupLayout, param_name); | 59 kAutofillCreditCardPopupLayout, param_name); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit)) | 94 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit)) |
| 90 return impression_limit; | 95 return impression_limit; |
| 91 | 96 |
| 92 return 0; | 97 return 0; |
| 93 } | 98 } |
| 94 | 99 |
| 95 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { | 100 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { |
| 96 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); | 101 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); |
| 97 } | 102 } |
| 98 | 103 |
| 104 bool IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled() { | |
| 105 return base::FeatureList::IsEnabled(kAutofillCreditCardLastUsedDateDisplay); | |
| 106 } | |
| 107 | |
| 99 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is | 108 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is |
| 100 // not specified. 0 == |SK_ColorTRANSPARENT|. | 109 // not specified. 0 == |SK_ColorTRANSPARENT|. |
| 101 SkColor GetCreditCardPopupBackgroundColor() { | 110 SkColor GetCreditCardPopupBackgroundColor() { |
| 102 return GetCreditCardPopupParameterUintValue( | 111 return GetCreditCardPopupParameterUintValue( |
| 103 kAutofillCreditCardPopupBackgroundColorKey); | 112 kAutofillCreditCardPopupBackgroundColorKey); |
| 104 } | 113 } |
| 105 | 114 |
| 106 SkColor GetCreditCardPopupDividerColor() { | 115 SkColor GetCreditCardPopupDividerColor() { |
| 107 return GetCreditCardPopupParameterUintValue( | 116 return GetCreditCardPopupParameterUintValue( |
| 108 kAutofillCreditCardPopupDividerColorKey); | 117 kAutofillCreditCardPopupDividerColorKey); |
| 109 } | 118 } |
| 110 | 119 |
| 111 bool IsCreditCardPopupValueBold() { | 120 bool IsCreditCardPopupValueBold() { |
| 112 const std::string param_value = variations::GetVariationParamValueByFeature( | 121 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 113 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); | 122 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); |
| 114 return param_value == "true"; | 123 return param_value == "true"; |
| 115 } | 124 } |
| 116 | 125 |
| 117 unsigned int GetPopupDropdownItemHeight() { | 126 unsigned int GetPopupDropdownItemHeight() { |
| 118 return GetCreditCardPopupParameterUintValue( | 127 return GetCreditCardPopupParameterUintValue( |
| 119 kAutofillPopupDropdownItemHeightKey); | 128 kAutofillPopupDropdownItemHeightKey); |
| 120 } | 129 } |
| 121 | 130 |
| 122 bool IsIconInCreditCardPopupAtStart() { | 131 bool IsIconInCreditCardPopupAtStart() { |
| 123 const std::string param_value = variations::GetVariationParamValueByFeature( | 132 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 124 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey); | 133 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey); |
| 125 return param_value == "true"; | 134 return param_value == "true"; |
| 126 } | 135 } |
| 127 | 136 |
| 137 bool ShowExpirationDateInAutofillCreditCardLastUsedDate() { | |
| 138 const std::string param_value = variations::GetVariationParamValueByFeature( | |
| 139 kAutofillCreditCardLastUsedDateDisplay, | |
| 140 kAutofillCreditCardLastUsedDateShowExpirationDateKey); | |
| 141 return param_value == "true"; | |
| 142 } | |
| 143 | |
| 144 bool ShowDetailedTimeInfoInAutofillCreditCardLastUsedDate() { | |
| 145 const std::string param_value = variations::GetVariationParamValueByFeature( | |
| 146 kAutofillCreditCardLastUsedDateDisplay, | |
| 147 kAutofillCreditCardLastUsedDateShowTimeDetailKey); | |
| 148 return param_value == "true"; | |
| 149 } | |
| 150 | |
| 128 // Modifies |suggestion| as follows if experiment to display value and label in | 151 // Modifies |suggestion| as follows if experiment to display value and label in |
| 129 // a single line is enabled. | 152 // a single line is enabled. |
| 130 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date). | 153 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date). |
| 131 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|. | 154 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|. |
| 132 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) { | 155 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) { |
| 133 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled()); | 156 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled()); |
| 134 const std::string param_value = variations::GetVariationParamValueByFeature( | 157 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 135 kAutofillCreditCardPopupLayout, | 158 kAutofillCreditCardPopupLayout, |
| 136 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey); | 159 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey); |
| 137 if (param_value == "true") { | 160 if (param_value == "true") { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 238 } |
| 216 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 239 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 217 switches::kDisableOfferUploadCreditCards)) { | 240 switches::kDisableOfferUploadCreditCards)) { |
| 218 return false; | 241 return false; |
| 219 } | 242 } |
| 220 | 243 |
| 221 return !group_name.empty() && group_name != "Disabled"; | 244 return !group_name.empty() && group_name != "Disabled"; |
| 222 } | 245 } |
| 223 | 246 |
| 224 } // namespace autofill | 247 } // namespace autofill |
| OLD | NEW |