Bug 1695050 - Part 5: Update the call-sites of CookieJarSettings::Create() for Necko. r=dimi,necko-reviewers,valentin

This patch updates the call-sites of CookieJarSettings::Create() in both
LoadInfo.cpp, nsHttpChannel.cpp and CookieCommons.cpp.

Differential Revision: https://phabricator.services.mozilla.com/D109048
This commit is contained in:
Tim Huang 2021-03-29 11:01:52 +00:00
Родитель 45630a2d30
Коммит 66dc23a3e4
3 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -367,7 +367,9 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
// Let's take the current cookie behavior and current cookie permission
// for the documents' loadInfo. Note that for any other loadInfos,
// cookieBehavior will be BEHAVIOR_REJECT for security reasons.
mCookieJarSettings = CookieJarSettings::Create();
bool isPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
mCookieJarSettings = CookieJarSettings::Create(
isPrivate ? CookieJarSettings::ePrivate : CookieJarSettings::eRegular);
}
LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
@ -406,7 +408,9 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
// Let's take the current cookie behavior and current cookie permission
// for the documents' loadInfo. Note that for any other loadInfos,
// cookieBehavior will be BEHAVIOR_REJECT for security reasons.
mCookieJarSettings = CookieJarSettings::Create();
bool isPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
mCookieJarSettings = CookieJarSettings::Create(
isPrivate ? CookieJarSettings::ePrivate : CookieJarSettings::eRegular);
}
LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,
@ -973,9 +977,10 @@ LoadInfo::GetCookiePolicy(uint32_t* aResult) {
namespace {
already_AddRefed<nsICookieJarSettings> CreateCookieJarSettings(
nsContentPolicyType aContentPolicyType) {
nsContentPolicyType aContentPolicyType, bool aIsPrivate) {
if (StaticPrefs::network_cookieJarSettings_unblocked_for_testing()) {
return CookieJarSettings::Create();
return aIsPrivate ? CookieJarSettings::Create(CookieJarSettings::ePrivate)
: CookieJarSettings::Create(CookieJarSettings::eRegular);
}
// These contentPolictTypes require a real CookieJarSettings because favicon
@ -983,7 +988,8 @@ already_AddRefed<nsICookieJarSettings> CreateCookieJarSettings(
// send/receive cookies.
if (aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON ||
aContentPolicyType == nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD) {
return CookieJarSettings::Create();
return aIsPrivate ? CookieJarSettings::Create(CookieJarSettings::ePrivate)
: CookieJarSettings::Create(CookieJarSettings::eRegular);
}
return CookieJarSettings::GetBlockingAll();
@ -994,7 +1000,9 @@ already_AddRefed<nsICookieJarSettings> CreateCookieJarSettings(
NS_IMETHODIMP
LoadInfo::GetCookieJarSettings(nsICookieJarSettings** aCookieJarSettings) {
if (!mCookieJarSettings) {
mCookieJarSettings = CreateCookieJarSettings(mInternalContentPolicyType);
bool isPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
mCookieJarSettings =
CreateCookieJarSettings(mInternalContentPolicyType, isPrivate);
}
nsCOMPtr<nsICookieJarSettings> cookieJarSettings = mCookieJarSettings;

Просмотреть файл

@ -457,7 +457,7 @@ already_AddRefed<nsICookieJarSettings> CookieCommons::GetCookieJarSettings(
cookieJarSettings = CookieJarSettings::GetBlockingAll();
}
} else {
cookieJarSettings = CookieJarSettings::Create();
cookieJarSettings = CookieJarSettings::Create(CookieJarSettings::eRegular);
}
MOZ_ASSERT(cookieJarSettings);

Просмотреть файл

@ -10057,7 +10057,7 @@ void nsHttpChannel::ReEvaluateReferrerAfterTrackingStatusIsKnown() {
Unused << mLoadInfo->GetCookieJarSettings(getter_AddRefs(cjs));
}
if (!cjs) {
cjs = net::CookieJarSettings::Create();
cjs = net::CookieJarSettings::Create(mLoadInfo->GetLoadingPrincipal());
}
if (cjs->GetRejectThirdPartyContexts()) {
bool isPrivate = mLoadInfo->GetOriginAttributes().mPrivateBrowsingId > 0;