Commit 3773deae authored by Fabio Tirelo's avatar Fabio Tirelo Committed by Commit Bot

[AF] Add flag to enable custom font weight for primary info

The goal is to allow experimentation with different font weights
for primary info for Payment Methods and Addresses suggestions on
the Autofill dropdown.

Screenshots on Windows (Googlers only): https://drive.google.com/open?id=1BhZdvN0l9GTzZv2kvim7_OCE9r9OsOhK

Bug: 882525
Change-Id: I9d1ec9ad662e858bd0d9c85c3b31849f13220b86
Reviewed-on: https://chromium-review.googlesource.com/1217171
Commit-Queue: Fabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590316}
parent 217006b4
...@@ -856,6 +856,36 @@ const FeatureEntry::FeatureVariation kAutofillPreviewStyleVariations[] = { ...@@ -856,6 +856,36 @@ const FeatureEntry::FeatureVariation kAutofillPreviewStyleVariations[] = {
{"(Black on GoogleYellow050)", kAutofillPreviewStyleBlackOnYellow050, {"(Black on GoogleYellow050)", kAutofillPreviewStyleBlackOnYellow050,
base::size(kAutofillPreviewStyleBlackOnYellow050), nullptr}}; base::size(kAutofillPreviewStyleBlackOnYellow050), nullptr}};
#if !defined(OS_ANDROID)
const FeatureEntry::FeatureParam kAutofillPrimaryInfoStyleMedium[] = {
{autofill::kAutofillPrimaryInfoFontWeightParameterName,
autofill::kAutofillPrimaryInfoFontWeightParameterMedium},
};
const FeatureEntry::FeatureParam kAutofillPrimaryInfoStyleSemiBold[] = {
{autofill::kAutofillPrimaryInfoFontWeightParameterName,
autofill::kAutofillPrimaryInfoFontWeightParameterSemiBold},
};
const FeatureEntry::FeatureParam kAutofillPrimaryInfoStyleBold[] = {
{autofill::kAutofillPrimaryInfoFontWeightParameterName,
autofill::kAutofillPrimaryInfoFontWeightParameterBold},
};
const FeatureEntry::FeatureParam kAutofillPrimaryInfoStyleExtraBold[] = {
{autofill::kAutofillPrimaryInfoFontWeightParameterName,
autofill::kAutofillPrimaryInfoFontWeightParameterExtraBold},
};
const FeatureEntry::FeatureVariation kAutofillPrimaryInfoStyleVariations[] = {
{"(Medium)", kAutofillPrimaryInfoStyleMedium,
base::size(kAutofillPrimaryInfoStyleMedium), nullptr},
{"(Semi-bold)", kAutofillPrimaryInfoStyleSemiBold,
base::size(kAutofillPrimaryInfoStyleSemiBold), nullptr},
{"(Bold)", kAutofillPrimaryInfoStyleBold,
base::size(kAutofillPrimaryInfoStyleBold), nullptr},
{"(Extra-bold)", kAutofillPrimaryInfoStyleExtraBold,
base::size(kAutofillPrimaryInfoStyleExtraBold), nullptr},
};
#endif // !defined(OS_ANDROID)
const FeatureEntry::Choice kAutoplayPolicyChoices[] = { const FeatureEntry::Choice kAutoplayPolicyChoices[] = {
{flags_ui::kGenericExperimentChoiceDefault, "", ""}, {flags_ui::kGenericExperimentChoiceDefault, "", ""},
{flag_descriptions::kAutoplayPolicyNoUserGestureRequired, {flag_descriptions::kAutoplayPolicyNoUserGestureRequired,
...@@ -4056,6 +4086,18 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -4056,6 +4086,18 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kAutofillCacheQueryResponsesName, flag_descriptions::kAutofillCacheQueryResponsesName,
flag_descriptions::kAutofillCacheQueryResponsesDescription, kOsAll, flag_descriptions::kAutofillCacheQueryResponsesDescription, kOsAll,
FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)}, FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
#if !defined(OS_ANDROID)
{"autofill-primary-info-style",
flag_descriptions::kAutofillPrimaryInfoStyleExperimentName,
flag_descriptions::kAutofillPrimaryInfoStyleExperimentDescription,
kOsDesktop,
FEATURE_WITH_PARAMS_VALUE_TYPE(
autofill::kAutofillPrimaryInfoStyleExperiment,
kAutofillPrimaryInfoStyleVariations,
"AutofillPrimaryInfoStyleExperiment")},
#endif // !defined(OS_ANDROID)
{"autofill-enable-company-name", {"autofill-enable-company-name",
flag_descriptions::kAutofillEnableCompanyNameName, flag_descriptions::kAutofillEnableCompanyNameName,
flag_descriptions::kAutofillEnableCompanyNameDescription, kOsAll, flag_descriptions::kAutofillEnableCompanyNameDescription, kOsAll,
......
...@@ -2770,6 +2770,12 @@ const char kAutofillDropdownLayoutName[] = ...@@ -2770,6 +2770,12 @@ const char kAutofillDropdownLayoutName[] =
const char kAutofillDropdownLayoutDescription[] = const char kAutofillDropdownLayoutDescription[] =
"Alternate visual designs for the Autofill dropdown."; "Alternate visual designs for the Autofill dropdown.";
const char kAutofillPrimaryInfoStyleExperimentName[] =
"Autofill experiment with primary info style";
const char kAutofillPrimaryInfoStyleExperimentDescription[] =
"Allow experimentation with different typefaces for primary info on the "
"Autofill dropdown (addresses and payment methods)";
const char kDoodlesOnLocalNtpName[] = "Enable doodles on the local NTP"; const char kDoodlesOnLocalNtpName[] = "Enable doodles on the local NTP";
const char kDoodlesOnLocalNtpDescription[] = const char kDoodlesOnLocalNtpDescription[] =
"Show doodles on the local New Tab page if Google is the default search " "Show doodles on the local New Tab page if Google is the default search "
......
...@@ -1673,6 +1673,9 @@ extern const char kAccountConsistencyChoiceDice[]; ...@@ -1673,6 +1673,9 @@ extern const char kAccountConsistencyChoiceDice[];
extern const char kAutofillDropdownLayoutName[]; extern const char kAutofillDropdownLayoutName[];
extern const char kAutofillDropdownLayoutDescription[]; extern const char kAutofillDropdownLayoutDescription[];
extern const char kAutofillPrimaryInfoStyleExperimentName[];
extern const char kAutofillPrimaryInfoStyleExperimentDescription[];
extern const char kDoodlesOnLocalNtpName[]; extern const char kDoodlesOnLocalNtpName[];
extern const char kDoodlesOnLocalNtpDescription[]; extern const char kDoodlesOnLocalNtpDescription[];
......
...@@ -175,6 +175,11 @@ class AutofillPopupItemView : public AutofillPopupRowView { ...@@ -175,6 +175,11 @@ class AutofillPopupItemView : public AutofillPopupRowView {
// Creates a label matching the style of the description label. // Creates a label matching the style of the description label.
views::Label* CreateSecondaryLabel(const base::string16& text) const; views::Label* CreateSecondaryLabel(const base::string16& text) const;
// Sets |font_weight| as the font weight to be used for primary information on
// the current item. Returns false if no custom font weight is undefined.
virtual bool ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const = 0;
private: private:
void AddIcon(gfx::ImageSkia icon); void AddIcon(gfx::ImageSkia icon);
void AddSpacerWithSize(int spacer_width, void AddSpacerWithSize(int spacer_width,
...@@ -201,6 +206,8 @@ class AutofillPopupSuggestionView : public AutofillPopupItemView { ...@@ -201,6 +206,8 @@ class AutofillPopupSuggestionView : public AutofillPopupItemView {
// AutofillPopupItemView: // AutofillPopupItemView:
std::unique_ptr<views::Background> CreateBackground() override; std::unique_ptr<views::Background> CreateBackground() override;
int GetPrimaryTextStyle() override; int GetPrimaryTextStyle() override;
bool ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const override;
AutofillPopupSuggestionView(AutofillPopupViewNativeViews* popup_view, AutofillPopupSuggestionView(AutofillPopupViewNativeViews* popup_view,
int line_number); int line_number);
...@@ -222,6 +229,8 @@ class PasswordPopupSuggestionView : public AutofillPopupSuggestionView { ...@@ -222,6 +229,8 @@ class PasswordPopupSuggestionView : public AutofillPopupSuggestionView {
views::View* CreateValueLabel() override; views::View* CreateValueLabel() override;
views::View* CreateSubtextLabel() override; views::View* CreateSubtextLabel() override;
views::View* CreateDescriptionLabel() override; views::View* CreateDescriptionLabel() override;
bool ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const override;
private: private:
PasswordPopupSuggestionView(AutofillPopupViewNativeViews* popup_view, PasswordPopupSuggestionView(AutofillPopupViewNativeViews* popup_view,
...@@ -245,6 +254,8 @@ class AutofillPopupFooterView : public AutofillPopupItemView { ...@@ -245,6 +254,8 @@ class AutofillPopupFooterView : public AutofillPopupItemView {
void CreateContent() override; void CreateContent() override;
std::unique_ptr<views::Background> CreateBackground() override; std::unique_ptr<views::Background> CreateBackground() override;
int GetPrimaryTextStyle() override; int GetPrimaryTextStyle() override;
bool ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const override;
private: private:
AutofillPopupFooterView(AutofillPopupViewNativeViews* popup_view, AutofillPopupFooterView(AutofillPopupViewNativeViews* popup_view,
...@@ -439,10 +450,15 @@ views::View* AutofillPopupItemView::CreateValueLabel() { ...@@ -439,10 +450,15 @@ views::View* AutofillPopupItemView::CreateValueLabel() {
->GetSuggestionAt(line_number_) ->GetSuggestionAt(line_number_)
.is_value_secondary) .is_value_secondary)
return CreateSecondaryLabel(text); return CreateSecondaryLabel(text);
gfx::FontList font_list = views::style::GetFont(
ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, GetPrimaryTextStyle());
gfx::Font::Weight font_weight;
views::Label* text_label = new views::Label( views::Label* text_label = new views::Label(
popup_view_->controller()->GetElidedValueAt(line_number_), popup_view_->controller()->GetElidedValueAt(line_number_),
{views::style::GetFont(ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, {ShouldUseCustomFontWeightForPrimaryInfo(&font_weight)
GetPrimaryTextStyle())}); ? font_list.DeriveWithWeight(font_weight)
: font_list});
text_label->SetEnabledColor( text_label->SetEnabledColor(
views::style::GetColor(*this, ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, views::style::GetColor(*this, ChromeTextContext::CONTEXT_BODY_TEXT_LARGE,
GetPrimaryTextStyle())); GetPrimaryTextStyle()));
...@@ -513,6 +529,11 @@ int AutofillPopupSuggestionView::GetPrimaryTextStyle() { ...@@ -513,6 +529,11 @@ int AutofillPopupSuggestionView::GetPrimaryTextStyle() {
return views::style::TextStyle::STYLE_PRIMARY; return views::style::TextStyle::STYLE_PRIMARY;
} }
bool AutofillPopupSuggestionView::ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const {
return autofill::ShouldUseCustomFontWeightForPrimaryInfo(font_weight);
}
AutofillPopupSuggestionView::AutofillPopupSuggestionView( AutofillPopupSuggestionView::AutofillPopupSuggestionView(
AutofillPopupViewNativeViews* popup_view, AutofillPopupViewNativeViews* popup_view,
int line_number) int line_number)
...@@ -557,6 +578,11 @@ views::View* PasswordPopupSuggestionView::CreateDescriptionLabel() { ...@@ -557,6 +578,11 @@ views::View* PasswordPopupSuggestionView::CreateDescriptionLabel() {
return new ConstrainedWidthView(label, kAutofillPopupPasswordMaxWidth); return new ConstrainedWidthView(label, kAutofillPopupPasswordMaxWidth);
} }
bool PasswordPopupSuggestionView::ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const {
return false;
}
PasswordPopupSuggestionView::PasswordPopupSuggestionView( PasswordPopupSuggestionView::PasswordPopupSuggestionView(
AutofillPopupViewNativeViews* popup_view, AutofillPopupViewNativeViews* popup_view,
int line_number) int line_number)
...@@ -594,6 +620,11 @@ int AutofillPopupFooterView::GetPrimaryTextStyle() { ...@@ -594,6 +620,11 @@ int AutofillPopupFooterView::GetPrimaryTextStyle() {
return ChromeTextStyle::STYLE_SECONDARY; return ChromeTextStyle::STYLE_SECONDARY;
} }
bool AutofillPopupFooterView::ShouldUseCustomFontWeightForPrimaryInfo(
gfx::Font::Weight* font_weight) const {
return false;
}
AutofillPopupFooterView::AutofillPopupFooterView( AutofillPopupFooterView::AutofillPopupFooterView(
AutofillPopupViewNativeViews* popup_view, AutofillPopupViewNativeViews* popup_view,
int line_number) int line_number)
......
...@@ -28,6 +28,14 @@ ...@@ -28,6 +28,14 @@
namespace autofill { namespace autofill {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
const base::Feature kAutofillPrimaryInfoStyleExperiment{
"AutofillPrimaryInfoStyleExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
const char kAutofillPrimaryInfoFontWeightParameterName[] = "font_weight";
const char kAutofillPrimaryInfoFontWeightParameterMedium[] = "medium";
const char kAutofillPrimaryInfoFontWeightParameterSemiBold[] = "semi-bold";
const char kAutofillPrimaryInfoFontWeightParameterBold[] = "bold";
const char kAutofillPrimaryInfoFontWeightParameterExtraBold[] = "extra-bold";
const base::Feature kAutofillDropdownLayoutExperiment{ const base::Feature kAutofillDropdownLayoutExperiment{
"AutofillDropdownLayout", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillDropdownLayout", base::FEATURE_DISABLED_BY_DEFAULT};
const char kAutofillDropdownLayoutParameterName[] = "variant"; const char kAutofillDropdownLayoutParameterName[] = "variant";
...@@ -156,6 +164,45 @@ bool ShouldUseActiveSignedInAccount() { ...@@ -156,6 +164,45 @@ bool ShouldUseActiveSignedInAccount() {
} }
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
namespace {
// Returns the font weight corresponding to the value of param
// kAutofillPrimaryInfoFontWeightParameterName, or INVALID if the param is not
// valid.
gfx::Font::Weight GetFontWeightFromParam() {
std::string param = base::GetFieldTrialParamValueByFeature(
autofill::kAutofillPrimaryInfoStyleExperiment,
autofill::kAutofillPrimaryInfoFontWeightParameterName);
if (param == autofill::kAutofillPrimaryInfoFontWeightParameterMedium)
return gfx::Font::Weight::MEDIUM;
if (param == autofill::kAutofillPrimaryInfoFontWeightParameterSemiBold)
return gfx::Font::Weight::SEMIBOLD;
if (param == autofill::kAutofillPrimaryInfoFontWeightParameterBold)
return gfx::Font::Weight::BOLD;
if (param == autofill::kAutofillPrimaryInfoFontWeightParameterExtraBold)
return gfx::Font::Weight::EXTRA_BOLD;
return gfx::Font::Weight::INVALID;
}
} // namespace
bool ShouldUseCustomFontWeightForPrimaryInfo(gfx::Font::Weight* font_weight) {
if (!base::FeatureList::IsEnabled(
autofill::kAutofillPrimaryInfoStyleExperiment)) {
return false;
}
// Only read the feature param's value the first time it's needed.
static gfx::Font::Weight font_weight_from_param = GetFontWeightFromParam();
if (font_weight_from_param == gfx::Font::Weight::INVALID)
return false;
*font_weight = font_weight_from_param;
return true;
}
ForcedPopupLayoutState GetForcedPopupLayoutState() { ForcedPopupLayoutState GetForcedPopupLayoutState() {
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
autofill::kAutofillDropdownLayoutExperiment)) autofill::kAutofillDropdownLayoutExperiment))
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/gfx/font.h"
class PrefService; class PrefService;
...@@ -28,6 +29,13 @@ extern const base::Feature kAutofillDropdownLayoutExperiment; ...@@ -28,6 +29,13 @@ extern const base::Feature kAutofillDropdownLayoutExperiment;
extern const char kAutofillDropdownLayoutParameterName[]; extern const char kAutofillDropdownLayoutParameterName[];
extern const char kAutofillDropdownLayoutParameterLeadingIcon[]; extern const char kAutofillDropdownLayoutParameterLeadingIcon[];
extern const char kAutofillDropdownLayoutParameterTrailingIcon[]; extern const char kAutofillDropdownLayoutParameterTrailingIcon[];
extern const base::Feature kAutofillPrimaryInfoStyleExperiment;
extern const char kAutofillPrimaryInfoFontWeightParameterName[];
extern const char kAutofillPrimaryInfoFontWeightParameterMedium[];
extern const char kAutofillPrimaryInfoFontWeightParameterSemiBold[];
extern const char kAutofillPrimaryInfoFontWeightParameterBold[];
extern const char kAutofillPrimaryInfoFontWeightParameterExtraBold[];
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
// Returns true if uploading credit cards to Wallet servers is enabled. This // Returns true if uploading credit cards to Wallet servers is enabled. This
...@@ -59,6 +67,12 @@ bool OfferStoreUnmaskedCards(); ...@@ -59,6 +67,12 @@ bool OfferStoreUnmaskedCards();
bool ShouldUseActiveSignedInAccount(); bool ShouldUseActiveSignedInAccount();
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// Sets |font_weight| as the font weight to be used for primary information on
// the Autofill dropdown for Addresses and Credit Cards. Returns false if
// feature kAutofillPrimaryInfoStyleExperiment is disabled or if the
// corresponding feature param is invalid.
bool ShouldUseCustomFontWeightForPrimaryInfo(gfx::Font::Weight* font_weight);
enum class ForcedPopupLayoutState { enum class ForcedPopupLayoutState {
kDefault, // No popup layout forced by experiment. kDefault, // No popup layout forced by experiment.
kLeadingIcon, // Experiment forces leading (left in LTR) icon layout. kLeadingIcon, // Experiment forces leading (left in LTR) icon layout.
......
...@@ -29735,6 +29735,7 @@ from previous Chrome versions. ...@@ -29735,6 +29735,7 @@ from previous Chrome versions.
<int value="1098823967" label="ash-enable-window-cycle-ui"/> <int value="1098823967" label="ash-enable-window-cycle-ui"/>
<int value="1104948452" label="manual-enhanced-bookmarks-optout"/> <int value="1104948452" label="manual-enhanced-bookmarks-optout"/>
<int value="1105439588" label="enable-swipe-selection"/> <int value="1105439588" label="enable-swipe-selection"/>
<int value="1106307305" label="AutofillPrimaryInfoStyleExperiment:enabled"/>
<int value="1107543566" label="enable-one-copy"/> <int value="1107543566" label="enable-one-copy"/>
<int value="1108663108" label="disable-device-discovery-notifications"/> <int value="1108663108" label="disable-device-discovery-notifications"/>
<int value="1111871757" label="ForceUnifiedConsentBump:enabled"/> <int value="1111871757" label="ForceUnifiedConsentBump:enabled"/>
...@@ -29995,6 +29996,7 @@ from previous Chrome versions. ...@@ -29995,6 +29996,7 @@ from previous Chrome versions.
<int value="1594664550" label="NTPModernLayout:enabled"/> <int value="1594664550" label="NTPModernLayout:enabled"/>
<int value="1600926040" label="TranslateCompactUI:enabled"/> <int value="1600926040" label="TranslateCompactUI:enabled"/>
<int value="1605611615" label="enable-webrtc-srtp-aes-gcm"/> <int value="1605611615" label="enable-webrtc-srtp-aes-gcm"/>
<int value="1611522475" label="AutofillPrimaryInfoStyleExperiment:disabled"/>
<int value="1612446645" label="enable-weak-memorycache"/> <int value="1612446645" label="enable-weak-memorycache"/>
<int value="1612871297" label="WebPayments:disabled"/> <int value="1612871297" label="WebPayments:disabled"/>
<int value="1612974229" label="allow-insecure-localhost"/> <int value="1612974229" label="allow-insecure-localhost"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment