#include "components/bookmarks/browser/titled_url_index.h"
#include <stdint.h>
#include <algorithm>
#include <iterator>
#include <unordered_set>
#include <utility>
#include "base/i18n/case_conversion.h"
#include "base/i18n/unicodestring.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/stl_util.h"
#include "base/strings/utf_offset_string_conversions.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "build/build_config.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "components/bookmarks/browser/titled_url_node.h"
#include "components/query_parser/snippet.h"
#include "third_party/icu/source/common/unicode/normalizer2.h"
#include "third_party/icu/source/common/unicode/utypes.h"
namespace bookmarks {
namespace {
bool IsPrefix(const std::u16string& prefix, const std::u16string& string) { … }
}
TitledUrlIndex::TitledUrlIndex(std::unique_ptr<TitledUrlNodeSorter> sorter)
: … { … }
TitledUrlIndex::~TitledUrlIndex() = default;
void TitledUrlIndex::SetNodeSorter(
std::unique_ptr<TitledUrlNodeSorter> sorter) { … }
void TitledUrlIndex::Add(const TitledUrlNode* node) { … }
void TitledUrlIndex::Remove(const TitledUrlNode* node) { … }
void TitledUrlIndex::AddPath(const TitledUrlNode* node) { … }
void TitledUrlIndex::RemovePath(const TitledUrlNode* node) { … }
std::vector<TitledUrlMatch> TitledUrlIndex::GetResultsMatching(
const std::u16string& input_query,
size_t max_count,
query_parser::MatchingAlgorithm matching_algorithm) { … }
std::u16string TitledUrlIndex::Normalize(std::u16string_view text) { … }
void TitledUrlIndex::SortMatches(const TitledUrlNodeSet& matches,
TitledUrlNodes* sorted_nodes) const { … }
std::vector<TitledUrlMatch> TitledUrlIndex::MatchTitledUrlNodesWithQuery(
const TitledUrlNodes& nodes,
const query_parser::QueryNodeVector& query_nodes,
const std::vector<std::u16string>& query_terms,
size_t max_count) { … }
std::optional<TitledUrlMatch> TitledUrlIndex::MatchTitledUrlNodeWithQuery(
const TitledUrlNode* node,
const query_parser::QueryNodeVector& query_nodes,
const std::vector<std::u16string>& query_terms) { … }
TitledUrlIndex::TitledUrlNodeSet TitledUrlIndex::RetrieveNodesMatchingAllTerms(
const std::vector<std::u16string>& terms,
query_parser::MatchingAlgorithm matching_algorithm) const { … }
TitledUrlIndex::TitledUrlNodeSet TitledUrlIndex::RetrieveNodesMatchingAnyTerms(
const std::vector<std::u16string>& terms,
query_parser::MatchingAlgorithm matching_algorithm,
size_t max_nodes) const { … }
TitledUrlIndex::TitledUrlNodes TitledUrlIndex::RetrieveNodesMatchingTerm(
const std::u16string& term,
query_parser::MatchingAlgorithm matching_algorithm) const { … }
bool TitledUrlIndex::DoesTermMatchPath(
const std::u16string& term,
query_parser::MatchingAlgorithm matching_algorithm) const { … }
std::vector<std::u16string> TitledUrlIndex::ExtractQueryWords(
const std::u16string& query) { … }
std::vector<std::u16string> TitledUrlIndex::ExtractIndexTerms(
const TitledUrlNode* node) { … }
void TitledUrlIndex::RegisterNode(const std::u16string& term,
const TitledUrlNode* node) { … }
void TitledUrlIndex::UnregisterNode(const std::u16string& term,
const TitledUrlNode* node) { … }
}