Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 31a8a70

Browse files
author
Ehsan Akhgari
committed
Bug 1547114 - Part 6: Convert network.cookie.lifetimePolicy into a static pref; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D28997 --HG-- extra : moz-landing-system : lando
1 parent c8fea1e commit 31a8a70

5 files changed

Lines changed: 16 additions & 23 deletions

File tree

dom/base/nsContentUtils.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@ nsContentUtils::UserInteractionObserver*
344344

345345
uint32_t nsContentUtils::sHandlingInputTimeout = 1000;
346346

347-
uint32_t nsContentUtils::sCookiesLifetimePolicy =
348-
nsICookieService::ACCEPT_NORMALLY;
349-
350347
nsHtml5StringParser* nsContentUtils::sHTMLFragmentParser = nullptr;
351348
nsIParser* nsContentUtils::sXMLFragmentParser = nullptr;
352349
nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nullptr;
@@ -679,10 +676,6 @@ nsresult nsContentUtils::Init() {
679676
&sSendPerformanceTimingNotifications,
680677
"dom.performance.enable_notify_performance_timing", false);
681678

682-
Preferences::AddUintVarCache(&sCookiesLifetimePolicy,
683-
"network.cookie.lifetimePolicy",
684-
nsICookieService::ACCEPT_NORMALLY);
685-
686679
Preferences::AddBoolVarCache(&sDoNotTrackEnabled,
687680
"privacy.donottrackheader.enabled", false);
688681

@@ -8284,7 +8277,7 @@ nsContentUtils::StorageAccess nsContentUtils::StorageAllowedForServiceWorker(
82848277
void nsContentUtils::GetCookieLifetimePolicyFromCookieSettings(
82858278
nsICookieSettings* aCookieSettings, nsIPrincipal* aPrincipal,
82868279
uint32_t* aLifetimePolicy) {
8287-
*aLifetimePolicy = sCookiesLifetimePolicy;
8280+
*aLifetimePolicy = StaticPrefs::network_cookie_lifetimePolicy();
82888281

82898282
if (aCookieSettings) {
82908283
uint32_t cookiePermission = 0;

dom/base/nsContentUtils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,11 +3360,6 @@ class nsContentUtils {
33603360
static bool HighPriorityEventPendingForTopLevelDocumentBeforeContentfulPaint(
33613361
Document* aDocument);
33623362

3363-
/**
3364-
* Gets the global cookie lifetime policy.
3365-
*/
3366-
static uint32_t GetCookieLifetimePolicy() { return sCookiesLifetimePolicy; }
3367-
33683363
private:
33693364
static bool InitializeEventTable();
33703365

@@ -3513,7 +3508,6 @@ class nsContentUtils {
35133508
#endif
35143509
static bool sIsBytecodeCacheEnabled;
35153510
static int32_t sBytecodeCacheStrategy;
3516-
static uint32_t sCookiesLifetimePolicy;
35173511
static bool sAntiTrackingControlCenterUIEnabled;
35183512

35193513
static int32_t sPrivacyMaxInnerWidth;

extensions/cookie/nsCookiePermission.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
************************ nsCookiePermission ********************
3232
****************************************************************/
3333

34+
using namespace mozilla;
35+
3436
static const bool kDefaultPolicy = true;
3537

3638
static const nsLiteralCString kPermissionType(NS_LITERAL_CSTRING("cookie"));
@@ -108,7 +110,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI, nsIChannel *aChannel,
108110

109111
// now we need to figure out what type of accept policy we're dealing with
110112
// if we accept cookies normally, just bail and return
111-
if (nsContentUtils::GetCookieLifetimePolicy() ==
113+
if (StaticPrefs::network_cookie_lifetimePolicy() ==
112114
nsICookieService::ACCEPT_NORMALLY) {
113115
*aResult = true;
114116
return NS_OK;
@@ -121,7 +123,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI, nsIChannel *aChannel,
121123
// We are accepting the cookie, but,
122124
// if it's not a session cookie, we may have to limit its lifetime.
123125
if (!*aIsSession && delta > 0) {
124-
if (nsContentUtils::GetCookieLifetimePolicy() ==
126+
if (StaticPrefs::network_cookie_lifetimePolicy() ==
125127
nsICookieService::ACCEPT_SESSION) {
126128
// limit lifetime to session
127129
*aIsSession = true;

modules/libpref/init/StaticPrefList.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,17 @@ VARCACHE_PREF(
19641964
RelaxedAtomicInt32, 0
19651965
)
19661966

1967+
// Cookie lifetime policy. Possible values:
1968+
// 0 - accept all cookies
1969+
// 1 - deprecated. don't use it.
1970+
// 2 - accept as session cookies
1971+
// 3 - deprecated. don't use it.
1972+
VARCACHE_PREF(
1973+
"network.cookie.lifetimePolicy",
1974+
network_cookie_lifetimePolicy,
1975+
RelaxedAtomicInt32, 0
1976+
)
1977+
19671978
// Enables the predictive service.
19681979
VARCACHE_PREF(
19691980
"network.predictor.enabled",

modules/libpref/init/all.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,13 +2409,6 @@ pref("network.cookie.thirdparty.sessionOnly", false);
24092409
pref("network.cookie.thirdparty.nonsecureSessionOnly", false);
24102410
pref("network.cookie.same-site.enabled", true); // Honor the SameSite cookie attribute
24112411

2412-
// Cookie lifetime policy. Possible values:
2413-
// 0 - accept all cookies
2414-
// 1 - deprecated. don't use it.
2415-
// 2 - accept as session cookies
2416-
// 3 - deprecated. don't use it.
2417-
pref("network.cookie.lifetimePolicy", 0);
2418-
24192412
// The interval in seconds to move the cookies in the child process.
24202413
// Set to 0 to disable moving the cookies.
24212414
pref("network.cookie.move.interval_sec", 10);

0 commit comments

Comments
 (0)