#include "chrome/browser/first_party_sets/first_party_sets_policy_service.h"
#include <utility>
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/types/optional_util.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/privacy_sandbox/tracking_protection_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_constraints.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/first_party_sets_handler.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "net/base/schemeful_site.h"
#include "net/first_party_sets/first_party_set_entry.h"
#include "net/first_party_sets/first_party_set_entry_override.h"
#include "net/first_party_sets/first_party_sets_cache_filter.h"
#include "net/first_party_sets/first_party_sets_context_config.h"
#include "services/network/public/mojom/first_party_sets_access_delegate.mojom.h"
namespace first_party_sets {
namespace {
ServiceState;
network::mojom::FirstPartySetsReadyEventPtr MakeReadyEvent(
net::FirstPartySetsContextConfig config,
net::FirstPartySetsCacheFilter cache_filter) { … }
const base::Value::Dict* GetOverridesPolicyForProfile(
const PrefService* prefs) { … }
ServiceState GetServiceState(Profile* profile, bool pref_enabled) { … }
}
FirstPartySetsPolicyService::FirstPartySetsPolicyService(
content::BrowserContext* browser_context)
: … { … }
FirstPartySetsPolicyService::~FirstPartySetsPolicyService() = default;
void FirstPartySetsPolicyService::InitForTesting() { … }
void FirstPartySetsPolicyService::Init() { … }
void FirstPartySetsPolicyService::ComputeFirstPartySetMetadata(
const net::SchemefulSite& site,
const net::SchemefulSite* top_frame_site,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback) { … }
void FirstPartySetsPolicyService::ComputeFirstPartySetMetadataInternal(
const net::SchemefulSite& site,
const std::optional<net::SchemefulSite>& top_frame_site,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback) const { … }
void FirstPartySetsPolicyService::AddRemoteAccessDelegate(
mojo::Remote<network::mojom::FirstPartySetsAccessDelegate>
access_delegate) { … }
void FirstPartySetsPolicyService::OnFirstPartySetsEnabledChanged(bool enabled) { … }
void FirstPartySetsPolicyService::ClearContentSettings(Profile* profile) const { … }
void FirstPartySetsPolicyService::RegisterThrottleResumeCallback(
base::OnceClosure resume_callback) { … }
void FirstPartySetsPolicyService::Shutdown() { … }
void FirstPartySetsPolicyService::WaitForFirstInitCompleteForTesting(
base::OnceClosure callback) { … }
void FirstPartySetsPolicyService::OnProfileConfigReady(
ServiceState initial_state,
net::FirstPartySetsContextConfig config) { … }
std::optional<net::FirstPartySetEntry> FirstPartySetsPolicyService::FindEntry(
const net::SchemefulSite& site) { … }
bool FirstPartySetsPolicyService::IsSiteInManagedSet(
const net::SchemefulSite& site) const { … }
bool FirstPartySetsPolicyService::ForEachEffectiveSetEntry(
base::FunctionRef<bool(const net::SchemefulSite&,
const net::FirstPartySetEntry&)> f) const { … }
void FirstPartySetsPolicyService::OnReadyToNotifyDelegates(
net::FirstPartySetsContextConfig config,
net::FirstPartySetsCacheFilter cache_filter) { … }
void FirstPartySetsPolicyService::ResetForTesting() { … }
}