#include "components/affiliations/core/browser/affiliation_service_impl.h"
#include <vector>
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "components/affiliations/core/browser/affiliation_backend.h"
#include "components/affiliations/core/browser/affiliation_fetcher_interface.h"
#include "services/network/public/cpp/network_connection_tracker.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
namespace affiliations {
namespace {
void LogFetchResult(GetChangePasswordUrlMetric result) { … }
std::map<FacetURI, AffiliationServiceImpl::ChangePasswordUrlMatch>
CreateFacetUriToChangePasswordUrlMap(
const std::vector<GroupedFacets>& groupings) { … }
}
const char kGetChangePasswordURLMetricName[] = …;
struct AffiliationServiceImpl::FetchInfo { … };
AffiliationServiceImpl::AffiliationServiceImpl(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
: … { … }
AffiliationServiceImpl::~AffiliationServiceImpl() = default;
void AffiliationServiceImpl::Init(
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path) { … }
void AffiliationServiceImpl::Shutdown() { … }
void AffiliationServiceImpl::PrefetchChangePasswordURLs(
const std::vector<GURL>& urls,
base::OnceClosure callback) { … }
void AffiliationServiceImpl::Clear() { … }
GURL AffiliationServiceImpl::GetChangePasswordURL(const GURL& url) const { … }
void AffiliationServiceImpl::OnFetchSucceeded(
AffiliationFetcherInterface* fetcher,
std::unique_ptr<AffiliationFetcherDelegate::Result> result) { … }
void AffiliationServiceImpl::OnFetchFailed(
AffiliationFetcherInterface* fetcher) { … }
void AffiliationServiceImpl::OnMalformedResponse(
AffiliationFetcherInterface* fetcher) { … }
void AffiliationServiceImpl::GetAffiliationsAndBranding(
const FacetURI& facet_uri,
AffiliationService::StrategyOnCacheMiss cache_miss_strategy,
ResultCallback result_callback) { … }
void AffiliationServiceImpl::Prefetch(const FacetURI& facet_uri,
const base::Time& keep_fresh_until) { … }
void AffiliationServiceImpl::CancelPrefetch(
const FacetURI& facet_uri,
const base::Time& keep_fresh_until) { … }
void AffiliationServiceImpl::KeepPrefetchForFacets(
std::vector<FacetURI> facet_uris) { … }
void AffiliationServiceImpl::TrimUnusedCache(std::vector<FacetURI> facet_uris) { … }
void AffiliationServiceImpl::GetGroupingInfo(std::vector<FacetURI> facet_uris,
GroupsCallback callback) { … }
void AffiliationServiceImpl::GetPSLExtensions(
base::OnceCallback<void(std::vector<std::string>)> callback) const { … }
void AffiliationServiceImpl::UpdateAffiliationsAndBranding(
const std::vector<FacetURI>& facets,
base::OnceClosure callback) { … }
void AffiliationServiceImpl::RegisterSource(
std::unique_ptr<AffiliationSource> source) { … }
}