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

Unified Diff: components/autofill/core/browser/autofill_experiments.cc

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Fixes compile error. Created 4 years 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 side-by-side diff with in-line comments
Download patch
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..8ceb5c6b37cf00599cfff4ee8d08d14cb832a68f 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,34 @@ 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 kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey[] =
+ "is_value_and_label_in_single_line";
+const char kAutofillPopupDropdownItemHeightKey[] =
+ "dropdown_item_height";
+const char kAutofillCreditCardPopupIsIconAtStartKey[] =
+ "is_credit_card_icon_at_start";
+
+namespace {
+
+// Returns parameter value in |kAutofillCreditCardPopupLayout| feature, or 0 if
+// parameter is not specified.
+unsigned int GetCreditCardPopupParameterUintValue(
+ const std::string& param_name) {
+ unsigned int value;
+ const std::string param_value = variations::GetVariationParamValueByFeature(
+ kAutofillCreditCardPopupLayout, param_name);
+ if (!param_value.empty() && base::StringToUint(param_value, &value))
+ return value;
+ return 0;
+}
+
+} // namespace
bool IsAutofillEnabled(const PrefService* pref_service) {
return pref_service->GetBoolean(prefs::kAutofillEnabled);
@@ -67,6 +99,60 @@ int GetCreditCardSigninPromoImpressionLimit() {
return 0;
}
+bool IsAutofillCreditCardPopupLayoutExperimentEnabled() {
+ return base::FeatureList::IsEnabled(kAutofillCreditCardPopupLayout);
+}
+
+// |GetCreditCardPopupParameterUintValue| returns 0 if experiment parameter is
+// not specified. 0 == |SK_ColorTRANSPARENT|.
+SkColor GetCreditCardPopupBackgroundColor() {
+ return GetCreditCardPopupParameterUintValue(
+ kAutofillCreditCardPopupBackgroundColorKey);
+}
+
+SkColor GetCreditCardPopupDividerColor() {
+ return GetCreditCardPopupParameterUintValue(
+ kAutofillCreditCardPopupDividerColorKey);
+}
+
+bool IsCreditCardPopupValueBold() {
+ const std::string param_value = variations::GetVariationParamValueByFeature(
+ kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupValueBoldKey);
+ return param_value == "true";
+}
+
+unsigned int GetPopupDropdownItemHeight() {
+ return GetCreditCardPopupParameterUintValue(
+ kAutofillPopupDropdownItemHeightKey);
+}
+
+bool IsIconInCreditCardPopupAtStart() {
+ const std::string param_value = variations::GetVariationParamValueByFeature(
+ kAutofillCreditCardPopupLayout, kAutofillCreditCardPopupIsIconAtStartKey);
+ return param_value == "true";
+}
+
+// Modifies |suggestion| as follows if experiment to display value and label in
+// a single line is enabled.
+// Say, |value| is 'Visa ....1111' and |label| is '01/18' (expiration date).
+// Modifies |value| to 'Visa ....1111, exp 01/18' and clears |label|.
+void ModifyAutofillCreditCardSuggestion(Suggestion* suggestion) {
+ DCHECK(IsAutofillCreditCardPopupLayoutExperimentEnabled());
+ const std::string param_value = variations::GetVariationParamValueByFeature(
+ kAutofillCreditCardPopupLayout,
+ kAutofillCreditCardPopupIsValueAndLabelInSingleLineKey);
+ if (param_value == "true") {
+ const base::string16 format_string = l10n_util::GetStringUTF16(
+ IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_LABEL_AND_ABBR);
+ if (!format_string.empty()) {
+ suggestion->value.append(l10n_util::GetStringFUTF16(
+ IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_LABEL_AND_ABBR,
+ 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
« no previous file with comments | « components/autofill/core/browser/autofill_experiments.h ('k') | components/autofill/core/browser/autofill_external_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698