#include "components/content_settings/core/browser/cookie_settings.h"
#include <memory>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "components/content_settings/core/browser/content_settings_info.h"
#include "components/content_settings/core/browser/content_settings_registry.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.h"
#include "components/content_settings/core/common/content_settings_constraints.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/cookie_settings_base.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/host_indexed_content_settings.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "components/tpcd/metadata/browser/manager.h"
#include "extensions/buildflags/buildflags.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/site_for_cookies.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content_settings {
CookieSettings::CookieSettings(
HostContentSettingsMap* host_content_settings_map,
PrefService* prefs,
privacy_sandbox::TrackingProtectionSettings* tracking_protection_settings,
bool is_incognito,
ComputeFedCmSharingPermissionsCallback compute_fedcm_sharing_permissions,
tpcd::metadata::Manager* tpcd_metadata_manager,
const char* extension_scheme)
: … { … }
ContentSetting CookieSettings::GetDefaultCookieSetting(
content_settings::ProviderType* provider_id) const { … }
ContentSettingsForOneType CookieSettings::GetCookieSettings() const { … }
void CookieSettings::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
void CookieSettings::SetDefaultCookieSetting(ContentSetting setting) { … }
void CookieSettings::SetCookieSetting(const GURL& primary_url,
ContentSetting setting) { … }
bool CookieSettings::IsAllowedByTpcdMetadataGrant(const GURL& url,
const GURL& first_party_url,
SettingInfo* out_info) const { … }
void CookieSettings::SetTemporaryCookieGrantForHeuristic(
const GURL& url,
const GURL& first_party_url,
base::TimeDelta ttl,
bool use_schemeless_patterns) { … }
void CookieSettings::SetCookieSettingForUserBypass(
const GURL& first_party_url) { … }
bool CookieSettings::IsStoragePartitioningBypassEnabled(
const GURL& first_party_url) const { … }
void CookieSettings::ResetCookieSetting(const GURL& primary_url) { … }
bool CookieSettings::IsThirdPartyAccessAllowed(
const GURL& first_party_url,
content_settings::SettingInfo* info) const { … }
void CookieSettings::SetThirdPartyCookieSetting(const GURL& first_party_url,
ContentSetting setting) { … }
void CookieSettings::ResetThirdPartyCookieSetting(const GURL& first_party_url) { … }
bool CookieSettings::IsStorageDurable(const GURL& origin) const { … }
bool CookieSettings::HasAnyFrameRequestedStorageAccess(
const GURL& first_party_url) const { … }
bool CookieSettings::ShouldIgnoreSameSiteRestrictions(
const GURL& url,
const net::SiteForCookies& site_for_cookies) const { … }
void CookieSettings::ShutdownOnUIThread() { … }
bool CookieSettings::ShouldAlwaysAllowCookies(
const GURL& url,
const GURL& first_party_url) const { … }
ContentSetting CookieSettings::GetContentSetting(
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
content_settings::SettingInfo* info) const { … }
bool CookieSettings::IsThirdPartyCookiesAllowedScheme(
const std::string& scheme) const { … }
CookieSettings::~CookieSettings() = default;
bool CookieSettings::ShouldBlockThirdPartyCookiesInternal() const { … }
bool CookieSettings::MitigationsEnabledFor3pcdInternal() const { … }
void CookieSettings::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) { … }
void CookieSettings::OnBlockAllThirdPartyCookiesChanged() { … }
void CookieSettings::OnTrackingProtection3pcdChanged() { … }
void CookieSettings::OnCookiePreferencesChanged() { … }
bool CookieSettings::ShouldBlockThirdPartyCookies() const { … }
bool CookieSettings::MitigationsEnabledFor3pcd() const { … }
void CookieSettings::UpdateFedCmSharingPermissions() { … }
bool CookieSettings::HasFedCmSharingPermission(
const GURL& primary_url,
const GURL& secondary_url) const { … }
}