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); |