Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_result.cc |
| diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc |
| index 0c01b3923344778c50e930e693230cfa507aa19c..d90554a47c4b860c0ef0478ef1a0b78b93e002f3 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_result.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_result.cc |
| @@ -153,11 +153,26 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input, |
| matches_.erase(std::unique(matches_.begin(), matches_.end(), |
| &AutocompleteMatch::DestinationsEqual), |
| matches_.end()); |
| + size_t max_num_matches = std::min(kMaxMatches, matches_.size()); |
|
Mark P
2013/11/04 18:47:56
Can you put this "don't demote top match under cer
H Fung
2013/11/04 19:44:08
I think that would require CompareWithDemoteByType
|
| + |
| + // Don't demote the top match if applicable. |
| + OmniboxFieldTrial::UndemotableTopMatchTypes undemotable_top_types; |
| + OmniboxFieldTrial::GetUndemotableTopTypes(input.current_page_classification(), |
| + &undemotable_top_types); |
| + const bool have_top_undemotable_match = !matches_.empty() && |
| + undemotable_top_types.find(matches_.begin()->type) != |
| + undemotable_top_types.end(); |
| + AutocompleteMatch top_undemotable_match; |
| + if (have_top_undemotable_match) { |
| + top_undemotable_match = *matches_.begin(); |
| + matches_.erase(matches_.begin()); |
| + } |
| // Sort and trim to the most relevant kMaxMatches matches. |
| - size_t max_num_matches = std::min(kMaxMatches, matches_.size()); |
| CompareWithDemoteByType comparing_object(input.current_page_classification()); |
| std::sort(matches_.begin(), matches_.end(), comparing_object); |
| + if (have_top_undemotable_match) |
| + matches_.insert(matches_.begin(), top_undemotable_match); |
| if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match && |
| OmniboxFieldTrial::ReorderForLegalDefaultMatch( |
| input.current_page_classification())) { |