| 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 12 matching lines...) Expand all Loading... |
| 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{ |
| 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"; |
| 43 | 47 |
| 44 namespace { | 48 namespace { |
| 45 | 49 |
| 46 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if | 50 // Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if |
| 47 // parameter is not specified. | 51 // parameter is not specified. |
| 48 unsigned int GetCreditCardPopupParameterUintValue( | 52 unsigned int GetCreditCardPopupParameterUintValue( |
| 49 const std::string& param_name) { | 53 const std::string& param_name) { |
| 50 unsigned int value; | 54 unsigned int value; |
| 51 const std::string param_value = variations::GetVariationParamValueByFeature( | 55 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 52 kAutofillCreditCardPopupLayout, param_name); | 56 kAutofillCreditCardPopupLayout, param_name); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 return false; | 76 return false; |
| 73 #else | 77 #else |
| 74 return base::FeatureList::IsEnabled(kAutofillCreditCardAssist); | 78 return base::FeatureList::IsEnabled(kAutofillCreditCardAssist); |
| 75 #endif | 79 #endif |
| 76 } | 80 } |
| 77 | 81 |
| 78 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { | 82 bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { |
| 79 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); | 83 return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); |
| 80 } | 84 } |
| 81 | 85 |
| 86 bool IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled() { |
| 87 return base::FeatureList::IsEnabled(kAutofillCreditCardLastUsedDateDisplay); |
| 88 } |
| 89 |
| 82 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is | 90 // |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is |
| 83 // not specified. 0 == |SK_ColorTRANSPARENT|. | 91 // not specified. 0 == |SK_ColorTRANSPARENT|. |
| 84 SkColor GetCreditCardPopupBackgroundColor() { | 92 SkColor GetCreditCardPopupBackgroundColor() { |
| 85 return GetCreditCardPopupParameterUintValue( | 93 return GetCreditCardPopupParameterUintValue( |
| 86 kAutofillCreditCardPopupBackgroundColorKey); | 94 kAutofillCreditCardPopupBackgroundColorKey); |
| 87 } | 95 } |
| 88 | 96 |
| 89 SkColor GetCreditCardPopupDividerColor() { | 97 SkColor GetCreditCardPopupDividerColor() { |
| 90 return GetCreditCardPopupParameterUintValue( | 98 return GetCreditCardPopupParameterUintValue( |
| 91 kAutofillCreditCardPopupDividerColorKey); | 99 kAutofillCreditCardPopupDividerColorKey); |
| 92 } | 100 } |
| 93 | 101 |
| 94 bool IsCreditCardPopupValueBold() { | 102 bool IsCreditCardPopupValueBold() { |
| 95 const std::string param_value = variations::GetVariationParamValueByFeature( | 103 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 96 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); | 104 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); |
| 97 return param_value == "true"; | 105 return param_value == "true"; |
| 98 } | 106 } |
| 99 | 107 |
| 100 unsigned int GetPopupDropdownItemHeight() { | 108 unsigned int GetPopupDropdownItemHeight() { |
| 101 return GetCreditCardPopupParameterUintValue( | 109 return GetCreditCardPopupParameterUintValue( |
| 102 kAutofillPopupDropdownItemHeightKey); | 110 kAutofillPopupDropdownItemHeightKey); |
| 103 } | 111 } |
| 104 | 112 |
| 105 bool IsIconInCreditCardPopupAtStart() { | 113 bool IsIconInCreditCardPopupAtStart() { |
| 106 const std::string param_value = variations::GetVariationParamValueByFeature( | 114 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 107 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey); | 115 kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey); |
| 108 return param_value == "true"; | 116 return param_value == "true"; |
| 109 } | 117 } |
| 110 | 118 |
| 119 bool ShowExpirationDateInAutofillCreditCardLastUsedDate() { |
| 120 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 121 kAutofillCreditCardLastUsedDateDisplay, |
| 122 kAutofillCreditCardLastUsedDateShowExpirationDateKey); |
| 123 return param_value == "true"; |
| 124 } |
| 125 |
| 111 // Modifies |suggestion| as follows if experiment to display value and label in | 126 // Modifies |suggestion| as follows if experiment to display value and label in |
| 112 // a single line is enabled. | 127 // a single line is enabled. |
| 113 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date). | 128 // Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date). |
| 114 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|. | 129 // Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|. |
| 115 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) { | 130 void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) { |
| 116 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled()); | 131 DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled()); |
| 117 const std::string param_value = variations::GetVariationParamValueByFeature( | 132 const std::string param_value = variations::GetVariationParamValueByFeature( |
| 118 kAutofillCreditCardPopupLayout, | 133 kAutofillCreditCardPopupLayout, |
| 119 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey); | 134 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey); |
| 120 if (param_value == "true") { | 135 if (param_value == "true") { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 217 } |
| 203 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 218 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 204 switches::kDisableOfferUploadCreditCards)) { | 219 switches::kDisableOfferUploadCreditCards)) { |
| 205 return false; | 220 return false; |
| 206 } | 221 } |
| 207 | 222 |
| 208 return !group_name.empty() && group_name != "Disabled"; | 223 return !group_name.empty() && group_name != "Disabled"; |
| 209 } | 224 } |
| 210 | 225 |
| 211 } // namespace autofill | 226 } // namespace autofill |
| OLD | NEW |