chromium/components/history_clusters/core/history_clusters_util.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Returns true if `find_nodes` matches `cluster_keywords`.
bool DoesQueryMatchClusterKeywords(
    const query_parser::QueryNodeVector& find_nodes,
    const std::vector<std::u16string>& cluster_keywords) {}

// Flags any elements within `cluster_visits` that match `find_nodes`. The
// matching is deliberately meant to closely mirror the History implementation.
// Returns the total score of matching visits, and returns 0 if no visits match.
float MarkMatchesAndGetScore(const query_parser::QueryNodeVector& find_nodes,
                             history::Cluster* cluster) {}

// Re-scores and re-sorts `cluster_visits` so that all visits that match the
// search query are promoted above all visits that don't match the search query.
// All visits are likely to be rescored in this case.
//
// Note, this should NOT be called for `cluster_visits` with NO matching visits.
void PromoteMatchingVisitsAboveNonMatchingVisits(
    std::vector<history::ClusterVisit>& cluster_visits,
    history::Cluster::LabelSource label_source) {}

}  // namespace

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) {}

}  // namespace history_clusters