}
BookmarkIndex::BookmarkIndex(BookmarkClient* client,
- bool index_urls,
const std::string& languages)
: client_(client),
- languages_(languages),
- index_urls_(index_urls) {
+ languages_(languages) {
DCHECK(client_);
}
ExtractQueryWords(Normalize(node->GetTitle()));
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);
- }
+ 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) {
ExtractQueryWords(Normalize(node->GetTitle()));
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);
- }
+ 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,
base::i18n::ToLower(Normalize(node->GetTitle()));
parser->ExtractQueryWords(lower_title, &title_words);
base::OffsetAdjuster::Adjustments adjustments;
- if (index_urls_) {
- parser->ExtractQueryWords(
- CleanUpUrlForMatching(node->url(), languages_, &adjustments),
- &url_words);
- }
+ 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 = index_urls_ &&
+ const bool has_url_matches =
query_nodes[i]->HasMatchIn(url_words, &url_matches);
if (!has_title_matches && !has_url_matches)
return;
query_parser::QueryParser::SortAndCoalesceMatchPositions(&title_matches);
- if (index_urls_)
- query_parser::QueryParser::SortAndCoalesceMatchPositions(&url_matches);
+ query_parser::QueryParser::SortAndCoalesceMatchPositions(&url_matches);
}
BookmarkMatch match;
if (lower_title.length() == node->GetTitle().length()) {
// TODO(mpearson): revise match positions appropriately.
match.title_match_positions.swap(title_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);
- }
+ // 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);
}