diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /netwerk/cookie/CookieJarSettings.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/cookie/CookieJarSettings.cpp')
-rw-r--r-- | netwerk/cookie/CookieJarSettings.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/netwerk/cookie/CookieJarSettings.cpp b/netwerk/cookie/CookieJarSettings.cpp index 09a4789d85..9e598c296f 100644 --- a/netwerk/cookie/CookieJarSettings.cpp +++ b/netwerk/cookie/CookieJarSettings.cpp @@ -4,9 +4,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozIThirdPartyUtil.h" #include "mozilla/AntiTrackingUtils.h" #include "mozilla/BasePrincipal.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/Components.h" #include "mozilla/ContentBlockingAllowList.h" #include "mozilla/dom/BrowsingContext.h" #include "mozilla/net/CookieJarSettings.h" @@ -15,6 +17,7 @@ #include "mozilla/PermissionManager.h" #include "mozilla/SchedulerGroup.h" #include "mozilla/StaticPrefs_network.h" +#include "mozilla/StoragePrincipalHelper.h" #include "mozilla/Unused.h" #include "nsIPrincipal.h" #if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE) @@ -172,7 +175,8 @@ CookieJarSettings::CookieJarSettings(uint32_t aCookieBehavior, mIsOnContentBlockingAllowListUpdated(false), mState(aState), mToBeMerged(false), - mShouldResistFingerprinting(aShouldResistFingerprinting) { + mShouldResistFingerprinting(aShouldResistFingerprinting), + mTopLevelWindowContextId(0) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT_IF( mIsFirstPartyIsolated, @@ -195,7 +199,7 @@ CookieJarSettings::InitWithURI(nsIURI* aURI, bool aIsPrivate) { mCookieBehavior = nsICookieManager::GetCookieBehavior(aIsPrivate); - SetPartitionKey(aURI); + SetPartitionKey(aURI, false); return NS_OK; } @@ -408,6 +412,8 @@ void CookieJarSettings::Serialize(CookieJarSettingsArgs& aData) { CookiePermissionData(principalInfo, cookiePermission)); } + aData.topLevelWindowContextId() = mTopLevelWindowContextId; + mToBeMerged = false; } @@ -451,6 +457,8 @@ void CookieJarSettings::Serialize(CookieJarSettingsArgs& aData) { aData.fingerprintingRandomizationKey().Clone()); } + cookieJarSettings->mTopLevelWindowContextId = aData.topLevelWindowContextId(); + cookieJarSettings.forget(aCookieJarSettings); } @@ -521,14 +529,25 @@ void CookieJarSettings::Merge(const CookieJarSettingsArgs& aData) { } } -void CookieJarSettings::SetPartitionKey(nsIURI* aURI) { +void CookieJarSettings::SetPartitionKey(nsIURI* aURI, + bool aForeignByAncestorContext) { MOZ_ASSERT(aURI); OriginAttributes attrs; - attrs.SetPartitionKey(aURI); + attrs.SetPartitionKey(aURI, aForeignByAncestorContext); mPartitionKey = std::move(attrs.mPartitionKey); } +void CookieJarSettings::UpdatePartitionKeyForDocumentLoadedByChannel( + nsIChannel* aChannel) { + nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo(); + bool thirdParty = AntiTrackingUtils::IsThirdPartyChannel(aChannel); + bool foreignByAncestorContext = + thirdParty && !loadInfo->GetIsThirdPartyContextToTopWindow(); + StoragePrincipalHelper::UpdatePartitionKeyWithForeignAncestorBit( + mPartitionKey, foreignByAncestorContext); +} + void CookieJarSettings::UpdateIsOnContentBlockingAllowList( nsIChannel* aChannel) { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); |