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

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

Issue 2873423002: Omnibox UI Experiments: Add flag to change max autocomplete matches. (Closed)
Patch Set: format 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
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..ac307661068255c3d039bd8515172f2400610fe7 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,11 @@
#include "components/url_formatter/url_fixer.h"
// static
-const size_t AutocompleteResult::kMaxMatches = 6;
+size_t AutocompleteResult::GetMaxMatches() {
+ return base::GetFieldTrialParamByFeatureAsInt(
+ omnibox::kUIExperimentMaxAutocompleteMatches,
+ OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, 6);
Peter Kasting 2017/05/10 22:08:05 Nit: For clarity, pull this 6 out as a named const
tommycli 2017/05/10 22:44:29 Done.
+}
void AutocompleteResult::Selection::Clear() {
destination_url = GURL();
@@ -31,7 +36,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 +134,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);

Powered by Google App Engine
This is Rietveld 408576698