Bug 1260360 - Purge cookies on clean shutdown according to sanitize preference. r=mconley draft
authorKestrel <kestrel@vmail.me>
Tue, 05 Apr 2016 01:46:00 +0200
changeset 348310 af8eb32cce92e6e52850eff559bbf79aa1dbbbec
parent 348309 cfb3701b5edd3d377439ddda60aa3997b94d0183
child 348311 6f750184f27e432d9b8be42bc7e60bd3698dfed1
push id14805
push userbmo:jacheng@mozilla.com
push dateThu, 07 Apr 2016 07:37:41 +0000
reviewersmconley
bugs1260360
milestone48.0a1
Bug 1260360 - Purge cookies on clean shutdown according to sanitize preference. r=mconley
browser/components/sessionstore/SessionSaver.jsm
--- a/browser/components/sessionstore/SessionSaver.jsm
+++ b/browser/components/sessionstore/SessionSaver.jsm
@@ -206,26 +206,28 @@ var SessionSaverInternal = {
           break;
         }
 
         delete state._closedWindows[i]._shouldRestore;
         state.windows.unshift(state._closedWindows.pop());
       }
     }
 
-    // If this is the final write on a clean shutdown, and the user changed
-    // their cookie preferences to "Keep until I close Firefox", then we
-    // should remove all cookies. Check "resume_session_once" so we keep
-    // cookies when restarting due to a Firefox update.
-    if (RunState.isClosing &&
-        Services.prefs.getIntPref("network.cookie.lifetimePolicy") ==
-          Services.cookies.ACCEPT_SESSION &&
-        !Services.prefs.getBoolPref("browser.sessionstore.resume_session_once")) {
-      for (let window of state.windows) {
-        delete window.cookies;
+    // Clear all cookies on clean shutdown according to user preferences
+    if (RunState.isClosing) {
+      let expireCookies = Services.prefs.getIntPref("network.cookie.lifetimePolicy") ==
+                            Services.cookies.ACCEPT_SESSION;
+      let sanitizeCookies = Services.prefs.getBoolPref("privacy.sanitize.sanitizeOnShutdown") &&
+                            Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies");
+      let restart = Services.prefs.getBoolPref("browser.sessionstore.resume_session_once");
+      // Don't clear cookies when restarting
+      if ((expireCookies || sanitizeCookies) && !restart) {
+        for (let window of state.windows) {
+          delete window.cookies;
+        }
       }
     }
 
     stopWatchFinish("COLLECT_DATA_MS", "COLLECT_DATA_LONGEST_OP_MS");
     return this._writeState(state);
   },
 
   /**