#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/cookies/canonical_cookie.h"
#include <limits>
#include <optional>
#include <string_view>
#include <tuple>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/base/features.h"
#include "net/base/url_util.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/cookies/cookie_options.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h"
#include "net/http/http_util.h"
#include "url/gurl.h"
#include "url/url_canon.h"
#include "url/url_util.h"
Time;
namespace net {
namespace {
static constexpr int kMinutesInTwelveHours = …;
static constexpr int kMinutesInTwentyFourHours = …;
bool GetCookieDomain(const GURL& url,
const ParsedCookie& pc,
CookieInclusionStatus& status,
std::string* result) { … }
int PartialCookieOrdering(const CanonicalCookie& a, const CanonicalCookie& b) { … }
void AppendCookieLineEntry(const CanonicalCookie& cookie,
std::string* cookie_line) { … }
CookieSameSiteForMetrics CookieSameSiteToCookieSameSiteForMetrics(
CookieSameSite enum_in) { … }
auto GetAllDataMembersAsTuple(const CanonicalCookie& c) { … }
}
CookieAccessParams::CookieAccessParams(CookieAccessSemantics access_semantics,
bool delegate_treats_url_as_trustworthy)
: … { … }
CanonicalCookie::CanonicalCookie() = default;
CanonicalCookie::CanonicalCookie(const CanonicalCookie& other) = default;
CanonicalCookie::CanonicalCookie(CanonicalCookie&& other) = default;
CanonicalCookie& CanonicalCookie::operator=(const CanonicalCookie& other) =
default;
CanonicalCookie& CanonicalCookie::operator=(CanonicalCookie&& other) = default;
CanonicalCookie::CanonicalCookie(
base::PassKey<CanonicalCookie> pass_key,
std::string name,
std::string value,
std::string domain,
std::string path,
base::Time creation,
base::Time expiration,
base::Time last_access,
base::Time last_update,
bool secure,
bool httponly,
CookieSameSite same_site,
CookiePriority priority,
std::optional<CookiePartitionKey> partition_key,
CookieSourceScheme source_scheme,
int source_port,
CookieSourceType source_type)
: … { … }
CanonicalCookie::~CanonicalCookie() = default;
Time CanonicalCookie::ParseExpiration(const ParsedCookie& pc,
const Time& current,
const Time& server_time) { … }
base::Time CanonicalCookie::ValidateAndAdjustExpiryDate(
const base::Time& expiry_date,
const base::Time& creation_date,
net::CookieSourceScheme scheme) { … }
std::unique_ptr<CanonicalCookie> CanonicalCookie::Create(
const GURL& url,
const std::string& cookie_line,
const base::Time& creation_time,
std::optional<base::Time> server_time,
std::optional<CookiePartitionKey> cookie_partition_key,
CookieSourceType source_type,
CookieInclusionStatus* status) { … }
std::unique_ptr<CanonicalCookie> CanonicalCookie::CreateSanitizedCookie(
const GURL& url,
const std::string& name,
const std::string& value,
const std::string& domain,
const std::string& path,
base::Time creation_time,
base::Time expiration_time,
base::Time last_access_time,
bool secure,
bool http_only,
CookieSameSite same_site,
CookiePriority priority,
std::optional<CookiePartitionKey> partition_key,
CookieInclusionStatus* status) { … }
std::unique_ptr<CanonicalCookie> CanonicalCookie::FromStorage(
std::string name,
std::string value,
std::string domain,
std::string path,
base::Time creation,
base::Time expiration,
base::Time last_access,
base::Time last_update,
bool secure,
bool httponly,
CookieSameSite same_site,
CookiePriority priority,
std::optional<CookiePartitionKey> partition_key,
CookieSourceScheme source_scheme,
int source_port,
CookieSourceType source_type) { … }
std::unique_ptr<CanonicalCookie> CanonicalCookie::CreateUnsafeCookieForTesting(
const std::string& name,
const std::string& value,
const std::string& domain,
const std::string& path,
const base::Time& creation,
const base::Time& expiration,
const base::Time& last_access,
const base::Time& last_update,
bool secure,
bool httponly,
CookieSameSite same_site,
CookiePriority priority,
std::optional<CookiePartitionKey> partition_key,
CookieSourceScheme source_scheme,
int source_port,
CookieSourceType source_type) { … }
std::unique_ptr<CanonicalCookie> CanonicalCookie::CreateForTesting(
const GURL& url,
const std::string& cookie_line,
const base::Time& creation_time,
std::optional<base::Time> server_time,
std::optional<CookiePartitionKey> cookie_partition_key,
CookieSourceType source_type,
CookieInclusionStatus* status) { … }
bool CanonicalCookie::IsEquivalentForSecureCookieMatching(
const CanonicalCookie& secure_cookie) const { … }
bool CanonicalCookie::HasEquivalentDataMembers(
const CanonicalCookie& other) const { … }
void CanonicalCookie::PostIncludeForRequestURL(
const CookieAccessResult& access_result,
const CookieOptions& options_used,
CookieOptions::SameSiteCookieContext::ContextType
cookie_inclusion_context_used) const { … }
void CanonicalCookie::PostIsSetPermittedInContext(
const CookieAccessResult& access_result,
const CookieOptions& options_used) const { … }
base::TimeDelta CanonicalCookie::GetLaxAllowUnsafeThresholdAge() const { … }
std::string CanonicalCookie::DebugString() const { … }
bool CanonicalCookie::PartialCompare(const CanonicalCookie& other) const { … }
bool CanonicalCookie::IsCanonical() const { … }
bool CanonicalCookie::IsCanonicalForFromStorage() const { … }
bool CanonicalCookie::IsEffectivelySameSiteNone(
CookieAccessSemantics access_semantics) const { … }
CookieEffectiveSameSite CanonicalCookie::GetEffectiveSameSiteForTesting(
CookieAccessSemantics access_semantics) const { … }
std::string CanonicalCookie::BuildCookieLine(const CookieList& cookies) { … }
std::string CanonicalCookie::BuildCookieLine(
const CookieAccessResultList& cookie_access_result_list) { … }
std::string CanonicalCookie::BuildCookieAttributesLine(
const CanonicalCookie& cookie) { … }
void CanonicalCookie::RecordCookiePrefixMetrics(CookiePrefix prefix) { … }
int CanonicalCookie::GetAndAdjustPortForTrustworthyUrls(
const GURL& source_url,
bool url_is_trustworthy) { … }
bool CanonicalCookie::HasHiddenPrefixName(const std::string_view cookie_value) { … }
CookieAndLineWithAccessResult::CookieAndLineWithAccessResult() = default;
CookieAndLineWithAccessResult::CookieAndLineWithAccessResult(
std::optional<CanonicalCookie> cookie,
std::string cookie_string,
CookieAccessResult access_result)
: … { … }
CookieAndLineWithAccessResult::CookieAndLineWithAccessResult(
const CookieAndLineWithAccessResult&) = default;
CookieAndLineWithAccessResult& CookieAndLineWithAccessResult::operator=(
const CookieAndLineWithAccessResult& cookie_and_line_with_access_result) =
default;
CookieAndLineWithAccessResult::CookieAndLineWithAccessResult(
CookieAndLineWithAccessResult&&) = default;
CookieAndLineWithAccessResult::~CookieAndLineWithAccessResult() = default;
}