OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 } else { | 159 } else { |
160 // TODO(beng): ACMatchClassification::MATCH now seems to just mean | 160 // TODO(beng): ACMatchClassification::MATCH now seems to just mean |
161 // "bold" this. Consider modifying the terminology. | 161 // "bold" this. Consider modifying the terminology. |
162 // We don't iterate over the string here annotating all matches because | 162 // We don't iterate over the string here annotating all matches because |
163 // it looks odd to have every occurrence of a substring that may be as | 163 // it looks odd to have every occurrence of a substring that may be as |
164 // short as a single character highlighted in a query suggestion result, | 164 // short as a single character highlighted in a query suggestion result, |
165 // e.g. for input text "s" and query string "southwest airlines", it | 165 // e.g. for input text "s" and query string "southwest airlines", it |
166 // looks odd if both the first and last s are highlighted. | 166 // looks odd if both the first and last s are highlighted. |
167 if (input_position != 0) { | 167 if (input_position != 0) { |
168 match.contents_class.push_back( | 168 match.contents_class.push_back( |
169 ACMatchClassification(0, ACMatchClassification::NONE)); | 169 ACMatchClassification(0, ACMatchClassification::MATCH)); |
170 } | 170 } |
171 match.contents_class.push_back( | 171 match.contents_class.push_back( |
172 ACMatchClassification(input_position, ACMatchClassification::DIM)); | 172 ACMatchClassification(input_position, ACMatchClassification::NONE)); |
173 size_t next_fragment_position = input_position + input_text.length(); | 173 size_t next_fragment_position = input_position + input_text.length(); |
174 if (next_fragment_position < query_string.length()) { | 174 if (next_fragment_position < query_string.length()) { |
175 match.contents_class.push_back( | 175 match.contents_class.push_back( |
176 ACMatchClassification(next_fragment_position, | 176 ACMatchClassification(next_fragment_position, |
177 ACMatchClassification::NONE)); | 177 ACMatchClassification::MATCH)); |
178 } | 178 } |
179 } | 179 } |
180 } else { | 180 } else { |
181 // Otherwise, we're dealing with the "default search" result which has no | 181 // Otherwise, we're dealing with the "default search" result which has no |
182 // completion. | 182 // completion. |
183 match.contents_class.push_back( | 183 match.contents_class.push_back( |
184 ACMatchClassification(0, ACMatchClassification::NONE)); | 184 ACMatchClassification(0, ACMatchClassification::NONE)); |
185 } | 185 } |
186 | 186 |
187 // When the user forced a query, we need to make sure all the fill_into_edit | 187 // When the user forced a query, we need to make sure all the fill_into_edit |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 | 629 |
630 // Request history for both the keyword and default provider. We grab many | 630 // Request history for both the keyword and default provider. We grab many |
631 // more matches than we'll ultimately clamp to so that if there are several | 631 // more matches than we'll ultimately clamp to so that if there are several |
632 // recent multi-word matches who scores are lowered (see | 632 // recent multi-word matches who scores are lowered (see |
633 // AddHistoryResultsToMap()), they won't crowd out older, higher-scoring | 633 // AddHistoryResultsToMap()), they won't crowd out older, higher-scoring |
634 // matches. Note that this doesn't fix the problem entirely, but merely | 634 // matches. Note that this doesn't fix the problem entirely, but merely |
635 // limits it to cases with a very large number of such multi-word matches; for | 635 // limits it to cases with a very large number of such multi-word matches; for |
636 // now, this seems OK compared with the complexity of a real fix, which would | 636 // now, this seems OK compared with the complexity of a real fix, which would |
637 // require multiple searches and tracking of "single- vs. multi-word" in the | 637 // require multiple searches and tracking of "single- vs. multi-word" in the |
638 // database. | 638 // database. |
639 int num_matches = kMaxMatches * 5; | 639 int num_matches = kMaxSuggestMatches * 4; |
brettw
2013/06/04 23:43:12
This change needs to be reverted.
Peter Kasting
2013/06/06 18:52:16
I assume you wrote this because you've reverted th
| |
640 const TemplateURL* default_url = providers_.GetDefaultProviderURL(); | 640 const TemplateURL* default_url = providers_.GetDefaultProviderURL(); |
641 if (default_url) { | 641 if (default_url) { |
642 url_db->GetMostRecentKeywordSearchTerms(default_url->id(), input_.text(), | 642 url_db->GetMostRecentKeywordSearchTerms(default_url->id(), input_.text(), |
643 num_matches, &default_history_results_); | 643 num_matches, &default_history_results_); |
644 } | 644 } |
645 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); | 645 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
646 if (keyword_url) { | 646 if (keyword_url) { |
647 url_db->GetMostRecentKeywordSearchTerms(keyword_url->id(), | 647 url_db->GetMostRecentKeywordSearchTerms(keyword_url->id(), |
648 keyword_input_.text(), num_matches, &keyword_history_results_); | 648 keyword_input_.text(), num_matches, &keyword_history_results_); |
649 } | 649 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1099 NavigationResult(*this, | 1099 NavigationResult(*this, |
1100 GURL(UTF16ToUTF8(default_provider_suggestion_.text)), | 1100 GURL(UTF16ToUTF8(default_provider_suggestion_.text)), |
1101 string16(), | 1101 string16(), |
1102 false, | 1102 false, |
1103 kNonURLVerbatimRelevance + 1))); | 1103 kNonURLVerbatimRelevance + 1))); |
1104 } | 1104 } |
1105 AddNavigationResultsToMatches(keyword_results_.navigation_results, true); | 1105 AddNavigationResultsToMatches(keyword_results_.navigation_results, true); |
1106 AddNavigationResultsToMatches(default_results_.navigation_results, false); | 1106 AddNavigationResultsToMatches(default_results_.navigation_results, false); |
1107 | 1107 |
1108 // Allow additional match(es) for verbatim results if present. | 1108 // Allow additional match(es) for verbatim results if present. |
1109 const size_t max_total_matches = kMaxMatches + verbatim_matches_size; | 1109 const size_t max_total_matches = kMaxSuggestMatches + verbatim_matches_size; |
brettw
2013/06/04 23:43:12
Ditto
| |
1110 std::partial_sort(matches_.begin(), | 1110 std::partial_sort(matches_.begin(), |
1111 matches_.begin() + std::min(max_total_matches, matches_.size()), | 1111 matches_.begin() + std::min(max_total_matches, matches_.size()), |
1112 matches_.end(), &AutocompleteMatch::MoreRelevant); | 1112 matches_.end(), &AutocompleteMatch::MoreRelevant); |
1113 | 1113 |
1114 if (matches_.size() > max_total_matches) | 1114 if (matches_.size() > max_total_matches) |
1115 matches_.resize(max_total_matches); | 1115 matches_.resize(max_total_matches); |
1116 } | 1116 } |
1117 | 1117 |
1118 bool SearchProvider::IsTopMatchNavigationInKeywordMode() const { | 1118 bool SearchProvider::IsTopMatchNavigationInKeywordMode() const { |
1119 return (!providers_.keyword_provider().empty() && | 1119 return (!providers_.keyword_provider().empty() && |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1602 it->set_relevance(max_query_relevance); | 1602 it->set_relevance(max_query_relevance); |
1603 } | 1603 } |
1604 } | 1604 } |
1605 | 1605 |
1606 void SearchProvider::UpdateDone() { | 1606 void SearchProvider::UpdateDone() { |
1607 // We're done when the timer isn't running, there are no suggest queries | 1607 // We're done when the timer isn't running, there are no suggest queries |
1608 // pending, and we're not waiting on Instant. | 1608 // pending, and we're not waiting on Instant. |
1609 done_ = IsNonInstantSearchDone() && | 1609 done_ = IsNonInstantSearchDone() && |
1610 (instant_finalized_ || !chrome::IsInstantEnabled(profile_)); | 1610 (instant_finalized_ || !chrome::IsInstantEnabled(profile_)); |
1611 } | 1611 } |
OLD | NEW |