Bug 1260360 - Purge cookies on clean shutdown according to sanitize preference. r=mconley
authorKestrel <kestrel@vmail.me>
Tue, 05 Apr 2016 01:46:00 +0200
changeset 291641 4209cc859abcb5986b7b0e1406e9a00b5fff17a7
parent 291640 e003ad2de364adc21bd7ed89715bc6f397ba9739
child 291642 75bef7c5fd91e42e5cfa5337f02f48942b568996
push id18551
push usercbook@mozilla.com
push dateWed, 06 Apr 2016 03:56:47 +0000
treeherderfx-team@75bef7c5fd91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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);
   },
 
   /**