| Index: chrome/browser/bookmarks/bookmark_index.cc
|
| diff --git a/chrome/browser/bookmarks/bookmark_index.cc b/chrome/browser/bookmarks/bookmark_index.cc
|
| index 77c22d985990464467233e624eb214675a3a667b..28c24afe2a24f494a6001e63a88d78c81be34d5d 100644
|
| --- a/chrome/browser/bookmarks/bookmark_index.cc
|
| +++ b/chrome/browser/bookmarks/bookmark_index.cc
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "base/i18n/case_conversion.h"
|
| #include "base/strings/string16.h"
|
| +#include "base/strings/utf_offset_string_conversions.h"
|
| #include "chrome/browser/bookmarks/bookmark_model.h"
|
| #include "chrome/browser/bookmarks/bookmark_utils.h"
|
| #include "chrome/browser/history/history_service.h"
|
| @@ -92,8 +93,8 @@ void BookmarkIndex::Add(const BookmarkNode* node) {
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| RegisterNode(terms[i], node);
|
| if (index_urls_) {
|
| - terms = ExtractQueryWords(
|
| - bookmark_utils::CleanUpUrlForMatching(node->url(), languages_));
|
| + terms = ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
|
| + node->url(), languages_, NULL));
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| RegisterNode(terms[i], node);
|
| }
|
| @@ -108,8 +109,8 @@ void BookmarkIndex::Remove(const BookmarkNode* node) {
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| UnregisterNode(terms[i], node);
|
| if (index_urls_) {
|
| - terms = ExtractQueryWords(
|
| - bookmark_utils::CleanUpUrlForMatching(node->url(), languages_));
|
| + terms = ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
|
| + node->url(), languages_, NULL));
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| UnregisterNode(terms[i], node);
|
| }
|
| @@ -205,10 +206,10 @@ void BookmarkIndex::AddMatchToResults(
|
| const base::string16 lower_title =
|
| base::i18n::ToLower(Normalize(node->GetTitle()));
|
| parser->ExtractQueryWords(lower_title, &title_words);
|
| + base::OffsetAdjuster::Adjustments adjustments;
|
| if (index_urls_) {
|
| - parser->ExtractQueryWords(
|
| - bookmark_utils::CleanUpUrlForMatching(node->url(), languages_),
|
| - &url_words);
|
| + parser->ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
|
| + node->url(), languages_, &adjustments), &url_words);
|
| }
|
| query_parser::Snippet::MatchPositions title_matches, url_matches;
|
| for (size_t i = 0; i < query_nodes.size(); ++i) {
|
| @@ -229,8 +230,17 @@ void BookmarkIndex::AddMatchToResults(
|
| // TODO(mpearson): revise match positions appropriately.
|
| match.title_match_positions.swap(title_matches);
|
| }
|
| - if (index_urls_)
|
| + if (index_urls_) {
|
| + // 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 =
|
| + BookmarkMatch::OffsetsFromMatchPositions(url_matches);
|
| + base::OffsetAdjuster::UnadjustOffsets(adjustments, &offsets);
|
| + url_matches =
|
| + BookmarkMatch::ReplaceOffsetsInMatchPositions(url_matches, offsets);
|
| match.url_match_positions.swap(url_matches);
|
| + }
|
| match.node = node;
|
| results->push_back(match);
|
| }
|
|
|