Bug 469158 - Remove the 'privacy.sanitize.promptOnSanitize' preference; r=gavin ui-r=beltzner
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 02 Jan 2009 03:30:49 +0330
changeset 23243 45f0ebf6eecc1744bc84cffc69d4ea30835994ac
parent 23242 9c13f028da54d5280d65af5b1ec4b60fd21e2675
child 23244 40f7e81126a2b03f29457c71f857be8adb0676cd
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, beltzner
bugs469158
milestone1.9.2a1pre
Bug 469158 - Remove the 'privacy.sanitize.promptOnSanitize' preference; r=gavin ui-r=beltzner
browser/app/profile/firefox.js
browser/base/content/browser.js
browser/base/content/sanitize.js
browser/components/nsIBrowserGlue.idl
browser/components/preferences/privacy.js
browser/components/preferences/privacy.xul
browser/locales/en-US/chrome/browser/preferences/privacy.dtd
browser/modules/Sanitizer.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -412,17 +412,16 @@ pref("privacy.item.offlineApps", false);
 // What default should we use for the time span in the sanitizer:
 // 0 - Clear everything
 // 1 - Last Hour
 // 2 - Last 2 Hours
 // 3 - Last 4 Hours
 // 4 - Today
 pref("privacy.sanitize.timeSpan", 0);
 pref("privacy.sanitize.sanitizeOnShutdown", false);
-pref("privacy.sanitize.promptOnSanitize", true);
 
 pref("network.proxy.share_proxy_settings",  false); // use the same proxy settings for all protocols
 
 pref("network.cookie.cookieBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
 
 // l12n and i18n
 pref("intl.accept_languages", "chrome://global/locale/intl.properties");
 pref("intl.charsetmenu.browser.static", "chrome://global/locale/intl.properties");
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -82,18 +82,16 @@ var gSidebarCommand = "";
 var gInPrintPreviewMode = false;
 let gDownloadMgr = null;
 
 // Global variable that holds the nsContextMenu instance.
 var gContextMenu = null;
 
 var gChromeState = null; // chrome state before we went into print preview
 
-var gSanitizeListener = null;
-
 var gAutoHideTabbarPrefListener = null;
 var gBookmarkAllTabsHandler = null;
 
 #ifdef XP_MACOSX
 var gClickAndHoldTimer = null;
 #endif
 
 #ifndef XP_MACOSX
@@ -1195,17 +1193,17 @@ function delayedStartup(isLoadingBlank, 
 
   if (gURLBar)
     gURLBar.setAttribute("emptytext", gURLBar.getAttribute("delayedemptytext"));
 
   gNavToolbox.customizeDone = BrowserToolboxCustomizeDone;
   gNavToolbox.customizeChange = BrowserToolboxCustomizeChange;
 
   // Set up Sanitize Item
-  gSanitizeListener = new SanitizeListener();
+  initializeSanitizer();
 
   // Enable/Disable auto-hide tabbar
   gAutoHideTabbarPrefListener = new AutoHideTabbarPrefListener();
   gPrefService.addObserver(gAutoHideTabbarPrefListener.domain,
                            gAutoHideTabbarPrefListener, false);
 
   gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton, false);
 
@@ -1395,19 +1393,16 @@ function BrowserShutdown()
   try {
     gPrefService.removeObserver(gAutoHideTabbarPrefListener.domain,
                                 gAutoHideTabbarPrefListener);
     gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton);
   } catch (ex) {
     Components.utils.reportError(ex);
   }
 
-  if (gSanitizeListener)
-    gSanitizeListener.shutdown();
-
   BrowserOffline.uninit();
   OfflineApps.uninit();
   DownloadMonitorPanel.uninit();
   gPrivateBrowsingUI.uninit();
 
   var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
   var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
   var enumerator = windowManagerInterface.getEnumerator(null);
@@ -1477,24 +1472,21 @@ function nonBrowserWindowStartup()
 }
 
 function nonBrowserWindowDelayedStartup()
 {
   // initialise the offline listener
   BrowserOffline.init();
   
   // Set up Sanitize Item
-  gSanitizeListener = new SanitizeListener();
+  initializeSanitizer();
 }
 
 function nonBrowserWindowShutdown()
 {
-  if (gSanitizeListener)
-    gSanitizeListener.shutdown();
-
   BrowserOffline.uninit();
 }
 #endif
 
 function AutoHideTabbarPrefListener()
 {
   this.toggleAutoHideTabbar();
 }
@@ -1520,56 +1512,31 @@ AutoHideTabbarPrefListener.prototype =
       }
       catch (e) {
       }
       gBrowser.setStripVisibilityTo(aVisible);
     }
   }
 }
 
-function SanitizeListener()
+function initializeSanitizer()
 {
-  gPrefService.addObserver(this.promptDomain, this, false);
-
-  this._defaultLabel = document.getElementById("sanitizeItem")
-                               .getAttribute("label");
-  this._updateSanitizeItem();
-
-  if (gPrefService.prefHasUserValue(this.didSanitizeDomain)) {
-    gPrefService.clearUserPref(this.didSanitizeDomain);
+  // Always use the label with ellipsis
+  var label = gNavigatorBundle.getString("sanitizeWithPromptLabel2");
+  document.getElementById("sanitizeItem").setAttribute("label", label);
+
+  const kDidSanitizeDomain = "privacy.sanitize.didShutdownSanitize";
+  if (gPrefService.prefHasUserValue(kDidSanitizeDomain)) {
+    gPrefService.clearUserPref(kDidSanitizeDomain);
     // We need to persist this preference change, since we want to
     // check it at next app start even if the browser exits abruptly
     gPrefService.QueryInterface(Ci.nsIPrefService).savePrefFile(null);
   }
 }
 
-SanitizeListener.prototype =
-{
-  promptDomain      : "privacy.sanitize.promptOnSanitize",
-  didSanitizeDomain : "privacy.sanitize.didShutdownSanitize",
-
-  observe: function (aSubject, aTopic, aPrefName)
-  {
-    this._updateSanitizeItem();
-  },
-
-  shutdown: function ()
-  {
-    gPrefService.removeObserver(this.promptDomain, this);
-  },
-
-  _updateSanitizeItem: function ()
-  {
-    var label = gPrefService.getBoolPref(this.promptDomain) ?
-        gNavigatorBundle.getString("sanitizeWithPromptLabel2") : 
-        this._defaultLabel;
-    document.getElementById("sanitizeItem").setAttribute("label", label);
-  }
-}
-
 function gotoHistoryIndex(aEvent)
 {
   var index = aEvent.target.getAttribute("index");
   if (!index)
     return false;
 
   var where = whereToOpenLink(aEvent);
 
--- a/browser/base/content/sanitize.js
+++ b/browser/base/content/sanitize.js
@@ -18,16 +18,17 @@
 # Ben Goodger.
 # Portions created by the Initial Developer are Copyright (C) 2005
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ben Goodger <ben@mozilla.org>
 #   Giorgio Maone <g.maone@informaction.com>
 #   Johnathan Nightingale <johnath@mozilla.com>
+#   Ehsan Akhgari <ehsan.akhgari@gmail.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -339,17 +340,16 @@ Sanitizer.prototype = {
     }
   }
 };
 
 
 
 // "Static" members
 Sanitizer.prefDomain          = "privacy.sanitize.";
-Sanitizer.prefPrompt          = "promptOnSanitize";
 Sanitizer.prefShutdown        = "sanitizeOnShutdown";
 Sanitizer.prefDidShutdown     = "didShutdownSanitize";
 
 // Time span constants corresponding to values of the privacy.sanitize.timeSpan
 // pref.  Used to determine how much history to clear, for various items
 Sanitizer.TIMESPAN_EVERYTHING = 0;
 Sanitizer.TIMESPAN_HOUR       = 1;
 Sanitizer.TIMESPAN_2HOURS     = 2;
@@ -413,27 +413,22 @@ Sanitizer.showUI = function(aParentWindo
                 "chrome,titlebar,centerscreen,modal",
                 null);
 };
 
 /** 
  * Deletes privacy sensitive data in a batch, optionally showing the 
  * sanitize UI, according to user preferences
  *
- * @returns  null if everything's fine (no error or displayed UI,  which
- *           should handle errors);  
- *           an object in the form { itemName: error, ... } on (partial) failure
+ * @returns  null (displayed UI, which should handle errors)
  */
 Sanitizer.sanitize = function(aParentWindow) 
 {
-  if (Sanitizer.prefs.getBoolPref(Sanitizer.prefPrompt)) {
-    Sanitizer.showUI(aParentWindow);
-    return null;
-  }
-  return new Sanitizer().sanitize();
+  Sanitizer.showUI(aParentWindow);
+  return null;
 };
 
 Sanitizer.onStartup = function() 
 {
   // we check for unclean exit with pending sanitization
   Sanitizer._checkAndSanitize();
 };
 
@@ -445,14 +440,14 @@ Sanitizer.onShutdown = function()
 
 // this is called on startup and shutdown, to perform pending sanitizations
 Sanitizer._checkAndSanitize = function() 
 {
   const prefs = Sanitizer.prefs;
   if (prefs.getBoolPref(Sanitizer.prefShutdown) && 
       !prefs.prefHasUserValue(Sanitizer.prefDidShutdown)) {
     // this is a shutdown or a startup after an unclean exit
-    Sanitizer.sanitize(null) || // sanitize() returns null on full success
+    new Sanitizer().sanitize() || // sanitize() returns null on full success
       prefs.setBoolPref(Sanitizer.prefDidShutdown, true);
   }
 };
 
 
--- a/browser/components/nsIBrowserGlue.idl
+++ b/browser/components/nsIBrowserGlue.idl
@@ -59,17 +59,17 @@ interface nsIDOMWindow;
 
 [scriptable, uuid(01639c88-c0eb-4d75-9ee1-f325c1e04215)]
 interface nsIBrowserGlue : nsISupports
 {
   /** 
    * Deletes privacy sensitive data according to user preferences
    *
    * @param aParentWindow an optionally null window which is the parent of the 
-   *        sanitization dialog (if it has to be shown per user preferences)
+   *        sanitization dialog
    *
    */
   void sanitize(in nsIDOMWindow aParentWindow);
 
   /**
    * Add Smart Bookmarks special queries to bookmarks menu and toolbar folder.
    */
   void ensurePlacesDefaultQueriesInitialized();
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -18,16 +18,17 @@
 # The Initial Developer of the Original Code is
 # Ben Goodger.
 # Portions created by the Initial Developer are Copyright (C) 2005
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ben Goodger <ben@mozilla.org>
 #   Jeff Walden <jwalden+code@mit.edu>
+#   Ehsan Akhgari <ehsan.akhgari@gmail.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -43,17 +44,16 @@ var gPrivacyPane = {
 
   /**
    * Sets up the UI for the number of days of history to keep, and updates the
    * label of the "Clear Now..." button.
    */
   init: function ()
   {
     this._updateHistoryDaysUI();
-    this.updateClearNowButtonLabel();
   },
 
   // HISTORY
 
   /*
    * Preferences:
    *
    * NOTE: These first two are no longer shown in the UI. They're controlled
@@ -252,53 +252,30 @@ var gPrivacyPane = {
   // CLEAR PRIVATE DATA
 
   /*
    * Preferences:
    *
    * privacy.sanitize.sanitizeOnShutdown
    * - true if the user's private data is cleared on startup according to the
    *   Clear Private Data settings, false otherwise
-   * privacy.sanitize.promptOnSanitize
-   * - true if sanitizing forces the user to accept a dialog, false otherwise
    */
 
   /**
-   * Sets the label of the "Clear Now..." button according to the
-   * privacy.sanitize.promptOnSanitize preference. Read valueFromPreferences to
-   * only change the button when the underlying pref changes, since in the case
-   * of instantApply=false, the call to clearPrivateDataNow would result in the
-   * dialog appearing when the user just unchecked the "Ask me" checkbox.
-   */
-  updateClearNowButtonLabel: function ()
-  {
-    var pref = document.getElementById("privacy.sanitize.promptOnSanitize");
-    var clearNowButton = document.getElementById("clearDataNow");
-
-    if (pref.valueFromPreferences)
-      clearNowButton.label = clearNowButton.getAttribute("label1"); // "Clear Now..."
-    else
-      clearNowButton.label = clearNowButton.getAttribute("label2"); // "Clear Now"
-  },
-
-  /**
    * Displays the Clear Private Data settings dialog.
    */
   showClearPrivateDataSettings: function ()
   {
     document.documentElement.openSubDialog("chrome://browser/content/preferences/sanitize.xul",
                                            "", null);
-    this.updateClearNowButtonLabel();
   },
 
   /**
-   * Either displays a dialog from which individual parts of private data may be
-   * cleared, or automatically clears private data according to current
-   * CPD settings.  The former happens if privacy.sanitize.promptOnSanitize is
-   * true, and the latter happens otherwise.
+   * Displays a dialog from which individual parts of private data may be
+   * cleared.
    */
   clearPrivateDataNow: function ()
   {
     const Cc = Components.classes, Ci = Components.interfaces;
     var glue = Cc["@mozilla.org/browser/browserglue;1"]
                  .getService(Ci.nsIBrowserGlue);
     glue.sanitize(window || null);
   }
--- a/browser/components/preferences/privacy.xul
+++ b/browser/components/preferences/privacy.xul
@@ -19,16 +19,17 @@
 # The Initial Developer of the Original Code is
 # Ben Goodger.
 # Portions created by the Initial Developer are Copyright (C) 2005
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ben Goodger <ben@mozilla.org>
 #   Jeff Walden <jwalden+code@mit.edu>
+#   Ehsan Akhgari <ehsan.akhgari@gmail.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -89,20 +90,16 @@
       <preference id="network.cookie.cookieBehavior"      name="network.cookie.cookieBehavior"      type="int"/>
       <preference id="network.cookie.lifetimePolicy"      name="network.cookie.lifetimePolicy"      type="int"/>
       <preference id="network.cookie.blockFutureCookies"  name="network.cookie.blockFutureCookies"  type="bool"/>
 
       <!-- Clear Private Data -->
       <preference id="privacy.sanitize.sanitizeOnShutdown"
                   name="privacy.sanitize.sanitizeOnShutdown"
                   type="bool"/>
-      <preference id="privacy.sanitize.promptOnSanitize"
-                  name="privacy.sanitize.promptOnSanitize"
-                  type="bool"
-                  onchange="gPrivacyPane.updateClearNowButtonLabel();"/>
 
     </preferences>
     
     <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/>
     
     <script type="application/x-javascript" src="chrome://browser/content/preferences/privacy.js"/>
 
     <!-- History -->
@@ -200,23 +197,19 @@
                   preference="privacy.sanitize.sanitizeOnShutdown"
                   label="&alwaysClear.label;"
                   accesskey="&alwaysClear.accesskey;"/>
         <button id="clearDataSettings" label="&clearDataSettings.label;"
                 accesskey="&clearDataSettings.accesskey;"
                 oncommand="gPrivacyPane.showClearPrivateDataSettings();"/>
       </hbox>
       <hbox id="askClearBox">
-        <checkbox id="askBeforeClear" flex="1"
-                  preference="privacy.sanitize.promptOnSanitize"
-                  label="&askBeforeClear.label;"
-                  accesskey="&askBeforeClear.accesskey;"/>
+        <spacer flex="1"/>
         <button id="clearDataNow" icon="clear"
-                label1="&clearDataNow.label;"
-                label2="&clearDataNow.label2;"
+                label="&clearDataNow.label;"
                 accesskey="&clearDataNow.accesskey;"
                 oncommand="gPrivacyPane.clearPrivateDataNow();"/>
       </hbox>
     </groupbox>
 
   </prefpane>
 
 </overlay>
--- a/browser/locales/en-US/chrome/browser/preferences/privacy.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/privacy.dtd
@@ -47,17 +47,13 @@
 <!ENTITY  showCookies.accesskey         "S">
 
 
 <!ENTITY  privateData.label             "Private Data">
 
 <!ENTITY  alwaysClear.label              "Always clear my private data when I close &brandShortName;">
 <!ENTITY  alwaysClear.accesskey          "w">
 
-<!ENTITY  askBeforeClear.label           "Ask me before clearing private data">
-<!ENTITY  askBeforeClear.accesskey       "A">
-
 <!ENTITY  clearDataSettings.label        "Settings…">
 <!ENTITY  clearDataSettings.accesskey    "t">
 
 <!ENTITY  clearDataNow.label             "Clear Now…">
-<!ENTITY  clearDataNow.label2            "Clear Now">
 <!ENTITY  clearDataNow.accesskey         "N">
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -17,16 +17,17 @@
 # The Initial Developer of the Original Code is
 # Ben Goodger.
 # Portions created by the Initial Developer are Copyright (C) 2005
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ben Goodger <ben@mozilla.org>
 #   Giorgio Maone <g.maone@informaction.com>
+#   Ehsan Akhgari <ehsan.akhgari@gmail.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -250,17 +251,16 @@ Sanitizer.prototype = {
     }
   }
 };
 
 
 
 // "Static" members
 Sanitizer.prefDomain          = "privacy.sanitize.";
-Sanitizer.prefPrompt          = "promptOnSanitize";
 Sanitizer.prefShutdown        = "sanitizeOnShutdown";
 Sanitizer.prefDidShutdown     = "didShutdownSanitize";
 
 Sanitizer._prefs = null;
 Sanitizer.__defineGetter__("prefs", function() 
 {
   return Sanitizer._prefs ? Sanitizer._prefs
     : Sanitizer._prefs = Components.classes["@mozilla.org/preferences-service;1"]
@@ -283,27 +283,22 @@ Sanitizer.showUI = function(aParentWindo
                 "chrome,titlebar,centerscreen,modal",
                 null);
 };
 
 /** 
  * Deletes privacy sensitive data in a batch, optionally showing the 
  * sanitize UI, according to user preferences
  *
- * @returns  null if everything's fine (no error or displayed UI,  which
- *           should handle errors);  
- *           an object in the form { itemName: error, ... } on (partial) failure
+ * @returns  null (displayed UI, which should handle errors)
  */
 Sanitizer.sanitize = function(aParentWindow) 
 {
-  if (Sanitizer.prefs.getBoolPref(Sanitizer.prefPrompt)) {
-    Sanitizer.showUI(aParentWindow);
-    return null;
-  }
-  return new Sanitizer().sanitize();
+  Sanitizer.showUI(aParentWindow);
+  return null;
 };
 
 Sanitizer.onStartup = function() 
 {
   // we check for unclean exit with pending sanitization
   Sanitizer._checkAndSanitize();
 };
 
@@ -315,14 +310,14 @@ Sanitizer.onShutdown = function()
 
 // this is called on startup and shutdown, to perform pending sanitizations
 Sanitizer._checkAndSanitize = function() 
 {
   const prefs = Sanitizer.prefs;
   if (prefs.getBoolPref(Sanitizer.prefShutdown) && 
       !prefs.prefHasUserValue(Sanitizer.prefDidShutdown)) {
     // this is a shutdown or a startup after an unclean exit
-    Sanitizer.sanitize(null) || // sanitize() returns null on full success
+    new Sanitizer().sanitize() || // sanitize() returns null on full success
       prefs.setBoolPref(Sanitizer.prefDidShutdown, true);
   }
 };