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..2da18c0aa766c48f80331ccbd1a1360a1838439f 100644 |
--- a/components/bookmarks/browser/bookmark_index.cc |
+++ b/components/bookmarks/browser/bookmark_index.cc |
@@ -135,6 +135,7 @@ void BookmarkIndex::Remove(const BookmarkNode* node) { |
void BookmarkIndex::GetBookmarksMatching(const base::string16& input_query, |
size_t max_count, |
+ bool always_prefix_search, |
std::vector<BookmarkMatch>* results) { |
const base::string16 query = Normalize(input_query); |
std::vector<base::string16> terms = ExtractQueryWords(query); |
@@ -143,8 +144,10 @@ void BookmarkIndex::GetBookmarksMatching(const base::string16& input_query, |
Matches matches; |
for (size_t i = 0; i < terms.size(); ++i) { |
- if (!GetBookmarksMatchingTerm(terms[i], i == 0, &matches)) |
+ if (!GetBookmarksMatchingTerm( |
+ terms[i], i == 0, always_prefix_search, &matches)) { |
return; |
+ } |
} |
Nodes sorted_nodes; |
@@ -155,7 +158,7 @@ void BookmarkIndex::GetBookmarksMatching(const base::string16& input_query, |
// matches and so this shouldn't be performance critical. |
query_parser::QueryParser parser; |
ScopedVector<query_parser::QueryNode> query_nodes; |
- parser.ParseQueryNodes(query, &query_nodes.get()); |
+ parser.ParseQueryNodes(query, always_prefix_search, &query_nodes.get()); |
// The highest typed counts should be at the beginning of the results vector |
// so that the best matches will always be included in the results. The loop |
@@ -247,13 +250,15 @@ void BookmarkIndex::AddMatchToResults( |
} |
bool BookmarkIndex::GetBookmarksMatchingTerm(const base::string16& term, |
- bool first_term, |
- Matches* matches) { |
+ bool first_term, |
+ bool always_prefix_search, |
+ Matches* matches) { |
Index::const_iterator i = index_.lower_bound(term); |
if (i == index_.end()) |
return false; |
- if (!query_parser::QueryParser::IsWordLongEnoughForPrefixSearch(term)) { |
+ if (!always_prefix_search && |
+ !query_parser::QueryParser::IsWordLongEnoughForPrefixSearch(term)) { |
// Term is too short for prefix match, compare using exact match. |
if (i->first != term) |
return false; // No bookmarks with this term. |
@@ -334,7 +339,9 @@ std::vector<base::string16> BookmarkIndex::ExtractQueryWords( |
if (query.empty()) |
return std::vector<base::string16>(); |
query_parser::QueryParser parser; |
- parser.ParseQueryWords(base::i18n::ToLower(query), &terms); |
+ parser.ParseQueryWords(base::i18n::ToLower(query), |
+ false, /* always_prefix_search */ |
+ &terms); |
return terms; |
} |