#include "components/history_clusters/core/history_clusters_util.h"
#include <algorithm>
#include <set>
#include <string_view>
#include <vector>
#include "base/containers/contains.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/history/core/browser/history_types.h"
#include "components/history_clusters/core/config.h"
#include "components/history_clusters/core/features.h"
#include "components/history_clusters/core/history_clusters_types.h"
#include "components/query_parser/query_parser.h"
#include "components/query_parser/snippet.h"
#include "components/url_formatter/url_formatter.h"
namespace history_clusters {
namespace {
bool DoesQueryMatchClusterKeywords(
const query_parser::QueryNodeVector& find_nodes,
const std::vector<std::u16string>& cluster_keywords) { … }
float MarkMatchesAndGetScore(const query_parser::QueryNodeVector& find_nodes,
history::Cluster* cluster) { … }
void PromoteMatchingVisitsAboveNonMatchingVisits(
std::vector<history::ClusterVisit>& cluster_visits,
history::Cluster::LabelSource label_source) { … }
}
GURL ComputeURLForDeduping(const GURL& url) { … }
std::u16string ComputeURLForDisplay(const GURL& url, bool trim_after_host) { … }
void StableSortVisits(std::vector<history::ClusterVisit>& visits) { … }
void ApplySearchQuery(const std::string& query,
std::vector<history::Cluster>& clusters) { … }
void CullNonProminentOrDuplicateClusters(
std::string query,
std::vector<history::Cluster>& clusters,
std::set<GURL>* seen_single_visit_cluster_urls) { … }
void CullVisitsThatShouldBeHidden(std::vector<history::Cluster>& clusters,
bool is_zero_query_state) { … }
void CoalesceRelatedSearches(std::vector<history::Cluster>& clusters) { … }
void SortClusters(std::vector<history::Cluster>* clusters) { … }
bool ShouldUseNavigationContextClustersFromPersistence() { … }
bool IsTransitionUserVisible(int32_t transition) { … }
std::string GetHistogramNameSliceForRequestSource(
ClusteringRequestSource source) { … }
bool IsUIRequestSource(ClusteringRequestSource source) { … }
bool IsShownVisitCandidate(const history::ClusterVisit& visit) { … }
bool IsVisitInCategories(const history::ClusterVisit& visit,
const base::flat_set<std::string>& categories) { … }
bool IsClusterInCategories(const history::Cluster& cluster,
const base::flat_set<std::string>& categories) { … }
std::set<std::string> GetClusterCategoryIds(const history::Cluster& cluster) { … }
}