diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 4ab8d338e7be..4b0f020715e4 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -5725,6 +5725,13 @@ VARCACHE_PREF( bool, false ) +VARCACHE_PREF( + Live, + "network.cookie.thirdparty.nonsecureSessionOnly", + network_cookie_thirdparty_nonsecureSessionOnly, + bool, false +) + // Enables the predictive service. VARCACHE_PREF( Live, diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index be12453f9e38..614c9739ed80 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2327,7 +2327,6 @@ pref("network.proxy.no_proxies_on", ""); pref("network.proxy.allow_hijacking_localhost", false); pref("network.proxy.failover_timeout", 1800); // 30 minutes pref("network.online", true); //online/offline -pref("network.cookie.thirdparty.nonsecureSessionOnly", false); // The interval in seconds to move the cookies in the child process. // Set to 0 to disable moving the cookies. diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index fa067d435368..1aca1b2fe9a9 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -37,8 +37,6 @@ namespace mozilla { namespace net { // Pref string constants -static const char kPrefThirdPartyNonsecureSession[] = - "network.cookie.thirdparty.nonsecureSessionOnly"; static const char kCookieMoveIntervalSecs[] = "network.cookie.move.interval_sec"; @@ -57,8 +55,7 @@ already_AddRefed CookieServiceChild::GetSingleton() { NS_IMPL_ISUPPORTS(CookieServiceChild, nsICookieService, nsIObserver, nsITimerCallback, nsISupportsWeakReference) -CookieServiceChild::CookieServiceChild() - : mThirdPartyNonsecureSession(false), mIPCOpen(false) { +CookieServiceChild::CookieServiceChild() : mIPCOpen(false) { NS_ASSERTION(IsNeckoChild(), "not a child process"); mozilla::dom::ContentChild* cc = @@ -87,7 +84,6 @@ CookieServiceChild::CookieServiceChild() nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); NS_WARNING_ASSERTION(prefBranch, "no prefservice"); if (prefBranch) { - prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true); prefBranch->AddObserver(kCookieMoveIntervalSecs, this, true); PrefChanged(prefBranch); } @@ -250,11 +246,6 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvTrackCookiesLoad( } void CookieServiceChild::PrefChanged(nsIPrefBranch* aPrefBranch) { - bool boolval; - if (NS_SUCCEEDED( - aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession, &boolval))) - mThirdPartyNonsecureSession = boolval; - int32_t val; if (NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookieMoveIntervalSecs, &val))) { gMoveCookiesIntervalSeconds = clamped(val, 0, 3600); @@ -314,8 +305,8 @@ void CookieServiceChild::GetCookieStringFromCookieHashTable( nsCookieService::GetCookieSettings(aChannel); CookieStatus cookieStatus = nsCookieService::CheckPrefs( - cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign, - aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr, + cookieSettings, aHostURI, aIsForeign, aIsTrackingResource, + aFirstPartyStorageAccessGranted, nullptr, CountCookiesFromHashTable(baseDomain, attrs), attrs, &aRejectedReason); if (cookieStatus != STATUS_ACCEPTED && @@ -419,7 +410,7 @@ bool CookieServiceChild::RequireThirdPartyCheck(nsILoadInfo* aLoadInfo) { cookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN || StaticPrefs::network_cookie_thirdparty_sessionOnly() || - mThirdPartyNonsecureSession; + StaticPrefs::network_cookie_thirdparty_nonsecureSessionOnly(); } void CookieServiceChild::RecordDocumentCookie(nsCookie* aCookie, @@ -588,8 +579,8 @@ nsresult CookieServiceChild::SetCookieStringInternal(nsIURI* aHostURI, nsCookieService::GetCookieSettings(aChannel); CookieStatus cookieStatus = nsCookieService::CheckPrefs( - cookieSettings, mThirdPartyNonsecureSession, aHostURI, isForeign, - isTrackingResource, firstPartyStorageAccessGranted, aCookieString, + cookieSettings, aHostURI, isForeign, isTrackingResource, + firstPartyStorageAccessGranted, aCookieString, CountCookiesFromHashTable(baseDomain, attrs), attrs, &rejectedReason); if (cookieStatus != STATUS_ACCEPTED && diff --git a/netwerk/cookie/CookieServiceChild.h b/netwerk/cookie/CookieServiceChild.h index 93ede06e1774..9106dcc500ed 100644 --- a/netwerk/cookie/CookieServiceChild.h +++ b/netwerk/cookie/CookieServiceChild.h @@ -104,7 +104,6 @@ class CookieServiceChild : public PCookieServiceChild, nsCOMPtr mCookieTimer; nsCOMPtr mThirdPartyUtil; nsCOMPtr mTLDService; - bool mThirdPartyNonsecureSession; bool mIPCOpen; }; diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 472cd2dc16e7..398270f76d98 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -130,8 +130,6 @@ static const char kPrefMaxNumberOfCookies[] = "network.cookie.maxNumber"; static const char kPrefMaxCookiesPerHost[] = "network.cookie.maxPerHost"; static const char kPrefCookieQuotaPerHost[] = "network.cookie.quotaPerHost"; static const char kPrefCookiePurgeAge[] = "network.cookie.purgeAge"; -static const char kPrefThirdPartyNonsecureSession[] = - "network.cookie.thirdparty.nonsecureSessionOnly"; static void bindCookieParameters(mozIStorageBindingParamsArray* aParamsArray, const nsCookieKey& aKey, @@ -584,7 +582,6 @@ NS_IMPL_ISUPPORTS(nsCookieService, nsICookieService, nsICookieManager, nsCookieService::nsCookieService() : mDBState(nullptr), - mThirdPartyNonsecureSession(false), mMaxNumberOfCookies(kMaxNumberOfCookies), mMaxCookiesPerHost(kMaxCookiesPerHost), mCookieQuotaPerHost(kCookieQuotaPerHost), @@ -611,7 +608,6 @@ nsresult nsCookieService::Init() { prefBranch->AddObserver(kPrefMaxNumberOfCookies, this, true); prefBranch->AddObserver(kPrefMaxCookiesPerHost, this, true); prefBranch->AddObserver(kPrefCookiePurgeAge, this, true); - prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true); PrefChanged(prefBranch); } @@ -2172,10 +2168,10 @@ void nsCookieService::SetCookieStringInternal( nsAutoCString hostFromURI; aHostURI->GetHost(hostFromURI); CountCookiesFromHost(hostFromURI, &priorCookieCount); - CookieStatus cookieStatus = CheckPrefs( - cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign, - aIsTrackingResource, aFirstPartyStorageAccessGranted, aCookieHeader.get(), - priorCookieCount, aOriginAttrs, &rejectedReason); + CookieStatus cookieStatus = + CheckPrefs(cookieSettings, aHostURI, aIsForeign, aIsTrackingResource, + aFirstPartyStorageAccessGranted, aCookieHeader.get(), + priorCookieCount, aOriginAttrs, &rejectedReason); MOZ_ASSERT_IF(rejectedReason, cookieStatus == STATUS_REJECTED); @@ -2344,11 +2340,6 @@ void nsCookieService::PrefChanged(nsIPrefBranch* aPrefBranch) { mCookiePurgeAge = int64_t(LIMIT(val, 0, INT32_MAX, INT32_MAX)) * PR_USEC_PER_SEC; } - - bool boolval; - if (NS_SUCCEEDED( - aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession, &boolval))) - mThirdPartyNonsecureSession = boolval; } /****************************************************************************** @@ -2996,10 +2987,10 @@ void nsCookieService::GetCookiesForURI( uint32_t rejectedReason = aRejectedReason; uint32_t priorCookieCount = 0; CountCookiesFromHost(hostFromURI, &priorCookieCount); - CookieStatus cookieStatus = CheckPrefs( - cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign, - aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr, - priorCookieCount, aOriginAttrs, &rejectedReason); + CookieStatus cookieStatus = + CheckPrefs(cookieSettings, aHostURI, aIsForeign, aIsTrackingResource, + aFirstPartyStorageAccessGranted, nullptr, priorCookieCount, + aOriginAttrs, &rejectedReason); MOZ_ASSERT_IF(rejectedReason, cookieStatus == STATUS_REJECTED); @@ -3931,11 +3922,10 @@ static inline bool IsSubdomainOf(const nsCString& a, const nsCString& b) { } CookieStatus nsCookieService::CheckPrefs( - nsICookieSettings* aCookieSettings, bool aThirdPartyNonsecureSession, - nsIURI* aHostURI, bool aIsForeign, bool aIsTrackingResource, - bool aFirstPartyStorageAccessGranted, const char* aCookieHeader, - const int aNumOfCookies, const OriginAttributes& aOriginAttrs, - uint32_t* aRejectedReason) { + nsICookieSettings* aCookieSettings, nsIURI* aHostURI, bool aIsForeign, + bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted, + const char* aCookieHeader, const int aNumOfCookies, + const OriginAttributes& aOriginAttrs, uint32_t* aRejectedReason) { nsresult rv; MOZ_ASSERT(aRejectedReason); @@ -4034,7 +4024,7 @@ CookieStatus nsCookieService::CheckPrefs( return STATUS_ACCEPT_SESSION; } - if (aThirdPartyNonsecureSession) { + if (StaticPrefs::network_cookie_thirdparty_nonsecureSessionOnly()) { bool isHTTPS = false; aHostURI->SchemeIs("https", &isHTTPS); if (!isHTTPS) return STATUS_ACCEPT_SESSION; diff --git a/netwerk/cookie/nsCookieService.h b/netwerk/cookie/nsCookieService.h index 8bea9b421793..8789cd9fb96e 100644 --- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -213,11 +213,10 @@ class nsCookieService final : public nsICookieService, nsIChannel* aChannel, bool& aSetCookie, mozIThirdPartyUtil* aThirdPartyUtil); static CookieStatus CheckPrefs( - nsICookieSettings* aCookieSettings, bool aThirdPartyNonsecureSession, - nsIURI* aHostURI, bool aIsForeign, bool aIsTrackingResource, - bool aIsFirstPartyStorageAccessGranted, const char* aCookieHeader, - const int aNumOfCookies, const OriginAttributes& aOriginAttrs, - uint32_t* aRejectedReason); + nsICookieSettings* aCookieSettings, nsIURI* aHostURI, bool aIsForeign, + bool aIsTrackingResource, bool aIsFirstPartyStorageAccessGranted, + const char* aCookieHeader, const int aNumOfCookies, + const OriginAttributes& aOriginAttrs, uint32_t* aRejectedReason); static int64_t ParseServerTime(const nsCString& aServerTime); static already_AddRefed GetCookieSettings( @@ -368,7 +367,6 @@ class nsCookieService final : public nsICookieService, RefPtr mDefaultDBState; RefPtr mPrivateDBState; - bool mThirdPartyNonsecureSession; uint16_t mMaxNumberOfCookies; uint16_t mMaxCookiesPerHost; uint16_t mCookieQuotaPerHost;