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

Unified Diff: chrome/browser/autocomplete/history_contents_provider.cc

Issue 165455: Autocomplete suggestions for bookmark TitleMatch's does not order matching bo... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_contents_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_contents_provider.cc
===================================================================
--- chrome/browser/autocomplete/history_contents_provider.cc (revision 24426)
+++ chrome/browser/autocomplete/history_contents_provider.cc (working copy)
@@ -71,12 +71,10 @@
return;
}
- // Change input type and reset relevance counters, so matches will be marked
- // up properly.
+ // Change input type so matches will be marked up properly.
input_type_ = input.type();
trim_http_ = !url_util::FindAndCompareScheme(WideToUTF8(input.text()),
chrome::kHttpScheme, NULL);
- star_title_count_ = star_contents_count_ = title_count_ = contents_count_ = 0;
// Decide what to do about any previous query/results.
if (!minimal_changes) {
@@ -150,11 +148,20 @@
}
void HistoryContentsProvider::ConvertResults() {
+ // Reset the relevance counters so that result relevance won't vary on
+ // subsequent passes of ConvertResults.
+ star_title_count_ = star_contents_count_ = title_count_ = contents_count_ = 0;
+
// Make the result references and score the results.
std::vector<MatchReference> result_refs;
result_refs.reserve(results_.size());
- for (size_t i = 0; i < results_.size(); i++) {
- MatchReference ref(&results_[i], CalculateRelevance(results_[i]));
+
+ // Results are sorted in decreasing order so we run the loop backwards so that
+ // the relevance increment favors the higher ranked results.
+ for (std::vector<history::URLResult*>::const_reverse_iterator i =
+ results_.rbegin(); i != results_.rend(); ++i) {
+ history::URLResult* result = *i;
+ MatchReference ref(result, CalculateRelevance(*result));
result_refs.push_back(ref);
}
@@ -275,8 +282,7 @@
if (!bookmark_model)
return;
- DCHECK(results_.size() == 0); // When we get here the results should be
- // empty.
+ DCHECK(results_.empty());
TimeTicks start_time = TimeTicks::Now();
std::vector<bookmark_utils::TitleMatch> matches;
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_contents_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698