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