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

Unified Diff: components/omnibox/browser/autocomplete_result.cc

Issue 2873423002: Omnibox UI Experiments: Add flag to change max autocomplete matches. (Closed)
Patch Set: fix merge' Created 3 years, 7 months 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
« no previous file with comments | « components/omnibox/browser/autocomplete_result.h ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/autocomplete_result.cc
diff --git a/components/omnibox/browser/autocomplete_result.cc b/components/omnibox/browser/autocomplete_result.cc
index bc51bd46845d919461dd968c60bc1d125f6c21d3..3374b60a7d0c52a124d3e30cd6ceaac7024f519e 100644
--- a/components/omnibox/browser/autocomplete_result.cc
+++ b/components/omnibox/browser/autocomplete_result.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
@@ -21,7 +22,14 @@
#include "components/url_formatter/url_fixer.h"
// static
-const size_t AutocompleteResult::kMaxMatches = 6;
+size_t AutocompleteResult::GetMaxMatches() {
+ constexpr size_t kDefaultMaxAutocompleteMatches = 6;
+
+ return base::GetFieldTrialParamByFeatureAsInt(
+ omnibox::kUIExperimentMaxAutocompleteMatches,
+ OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam,
+ kDefaultMaxAutocompleteMatches);
+}
void AutocompleteResult::Selection::Clear() {
destination_url = GURL();
@@ -31,7 +39,7 @@ void AutocompleteResult::Selection::Clear() {
AutocompleteResult::AutocompleteResult() {
// Reserve space for the max number of matches we'll show.
- matches_.reserve(kMaxMatches);
+ matches_.reserve(GetMaxMatches());
// It's probably safe to do this in the initializer list, but there's little
// penalty to doing it here and it ensures our object is fully constructed
@@ -129,8 +137,8 @@ void AutocompleteResult::SortAndCull(
SortAndDedupMatches(input.current_page_classification(), &matches_);
- // Sort and trim to the most relevant kMaxMatches matches.
- size_t max_num_matches = std::min(kMaxMatches, matches_.size());
+ // Sort and trim to the most relevant GetMaxMatches() matches.
+ size_t max_num_matches = std::min(GetMaxMatches(), matches_.size());
CompareWithDemoteByType<AutocompleteMatch> comparing_object(
input.current_page_classification());
std::sort(matches_.begin(), matches_.end(), comparing_object);
« no previous file with comments | « components/omnibox/browser/autocomplete_result.h ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698