#include "content/browser/first_party_sets/first_party_sets_handler_impl_instance.h"
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "base/files/file.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "content/browser/first_party_sets/first_party_set_parser.h"
#include "content/browser/first_party_sets/first_party_sets_handler_impl.h"
#include "content/browser/first_party_sets/first_party_sets_loader.h"
#include "content/browser/first_party_sets/first_party_sets_overrides_policy.h"
#include "content/browser/first_party_sets/first_party_sets_site_data_remover.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/first_party_sets_handler.h"
#include "content/public/common/content_client.h"
#include "net/base/features.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "net/first_party_sets/first_party_sets_context_config.h"
#include "net/first_party_sets/global_first_party_sets.h"
#include "net/first_party_sets/local_set_declaration.h"
#include "net/first_party_sets/sets_mutation.h"
namespace net {
class SchemefulSite;
}
namespace content {
namespace {
constexpr base::FilePath::CharType kFirstPartySetsDatabase[] = …);
FirstPartySetsHandler* g_test_instance = …;
FirstPartySetsHandlerImpl* g_impl_test_instance = …;
base::TaskPriority GetTaskPriority() { … }
void RecordSitesToClearCount(int count) { … }
}
void FirstPartySetsHandler::SetInstanceForTesting(
FirstPartySetsHandler* test_instance) { … }
void FirstPartySetsHandlerImpl::SetInstanceForTesting(
FirstPartySetsHandlerImpl* test_instance) { … }
FirstPartySetsHandler* FirstPartySetsHandler::GetInstance() { … }
FirstPartySetsHandlerImpl* FirstPartySetsHandlerImpl::GetInstance() { … }
std::pair<base::expected<void, FirstPartySetsHandler::ParseError>,
std::vector<FirstPartySetsHandler::ParseWarning>>
FirstPartySetsHandler::ValidateEnterprisePolicy(
const base::Value::Dict& policy) { … }
FirstPartySetsHandlerImplInstance
FirstPartySetsHandlerImplInstance::CreateForTesting(
bool enabled,
bool embedder_will_provide_public_sets) { … }
void FirstPartySetsHandlerImplInstance::GetContextConfigForPolicy(
const base::Value::Dict* policy,
base::OnceCallback<void(net::FirstPartySetsContextConfig)> callback) { … }
FirstPartySetsHandlerImplInstance::FirstPartySetsHandlerImplInstance(
bool enabled,
bool embedder_will_provide_public_sets)
: … { … }
FirstPartySetsHandlerImplInstance::~FirstPartySetsHandlerImplInstance() =
default;
std::optional<net::GlobalFirstPartySets>
FirstPartySetsHandlerImplInstance::GetSets(
base::OnceCallback<void(net::GlobalFirstPartySets)> callback) { … }
void FirstPartySetsHandlerImplInstance::Init(
const base::FilePath& user_data_dir,
const net::LocalSetDeclaration& local_set) { … }
bool FirstPartySetsHandlerImplInstance::IsEnabled() const { … }
void FirstPartySetsHandlerImplInstance::SetPublicFirstPartySets(
const base::Version& version,
base::File sets_file) { … }
void FirstPartySetsHandlerImplInstance::GetPersistedSetsForTesting(
const std::string& browser_context_id,
base::OnceCallback<void(
std::optional<std::pair<net::GlobalFirstPartySets,
net::FirstPartySetsContextConfig>>)> callback) { … }
void FirstPartySetsHandlerImplInstance::HasBrowserContextClearedForTesting(
const std::string& browser_context_id,
base::OnceCallback<void(std::optional<bool>)> callback) { … }
void FirstPartySetsHandlerImplInstance::SetCompleteSets(
net::GlobalFirstPartySets sets) { … }
void FirstPartySetsHandlerImplInstance::SetDatabase(
const base::FilePath& user_data_dir) { … }
void FirstPartySetsHandlerImplInstance::EnqueuePendingTask(
base::OnceClosure run_task) { … }
void FirstPartySetsHandlerImplInstance::InvokePendingQueries() { … }
std::optional<net::FirstPartySetEntry>
FirstPartySetsHandlerImplInstance::FindEntry(
const net::SchemefulSite& site,
const net::FirstPartySetsContextConfig& config) const { … }
net::GlobalFirstPartySets FirstPartySetsHandlerImplInstance::GetGlobalSetsSync()
const { … }
void FirstPartySetsHandlerImplInstance::ClearSiteDataOnChangedSetsForContext(
base::RepeatingCallback<BrowserContext*()> browser_context_getter,
const std::string& browser_context_id,
net::FirstPartySetsContextConfig context_config,
base::OnceCallback<void(net::FirstPartySetsContextConfig,
net::FirstPartySetsCacheFilter)> callback) { … }
void FirstPartySetsHandlerImplInstance::
ClearSiteDataOnChangedSetsForContextInternal(
base::RepeatingCallback<BrowserContext*()> browser_context_getter,
const std::string& browser_context_id,
net::FirstPartySetsContextConfig context_config,
base::OnceCallback<void(net::FirstPartySetsContextConfig,
net::FirstPartySetsCacheFilter)> callback) { … }
void FirstPartySetsHandlerImplInstance::OnGetSitesToClear(
base::RepeatingCallback<BrowserContext*()> browser_context_getter,
const std::string& browser_context_id,
net::FirstPartySetsContextConfig context_config,
base::OnceCallback<void(net::FirstPartySetsContextConfig,
net::FirstPartySetsCacheFilter)> callback,
std::optional<std::pair<std::vector<net::SchemefulSite>,
net::FirstPartySetsCacheFilter>> sites_to_clear)
const { … }
void FirstPartySetsHandlerImplInstance::DidClearSiteDataOnChangedSetsForContext(
const std::string& browser_context_id,
net::FirstPartySetsContextConfig context_config,
net::FirstPartySetsCacheFilter cache_filter,
base::OnceCallback<void(net::FirstPartySetsContextConfig,
net::FirstPartySetsCacheFilter)> callback,
uint64_t failed_data_types) const { … }
void FirstPartySetsHandlerImplInstance::ComputeFirstPartySetMetadata(
const net::SchemefulSite& site,
const net::SchemefulSite* top_frame_site,
const net::FirstPartySetsContextConfig& config,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback) { … }
void FirstPartySetsHandlerImplInstance::ComputeFirstPartySetMetadataInternal(
const net::SchemefulSite& site,
const std::optional<net::SchemefulSite>& top_frame_site,
const net::FirstPartySetsContextConfig& config,
const base::ElapsedTimer& timer,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback) const { … }
net::FirstPartySetsContextConfig
FirstPartySetsHandlerImplInstance::GetContextConfigForPolicyInternal(
const base::Value::Dict& policy,
const std::optional<base::ElapsedTimer>& timer) const { … }
bool FirstPartySetsHandlerImplInstance::ForEachEffectiveSetEntry(
const net::FirstPartySetsContextConfig& config,
base::FunctionRef<bool(const net::SchemefulSite&,
const net::FirstPartySetEntry&)> f) const { … }
}