Bug 1203531 - Don't use default prefs for determining Custom History, use actual values. r=Gijs
authorMike Kaply <mozilla@kaply.com>
Wed, 21 Oct 2015 14:52:27 -0500
changeset 268890 b031fc40cf45213e29c085292568a22ef9d5621c
parent 268889 dc1467aff5e45fc7e31eb08969265c3ec1c72798
child 268891 2e4faf57a03b136b60db88deed366bf21497db81
push id29566
push usercbook@mozilla.com
push dateThu, 22 Oct 2015 09:45:32 +0000
treeherdermozilla-central@76bd0c01d72e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1203531
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203531 - Don't use default prefs for determining Custom History, use actual values. r=Gijs
browser/components/preferences/in-content/privacy.js
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -121,30 +121,31 @@ var gPrivacyPane = {
   },
 
   // HISTORY MODE
 
   /**
    * The list of preferences which affect the initial history mode settings.
    * If the auto start private browsing mode pref is active, the initial
    * history mode would be set to "Don't remember anything".
-   * If all of these preferences have their default values, and the auto-start
+   * If ALL of these preferences are set to the values that correspond
+   * to keeping some part of history, and the auto-start
    * private browsing mode is not active, the initial history mode would be
    * set to "Remember everything".
    * Otherwise, the initial history mode would be set to "Custom".
    *
-   * Extensions adding their own preferences can append their IDs to this array if needed.
+   * Extensions adding their own preferences can set values here if needed.
    */
-  prefsForDefault: [
-    "places.history.enabled",
-    "browser.formfill.enable",
-    "network.cookie.cookieBehavior",
-    "network.cookie.lifetimePolicy",
-    "privacy.sanitize.sanitizeOnShutdown"
-  ],
+  prefsForKeepingHistory: {
+    "places.history.enabled": true, // History is enabled
+    "browser.formfill.enable": true, // Form information is saved
+    "network.cookie.cookieBehavior": 0, // All cookies are enabled
+    "network.cookie.lifetimePolicy": 0, // Cookies use supplied lifetime
+    "privacy.sanitize.sanitizeOnShutdown": false, // Private date is NOT cleared on shutdown
+  },
 
   /**
    * The list of control IDs which are dependent on the auto-start private
    * browsing setting, such that in "Custom" mode they would be disabled if
    * the auto-start private browsing checkbox is checked, and enabled otherwise.
    *
    * Extensions adding their own controls can append their IDs to this array if needed.
    */
@@ -153,40 +154,39 @@ var gPrivacyPane = {
     "rememberForms",
     "keepUntil",
     "keepCookiesUntil",
     "alwaysClear",
     "clearDataSettings"
   ],
 
   /**
-   * Check whether all the preferences values are set to their default values
+   * Check whether preferences values are set to keep history
    *
    * @param aPrefs an array of pref names to check for
-   * @returns boolean true if all of the prefs are set to their default values,
+   * @returns boolean true if all of the prefs are set to keep history,
    *                  false otherwise
    */
-  _checkDefaultValues: function(aPrefs) {
-    for (let i = 0; i < aPrefs.length; ++i) {
-      let pref = document.getElementById(aPrefs[i]);
-      if (pref.value != pref.defaultValue)
+  _checkHistoryValues: function(aPrefs) {
+    for (let pref of Object.keys(aPrefs)) {
+      if (document.getElementById(pref).value != aPrefs[pref])
         return false;
     }
     return true;
   },
 
   /**
    * Initialize the history mode menulist based on the privacy preferences
    */
   initializeHistoryMode: function PPP_initializeHistoryMode()
   {
     let mode;
     let getVal = aPref => document.getElementById(aPref).value;
 
-    if (this._checkDefaultValues(this.prefsForDefault)) {
+    if (this._checkHistoryValues(this.prefsForKeepingHistory)) {
       if (getVal("browser.privatebrowsing.autostart"))
         mode = "dontremember";
       else
         mode = "remember";
     }
     else
       mode = "custom";