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

Unified Diff: chrome/browser/history/scored_history_match.cc

Issue 255423002: Omnibox: Highlight Matches in URLs Properly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix OffsetsFromTermMatches test Created 6 years, 8 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
Index: chrome/browser/history/scored_history_match.cc
diff --git a/chrome/browser/history/scored_history_match.cc b/chrome/browser/history/scored_history_match.cc
index d9cab367d77afd865d703f48d89b847acc545e84..cb53eb9fd8ff840667e08ad1e953418063a5118c 100644
--- a/chrome/browser/history/scored_history_match.cc
+++ b/chrome/browser/history/scored_history_match.cc
@@ -68,7 +68,9 @@ ScoredHistoryMatch::ScoredHistoryMatch(
// Figure out where each search term appears in the URL and/or page title
// so that we can score as well as provide autocomplete highlighting.
- base::string16 url = bookmark_utils::CleanUpUrlForMatching(gurl, languages);
+ base::OffsetAdjuster::Adjustments adjustments;
+ base::string16 url =
+ bookmark_utils::CleanUpUrlForMatching(gurl, languages, &adjustments);
base::string16 title = bookmark_utils::CleanUpTitleForMatching(row.title());
int term_num = 0;
for (String16Vector::const_iterator iter = terms.begin(); iter != terms.end();
@@ -207,6 +209,13 @@ ScoredHistoryMatch::ScoredHistoryMatch(
raw_score_ = std::min(max_assigned_score_for_non_inlineable_matches_,
raw_score_);
}
+
+ // Now that we're done processing this entry, correct the offsets of the
+ // matches in |url_matches_| so they point to offsets in the original URL
+ // spec, not the cleaned-up URL string that we used for matching.
+ std::vector<size_t> offsets = OffsetsFromTermMatches(url_matches_);
+ base::OffsetAdjuster::UnadjustOffsets(adjustments, &offsets);
+ url_matches_ = ReplaceOffsetsInTermMatches(url_matches_, offsets);
}
ScoredHistoryMatch::~ScoredHistoryMatch() {}
« no previous file with comments | « chrome/browser/history/in_memory_url_index_types_unittest.cc ('k') | chrome/browser/history/url_index_private_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698