Chromium Code Reviews| Index: components/autofill/core/browser/autofill_experiments.cc |
| diff --git a/components/autofill/core/browser/autofill_experiments.cc b/components/autofill/core/browser/autofill_experiments.cc |
| index e066d854f553a70cb1ea3078c5af875c8b5321b0..13c93ddff84a7944a88a04a02b155c54bc1c184f 100644 |
| --- a/components/autofill/core/browser/autofill_experiments.cc |
| +++ b/components/autofill/core/browser/autofill_experiments.cc |
| @@ -7,9 +7,12 @@ |
| #include "base/command_line.h" |
| #include "base/feature_list.h" |
| #include "base/metrics/field_trial.h" |
| +#include "base/strings/string16.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "build/build_config.h" |
| +#include "components/autofill/core/browser/suggestion.h" |
| #include "components/autofill/core/common/autofill_pref_names.h" |
| #include "components/autofill/core/common/autofill_switches.h" |
| #include "components/prefs/pref_service.h" |
| @@ -17,6 +20,8 @@ |
| #include "components/sync/driver/sync_service.h" |
| #include "components/variations/variations_associated_data.h" |
| #include "google_apis/gaia/gaia_auth_util.h" |
| +#include "grit/components_strings.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| namespace autofill { |
| @@ -28,7 +33,16 @@ const base::Feature kAutofillProfileCleanup{"AutofillProfileCleanup", |
| base::FEATURE_DISABLED_BY_DEFAULT}; |
| const base::Feature kAutofillScanCardholderName{ |
| "AutofillScanCardholderName", base::FEATURE_DISABLED_BY_DEFAULT}; |
| +const base::Feature kAutofillCreditCardPopupLayout{ |
| + "AutofillCreditCardPopupLayout", base::FEATURE_DISABLED_BY_DEFAULT}; |
| const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; |
| +const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color"; |
| +const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color"; |
| +const char kAutofillCreditCardPopupValueBoldKey[] = "is_value_bold"; |
| +const char kAutofillCreditCardPopupDropdownItemHeightKey[] = |
| + "dropdown_item_height"; |
| +const char kAutofillCreditCardPopupIsIconAtLeftKey[] = |
| + "is_credit_card_icon_at_left"; |
| bool IsAutofillEnabled(const PrefService* pref_service) { |
| return pref_service->GetBoolean(prefs::kAutofillEnabled); |
| @@ -67,6 +81,67 @@ int GetCreditCardSigninPromoImpressionLimit() { |
| return 0; |
| } |
| +bool IsAutofillCreditCardPopupLayoutExperimentEnabled() { |
| + return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout); |
| +} |
| + |
| +int GetCreditCardPopupBackgroundColor() { |
| + 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.
|
| + const std::string param_value = variations::GetVariationParamValueByFeature( |
| + kAutofillCreditCardPopupLayout, |
| + kAutofillCreditCardPopupBackgroundColorKey); |
| + if (!param_value.empty() && |
| + base::StringToUint(param_value, &background_color)) |
| + return background_color; |
| + |
| + return 0; |
| +} |
| + |
| +int GetCreditCardPopupDividerColor() { |
| + int background_color; |
| + const std::string param_value = variations::GetVariationParamValueByFeature( |
| + kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupDividerColorKey); |
| + if (!param_value.empty() && |
| + base::StringToUint(param_value, &background_color)) |
| + return background_color; |
| + |
| + return 0; |
| +} |
| + |
| +bool IsCreditCardPopupValueBold() { |
| + const std::string param_value = variations::GetVariationParamValueByFeature( |
| + kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey); |
| + 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.
|
| +} |
| + |
| +int GetCreditCardPopupDropdownItemHeight() { |
| + int dropdown_item_height; |
| + const std::string param_value = variations::GetVariationParamValueByFeature( |
| + kAutofillCreditCardPopupLayout, |
| + kAutofillCreditCardPopupDropdownItemHeightKey); |
| + if (!param_value.empty() && |
| + base::StringToInt(param_value, &dropdown_item_height)) |
| + return dropdown_item_height; |
| + return -1; |
| +} |
| + |
| +bool IsCreditCardIconInPopupAtLeft() { |
| + const std::string param_value = variations::GetVariationParamValueByFeature( |
| + kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtLeftKey); |
| + return param_value.compare("true") == 0; |
| +} |
| + |
| +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.
|
| + if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) { |
|
Mathieu
2016/11/30 21:27:34
DCHECK(IsAutofillCreditCardPopupLayoutExperimentEn
csashi
2016/12/01 01:13:43
Done.
|
| + suggestion->value.append(base::ASCIIToUTF16(", ")); |
| + suggestion->value.append(l10n_util::GetStringUTF16( |
| + IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_LABEL)); |
| + suggestion->value.append(base::ASCIIToUTF16(" ")); |
| + suggestion->value.append(suggestion->label); |
| + suggestion->label.clear(); |
| + } |
| +} |
| + |
| bool OfferStoreUnmaskedCards() { |
| #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| // The checkbox can be forced on with a flag, but by default we don't store |