#include "services/network/cookie_settings.h"
#include <functional>
#include <iterator>
#include <memory>
#include <optional>
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_map.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/to_string.h"
#include "base/types/optional_util.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_rules.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 "net/base/network_delegate.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/static_cookie_policy.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "services/network/tpcd/metadata/manager.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace network {
namespace {
bool ShouldApply3pcdRelatedReasons(const net::CanonicalCookie& cookie) { … }
bool IsValidType(ContentSettingsType type) { … }
net::CookieInclusionStatus::ExemptionReason GetExemptionReason(
CookieSettings::ThirdPartyCookieAllowMechanism allow_mechanism) { … }
bool IsOriginOpaqueHttpOrHttps(const url::Origin* top_frame_origin) { … }
}
bool CookieSettings::IsCookieAllowed(const net::CanonicalCookie& cookie,
const CookieSettingWithMetadata& setting) { … }
net::NetworkDelegate::PrivacySetting CookieSettings::PrivacySetting(
const CookieSettingWithMetadata& setting) { … }
CookieSettings::CookieSettings() { … }
CookieSettings::~CookieSettings() = default;
void CookieSettings::set_content_settings(
ContentSettingsType type,
const ContentSettingsForOneType& settings) { … }
DeleteCookiePredicate CookieSettings::CreateDeleteCookieOnExitPredicate()
const { … }
bool CookieSettings::ShouldIgnoreSameSiteRestrictions(
const GURL& url,
const net::SiteForCookies& site_for_cookies) const { … }
bool CookieSettings::IsCookieAccessible(
const net::CanonicalCookie& cookie,
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const std::optional<url::Origin>& top_frame_origin,
const net::FirstPartySetMetadata& first_party_set_metadata,
net::CookieSettingOverrides overrides,
net::CookieInclusionStatus* cookie_inclusion_status) const { … }
bool CookieSettings::ShouldAlwaysAllowCookies(
const GURL& url,
const GURL& first_party_url) const { … }
net::NetworkDelegate::PrivacySetting CookieSettings::IsPrivacyModeEnabled(
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const std::optional<url::Origin>& top_frame_origin,
net::CookieSettingOverrides overrides) const { … }
CookieSettings::CookieSettingWithMetadata
CookieSettings::GetCookieSettingWithMetadata(
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* top_frame_origin,
net::CookieSettingOverrides overrides) const { … }
GURL CookieSettings::FirstPartyURLForMetadata(
const net::SiteForCookies& site_for_cookies,
const url::Origin* top_frame_origin) { … }
bool CookieSettings::AnnotateAndMoveUserBlockedCookies(
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* top_frame_origin,
const net::FirstPartySetMetadata& first_party_set_metadata,
net::CookieSettingOverrides overrides,
net::CookieAccessResultList& maybe_included_cookies,
net::CookieAccessResultList& excluded_cookies) const { … }
bool CookieSettings::HasSessionOnlyOrigins() const { … }
const std::vector<content_settings::HostIndexedContentSettings>&
CookieSettings::GetHostIndexedContentSettings(ContentSettingsType type) 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 { … }
bool CookieSettings::ShouldBlockThirdPartyCookies() const { … }
bool CookieSettings::IsThirdPartyPhaseoutEnabled() const { … }
bool CookieSettings::MitigationsEnabledFor3pcd() const { … }
void CookieSettings::AugmentInclusionStatus(
const net::CanonicalCookie& cookie,
const url::Origin* top_frame_origin,
const CookieSettings::CookieSettingWithMetadata& setting_with_metadata,
const net::FirstPartySetMetadata& first_party_set_metadata,
net::CookieInclusionStatus& out_status) const { … }
}