UnregisterNode(terms[i], node);
}
-void BookmarkIndex::GetBookmarksMatching(const base::string16& input_query,
- size_t max_count,
- std::vector<BookmarkMatch>* results) {
+void BookmarkIndex::GetBookmarksMatching(
+ const base::string16& input_query,
+ size_t max_count,
+ query_parser::MatchingAlgorithm matching_algorithm,
+ std::vector<BookmarkMatch>* results) {
const base::string16 query = Normalize(input_query);
std::vector<base::string16> terms = ExtractQueryWords(query);
if (terms.empty())
Matches matches;
for (size_t i = 0; i < terms.size(); ++i) {
- if (!GetBookmarksMatchingTerm(terms[i], i == 0, &matches))
+ if (!GetBookmarksMatchingTerm(
+ terms[i], i == 0, matching_algorithm, &matches)) {
return;
+ }
}
Nodes sorted_nodes;
// 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, matching_algorithm, &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
results->push_back(match);
}
-bool BookmarkIndex::GetBookmarksMatchingTerm(const base::string16& term,
- bool first_term,
- Matches* matches) {
+bool BookmarkIndex::GetBookmarksMatchingTerm(
+ const base::string16& term,
+ bool first_term,
+ query_parser::MatchingAlgorithm matching_algorithm,
+ Matches* matches) {
Index::const_iterator i = index_.lower_bound(term);
if (i == index_.end())
return false;
- if (!query_parser::QueryParser::IsWordLongEnoughForPrefixSearch(term)) {
+ if (!query_parser::QueryParser::IsWordLongEnoughForPrefixSearch(
+ term, matching_algorithm)) {
// Term is too short for prefix match, compare using exact match.
if (i->first != term)
return false; // No bookmarks with this term.
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),
+ query_parser::MatchingAlgorithm::DEFAULT,
+ &terms);
return terms;
}