Chromium Code Reviews| Index: chrome/browser/autocomplete/search_provider.cc |
| diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc |
| index 830293131631e74baa5e56e2177586a83b572eb6..6001bea195ba5f4a495c20a35658c60311ef307a 100644 |
| --- a/chrome/browser/autocomplete/search_provider.cc |
| +++ b/chrome/browser/autocomplete/search_provider.cc |
| @@ -779,7 +779,6 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { |
| int did_not_accept_keyword_suggestion = keyword_suggest_results_.empty() ? |
| TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : |
| TemplateURLRef::NO_SUGGESTION_CHOSEN; |
| - // Keyword what you typed results are handled by the KeywordProvider. |
| int verbatim_relevance = GetVerbatimRelevance(); |
| int did_not_accept_default_suggestion = default_suggest_results_.empty() ? |
| @@ -790,6 +789,15 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { |
| AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, |
| did_not_accept_default_suggestion, false, &map); |
| } |
| + const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
| + if (!keyword_input_text_.empty() && keyword_url && |
|
Bart N.
2013/01/29 18:50:42
Most of the time keyword_input_text_ is empty, so
Mark P
2013/01/30 19:46:21
Done. (Perhaps I have too much respect for optimi
|
| + !keyword_url->IsExtensionKeyword()) { |
|
Bart N.
2013/01/29 18:50:42
It's not clear to me why we ignore extension keywo
Mark P
2013/01/30 19:46:21
Done.
|
| + AddMatchToMap(keyword_input_text_, keyword_input_text_, |
| + CalculateRelevanceForKeywordVerbatim( |
| + input_.type(), input_.prefer_keyword()), |
| + AutocompleteMatch::SEARCH_OTHER_ENGINE, |
| + did_not_accept_keyword_suggestion, true, &map); |
| + } |
| const size_t what_you_typed_size = map.size(); |
| if (!default_provider_suggestion_.text.empty() && |
| default_provider_suggestion_.type == INSTANT_SUGGESTION_SEARCH && |
| @@ -826,7 +834,7 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { |
| AddNavigationResultsToMatches(keyword_navigation_results_, true); |
| AddNavigationResultsToMatches(default_navigation_results_, false); |
| - // Allow an additional match for "what you typed" if it's present. |
| + // Allow additional match(es) for "what you typed" results if present. |
|
Bart N.
2013/01/29 18:50:42
If I read the code correctly, we may end up with 5
Mark P
2013/01/30 19:46:21
Yes.
|
| const size_t max_total_matches = kMaxMatches + what_you_typed_size; |
|
Bart N.
2013/01/29 18:50:42
Technically, this is not "what you typed" matches,
Mark P
2013/01/30 19:46:21
Done.
|
| std::partial_sort(matches_.begin(), |
| matches_.begin() + std::min(max_total_matches, matches_.size()), |
| @@ -1086,6 +1094,15 @@ int SearchProvider::CalculateRelevanceForVerbatim() const { |
| } |
| } |
| +// static |
| +int SearchProvider::CalculateRelevanceForKeywordVerbatim( |
| + AutocompleteInput::Type type, |
| + bool prefer_keyword) { |
| + if (prefer_keyword) |
| + return 1500; |
| + return (type == AutocompleteInput::QUERY) ? 1450 : 1100; |
|
Bart N.
2013/01/29 18:50:42
Nit: We don't need () around the first expression.
Mark P
2013/01/30 19:46:21
Done.
|
| +} |
| + |
| int SearchProvider::CalculateRelevanceForHistory( |
| const Time& time, |
| bool is_keyword, |