| Index: components/bookmarks/browser/bookmark_index.cc
|
| diff --git a/components/bookmarks/browser/bookmark_index.cc b/components/bookmarks/browser/bookmark_index.cc
|
| index 0d549e39a0dcad51a47db0809e0d72e836fa1750..e52b4ec06177c56dee09289964cf513e4a2715e9 100644
|
| --- a/components/bookmarks/browser/bookmark_index.cc
|
| +++ b/components/bookmarks/browser/bookmark_index.cc
|
| @@ -97,9 +97,11 @@
|
| }
|
|
|
| BookmarkIndex::BookmarkIndex(BookmarkClient* client,
|
| + bool index_urls,
|
| const std::string& languages)
|
| : client_(client),
|
| - languages_(languages) {
|
| + languages_(languages),
|
| + index_urls_(index_urls) {
|
| DCHECK(client_);
|
| }
|
|
|
| @@ -113,10 +115,12 @@
|
| ExtractQueryWords(Normalize(node->GetTitle()));
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| RegisterNode(terms[i], node);
|
| - terms =
|
| - ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
|
| - for (size_t i = 0; i < terms.size(); ++i)
|
| - RegisterNode(terms[i], node);
|
| + if (index_urls_) {
|
| + terms =
|
| + ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
|
| + for (size_t i = 0; i < terms.size(); ++i)
|
| + RegisterNode(terms[i], node);
|
| + }
|
| }
|
|
|
| void BookmarkIndex::Remove(const BookmarkNode* node) {
|
| @@ -127,10 +131,12 @@
|
| ExtractQueryWords(Normalize(node->GetTitle()));
|
| for (size_t i = 0; i < terms.size(); ++i)
|
| UnregisterNode(terms[i], node);
|
| - terms =
|
| - ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
|
| - for (size_t i = 0; i < terms.size(); ++i)
|
| - UnregisterNode(terms[i], node);
|
| + if (index_urls_) {
|
| + terms =
|
| + ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
|
| + for (size_t i = 0; i < terms.size(); ++i)
|
| + UnregisterNode(terms[i], node);
|
| + }
|
| }
|
|
|
| void BookmarkIndex::GetBookmarksMatching(const base::string16& input_query,
|
| @@ -212,19 +218,22 @@
|
| base::i18n::ToLower(Normalize(node->GetTitle()));
|
| parser->ExtractQueryWords(lower_title, &title_words);
|
| base::OffsetAdjuster::Adjustments adjustments;
|
| - parser->ExtractQueryWords(
|
| - CleanUpUrlForMatching(node->url(), languages_, &adjustments),
|
| - &url_words);
|
| + if (index_urls_) {
|
| + parser->ExtractQueryWords(
|
| + 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) {
|
| const bool has_title_matches =
|
| query_nodes[i]->HasMatchIn(title_words, &title_matches);
|
| - const bool has_url_matches =
|
| + const bool has_url_matches = index_urls_ &&
|
| query_nodes[i]->HasMatchIn(url_words, &url_matches);
|
| if (!has_title_matches && !has_url_matches)
|
| return;
|
| query_parser::QueryParser::SortAndCoalesceMatchPositions(&title_matches);
|
| - query_parser::QueryParser::SortAndCoalesceMatchPositions(&url_matches);
|
| + if (index_urls_)
|
| + query_parser::QueryParser::SortAndCoalesceMatchPositions(&url_matches);
|
| }
|
| BookmarkMatch match;
|
| if (lower_title.length() == node->GetTitle().length()) {
|
| @@ -233,15 +242,17 @@
|
| // TODO(mpearson): revise match positions appropriately.
|
| match.title_match_positions.swap(title_matches);
|
| }
|
| - // 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);
|
| + 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);
|
| }
|
|
|