Commit cd688992 authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Add flags for enabling and setting max URL suggestions

This CL only adds a flag with parameter for enabling capping the
number of URL suggestions, and configuring the limit.

Bug: 963174
Change-Id: I5d4310cf361dc5af1df734b8ff433720eef10fc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635435
Commit-Queue: Kevin Bailey <krb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664781}
parent 11568004
...@@ -751,6 +751,29 @@ const FeatureEntry::FeatureVariation ...@@ -751,6 +751,29 @@ const FeatureEntry::FeatureVariation
{"12 matches", kOmniboxUIMaxAutocompleteMatches12, {"12 matches", kOmniboxUIMaxAutocompleteMatches12,
base::size(kOmniboxUIMaxAutocompleteMatches12), nullptr}}; base::size(kOmniboxUIMaxAutocompleteMatches12), nullptr}};
const FeatureEntry::FeatureParam kOmniboxMaxURLMatches2[] = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "2"}};
const FeatureEntry::FeatureParam kOmniboxMaxURLMatches3[] = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "3"}};
const FeatureEntry::FeatureParam kOmniboxMaxURLMatches4[] = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "4"}};
const FeatureEntry::FeatureParam kOmniboxMaxURLMatches5[] = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "5"}};
const FeatureEntry::FeatureParam kOmniboxMaxURLMatches6[] = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "6"}};
const FeatureEntry::FeatureVariation kOmniboxMaxURLMatchesVariations[] = {
{"2 matches", kOmniboxMaxURLMatches2, base::size(kOmniboxMaxURLMatches2),
nullptr},
{"3 matches", kOmniboxMaxURLMatches3, base::size(kOmniboxMaxURLMatches3),
nullptr},
{"4 matches", kOmniboxMaxURLMatches4, base::size(kOmniboxMaxURLMatches4),
nullptr},
{"5 matches", kOmniboxMaxURLMatches5, base::size(kOmniboxMaxURLMatches5),
nullptr},
{"6 matches", kOmniboxMaxURLMatches6, base::size(kOmniboxMaxURLMatches6),
nullptr}};
#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) || \ #if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) || \
defined(OS_CHROMEOS) defined(OS_CHROMEOS)
const FeatureEntry::FeatureParam kTranslateBubbleUIButton[] = { const FeatureEntry::FeatureParam kTranslateBubbleUIButton[] = {
...@@ -2532,6 +2555,12 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2532,6 +2555,12 @@ const FeatureEntry kFeatureEntries[] = {
kOmniboxUIMaxAutocompleteMatchesVariations, kOmniboxUIMaxAutocompleteMatchesVariations,
"OmniboxUIMaxAutocompleteVariations")}, "OmniboxUIMaxAutocompleteVariations")},
{"omnibox-max-url-matches", flag_descriptions::kOmniboxMaxURLMatchesName,
flag_descriptions::kOmniboxMaxURLMatchesDescription, kOsAll,
FEATURE_WITH_PARAMS_VALUE_TYPE(omnibox::kOmniboxMaxURLMatches,
kOmniboxMaxURLMatchesVariations,
"OmniboxMaxURLMatchesVariations")},
{"omnibox-ui-vertical-margin", {"omnibox-ui-vertical-margin",
flag_descriptions::kOmniboxUIVerticalMarginName, flag_descriptions::kOmniboxUIVerticalMarginName,
flag_descriptions::kOmniboxUIVerticalMarginDescription, kOsDesktop, flag_descriptions::kOmniboxUIVerticalMarginDescription, kOsDesktop,
......
...@@ -2400,6 +2400,11 @@ ...@@ -2400,6 +2400,11 @@
"owners": [ "manukh", "chromium-omnibox-team" ], "owners": [ "manukh", "chromium-omnibox-team" ],
"expiry_milestone": 76 "expiry_milestone": 76
}, },
{
"name": "omnibox-max-url-matches",
"owners": [ "krb", "chromium-omnibox-team" ],
"expiry_milestone": 80
},
{ {
"name": "omnibox-new-answer-layout", "name": "omnibox-new-answer-layout",
"owners": [ "chrome-omnibox-team@google.com" ], "owners": [ "chrome-omnibox-team@google.com" ],
......
...@@ -1309,6 +1309,11 @@ const char kOmniboxUIMaxAutocompleteMatchesDescription[] = ...@@ -1309,6 +1309,11 @@ const char kOmniboxUIMaxAutocompleteMatchesDescription[] =
"Changes the maximum number of autocomplete matches displayed in the " "Changes the maximum number of autocomplete matches displayed in the "
"Omnibox UI."; "Omnibox UI.";
const char kOmniboxMaxURLMatchesName[] = "Omnibox Max URL Matches";
const char kOmniboxMaxURLMatchesDescription[] =
"The maximum number of URL matches to show, unless there are no "
"replacements.";
const char kOmniboxUIShowPlaceholderWhenCaretShowingName[] = const char kOmniboxUIShowPlaceholderWhenCaretShowingName[] =
"Omnibox UI Show Placeholder When Caret Showing"; "Omnibox UI Show Placeholder When Caret Showing";
const char kOmniboxUIShowPlaceholderWhenCaretShowingDescription[] = const char kOmniboxUIShowPlaceholderWhenCaretShowingDescription[] =
......
...@@ -797,6 +797,9 @@ extern const char kOmniboxUIOneClickUnelideDescription[]; ...@@ -797,6 +797,9 @@ extern const char kOmniboxUIOneClickUnelideDescription[];
extern const char kOmniboxUIMaxAutocompleteMatchesName[]; extern const char kOmniboxUIMaxAutocompleteMatchesName[];
extern const char kOmniboxUIMaxAutocompleteMatchesDescription[]; extern const char kOmniboxUIMaxAutocompleteMatchesDescription[];
extern const char kOmniboxMaxURLMatchesName[];
extern const char kOmniboxMaxURLMatchesDescription[];
extern const char kOmniboxUIShowPlaceholderWhenCaretShowingName[]; extern const char kOmniboxUIShowPlaceholderWhenCaretShowingName[];
extern const char kOmniboxUIShowPlaceholderWhenCaretShowingDescription[]; extern const char kOmniboxUIShowPlaceholderWhenCaretShowingDescription[];
......
...@@ -181,7 +181,7 @@ void AutocompleteResult::SortAndCull( ...@@ -181,7 +181,7 @@ void AutocompleteResult::SortAndCull(
std::rotate(matches_.begin(), it, it + 1); std::rotate(matches_.begin(), it, it + 1);
size_t max_url_count = 0; size_t max_url_count = 0;
if (OmniboxFieldTrial::IsCapURLMatchesFeatureEnabled() && if (OmniboxFieldTrial::IsMaxURLMatchesFeatureEnabled() &&
(max_url_count = OmniboxFieldTrial::GetMaxURLMatches()) != 0) (max_url_count = OmniboxFieldTrial::GetMaxURLMatches()) != 0)
LimitNumberOfURLsShown(max_url_count, comparing_object); LimitNumberOfURLsShown(max_url_count, comparing_object);
......
...@@ -1049,13 +1049,13 @@ TEST_F(AutocompleteResultTest, SortAndCullGroupSuggestionsByType) { ...@@ -1049,13 +1049,13 @@ TEST_F(AutocompleteResultTest, SortAndCullGroupSuggestionsByType) {
AssertResultMatches(result, expected_data, base::size(expected_data)); AssertResultMatches(result, expected_data, base::size(expected_data));
} }
TEST_F(AutocompleteResultTest, SortAndCullCapURLMatches) { TEST_F(AutocompleteResultTest, SortAndCullMaxURLMatches) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> parameters = { std::map<std::string, std::string> parameters = {
{OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "3"}}; {OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, "3"}};
feature_list.InitAndEnableFeatureWithParameters( feature_list.InitAndEnableFeatureWithParameters(
omnibox::kOmniboxCapURLMatches, parameters); omnibox::kOmniboxMaxURLMatches, parameters);
EXPECT_TRUE(OmniboxFieldTrial::IsCapURLMatchesFeatureEnabled()); EXPECT_TRUE(OmniboxFieldTrial::IsMaxURLMatchesFeatureEnabled());
EXPECT_EQ(OmniboxFieldTrial::GetMaxURLMatches(), 3u); EXPECT_EQ(OmniboxFieldTrial::GetMaxURLMatches(), 3u);
// Case 1: Eject URL match for a search. // Case 1: Eject URL match for a search.
......
...@@ -649,7 +649,7 @@ OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput( ...@@ -649,7 +649,7 @@ OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput(
size_t OmniboxFieldTrial::GetMaxURLMatches() { size_t OmniboxFieldTrial::GetMaxURLMatches() {
return base::GetFieldTrialParamByFeatureAsInt( return base::GetFieldTrialParamByFeatureAsInt(
omnibox::kOmniboxCapURLMatches, omnibox::kOmniboxMaxURLMatches,
OmniboxFieldTrial::kOmniboxMaxURLMatchesParam, OmniboxFieldTrial::kOmniboxMaxURLMatchesParam,
0); // default 0); // default
} }
...@@ -716,8 +716,8 @@ bool OmniboxFieldTrial::IsGroupSuggestionsBySearchVsUrlFeatureEnabled() { ...@@ -716,8 +716,8 @@ bool OmniboxFieldTrial::IsGroupSuggestionsBySearchVsUrlFeatureEnabled() {
omnibox::kOmniboxGroupSuggestionsBySearchVsUrl); omnibox::kOmniboxGroupSuggestionsBySearchVsUrl);
} }
bool OmniboxFieldTrial::IsCapURLMatchesFeatureEnabled() { bool OmniboxFieldTrial::IsMaxURLMatchesFeatureEnabled() {
return base::FeatureList::IsEnabled(omnibox::kOmniboxCapURLMatches); return base::FeatureList::IsEnabled(omnibox::kOmniboxMaxURLMatches);
} }
const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
......
...@@ -439,7 +439,7 @@ bool IsGroupSuggestionsBySearchVsUrlFeatureEnabled(); ...@@ -439,7 +439,7 @@ bool IsGroupSuggestionsBySearchVsUrlFeatureEnabled();
// Returns whether the feature to limit the number of shown URL matches // Returns whether the feature to limit the number of shown URL matches
// is enabled. // is enabled.
bool IsCapURLMatchesFeatureEnabled(); bool IsMaxURLMatchesFeatureEnabled();
// --------------------------------------------------------- // ---------------------------------------------------------
// Clipboard URL suggestions: // Clipboard URL suggestions:
......
...@@ -85,7 +85,7 @@ const base::Feature kOmniboxLocalEntitySuggestions{ ...@@ -85,7 +85,7 @@ const base::Feature kOmniboxLocalEntitySuggestions{
// there are no more non-URL matches available.) If enabled, there is a // there are no more non-URL matches available.) If enabled, there is a
// companion parameter - OmniboxMaxURLMatches - which specifies the maximum // companion parameter - OmniboxMaxURLMatches - which specifies the maximum
// desired number of URL-type matches. // desired number of URL-type matches.
const base::Feature kOmniboxCapURLMatches{"OmniboxCapURLMatches", const base::Feature kOmniboxMaxURLMatches{"OmniboxMaxURLMatches",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Feature used to enable entity suggestion images and enhanced presentation // Feature used to enable entity suggestion images and enhanced presentation
......
...@@ -18,7 +18,7 @@ extern const base::Feature kOneClickUnelide; ...@@ -18,7 +18,7 @@ extern const base::Feature kOneClickUnelide;
extern const base::Feature kSimplifyHttpsIndicator; extern const base::Feature kSimplifyHttpsIndicator;
extern const base::Feature kOmniboxGroupSuggestionsBySearchVsUrl; extern const base::Feature kOmniboxGroupSuggestionsBySearchVsUrl;
extern const base::Feature kOmniboxLocalEntitySuggestions; extern const base::Feature kOmniboxLocalEntitySuggestions;
extern const base::Feature kOmniboxCapURLMatches; extern const base::Feature kOmniboxMaxURLMatches;
extern const base::Feature kOmniboxRichEntitySuggestions; extern const base::Feature kOmniboxRichEntitySuggestions;
extern const base::Feature kOmniboxNewAnswerLayout; extern const base::Feature kOmniboxNewAnswerLayout;
extern const base::Feature kOmniboxReverseAnswers; extern const base::Feature kOmniboxReverseAnswers;
......
...@@ -32974,6 +32974,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> ...@@ -32974,6 +32974,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
</enum> </enum>
<enum name="LoginCustomFlags"> <enum name="LoginCustomFlags">
<int value="-2146979021" label="OmniboxMaxURLMatches:enabled"/>
<int value="-2146832142" label="SyncPseudoUSSSearchEngines:enabled"/> <int value="-2146832142" label="SyncPseudoUSSSearchEngines:enabled"/>
<int value="-2146613579" label="V8Future:disabled"/> <int value="-2146613579" label="V8Future:disabled"/>
<int value="-2145472146" label="OfflinePagesResourceBasedSnapshot:disabled"/> <int value="-2145472146" label="OfflinePagesResourceBasedSnapshot:disabled"/>
...@@ -35750,6 +35751,7 @@ from previous Chrome versions. ...@@ -35750,6 +35751,7 @@ from previous Chrome versions.
<int value="1950191981" label="OverlayNewLayout:enabled"/> <int value="1950191981" label="OverlayNewLayout:enabled"/>
<int value="1951466218" label="enable-data-reduction-proxy-lite-page"/> <int value="1951466218" label="enable-data-reduction-proxy-lite-page"/>
<int value="1951645673" label="PasswordsKeyboardAccessory:disabled"/> <int value="1951645673" label="PasswordsKeyboardAccessory:disabled"/>
<int value="1955238689" label="OmniboxMaxURLMatches:disabled"/>
<int value="1957273171" label="PageAlmostIdle:disabled"/> <int value="1957273171" label="PageAlmostIdle:disabled"/>
<int value="1957358530" label="ContextualSearchSecondTap:enabled"/> <int value="1957358530" label="ContextualSearchSecondTap:enabled"/>
<int value="1957472162" <int value="1957472162"
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