[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r15402: Revamp how we handle saving+setting Firefox preferences. Bee (in torbutton/trunk/src: chrome/content chrome/locale/en-US components defaults/preferences)



Author: mikeperry
Date: 2008-06-22 02:15:31 -0400 (Sun, 22 Jun 2008)
New Revision: 15402

Modified:
   torbutton/trunk/src/chrome/content/preferences.js
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/chrome/content/torbutton_util.js
   torbutton/trunk/src/chrome/locale/en-US/torbutton.properties
   torbutton/trunk/src/components/crash-observer.js
   torbutton/trunk/src/defaults/preferences/preferences.js
Log:

Revamp how we handle saving+setting Firefox preferences. Beef
up "Restore Defaults" button and uninstall code to revert every
pref we touch to the Firefox default, just in case. May annoy
some advanced users, but at least the less experienced ones
won't be completely helpless in the event we do wedge a pref.



Modified: torbutton/trunk/src/chrome/content/preferences.js
===================================================================
--- torbutton/trunk/src/chrome/content/preferences.js	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/chrome/content/preferences.js	2008-06-22 06:15:31 UTC (rev 15402)
@@ -392,8 +392,6 @@
     
     torbutton_log(3, "Tor disabled for pref reset");
 
-    // XXX: Some of these are torbutton state variables that should NOT
-    // be reset!
     children = o_torprefs.getChildList("" , tmpcnt);
     for(i = 0; i < children.length; i++) {
         if(o_torprefs.prefHasUserValue(children[i]))
@@ -406,12 +404,21 @@
             o_proxyprefs.clearUserPref(children[i]);
     }
     
+    torbutton_log(3, "Resetting browser prefs");
+
+    // Reset browser prefs that torbutton touches just in case
+    // they get horked. Better everything gets set back to default
+    // than some arcane pref gets wedged with no clear way to do it.
+    // Technical users who tuned these by themselves will be able to fix it.
+    // It's the non-technical ones we should make it easy for
+    torbutton_reset_browser_prefs();
+
     torbutton_log(3, "Prefs reset");
 
     if(was_enabled) {
         chrome.torbutton_enable_tor();
     }
 
-    torbutton_log(5, "Preferences reset to defaults");
+    torbutton_log(4, "Preferences reset to defaults");
     torbutton_prefs_init(window.document);
 }

Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2008-06-22 06:15:31 UTC (rev 15402)
@@ -101,14 +101,15 @@
             case "extensions.torbutton.cookie_jars":
             case "extensions.torbutton.clear_cookies":
                 torbutton_log(2, "Got cookie pref change");
-                if(!m_tb_prefs.getBoolPref("extensions.torbutton.cookie_jars")
-                    && !m_tb_prefs.getBoolPref("extensions.torbutton.clear_cookies")) {
-                    torbutton_log(3, "Changing lifetime");
-                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy",
-                            m_tb_prefs.getIntPref("extensions.torbutton.saved.cookieLifetime")); 
-                } else if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
-                    torbutton_log(3, "Changing lifetime");
-                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 2); 
+                if(m_tb_prefs.getBoolPref('extensions.torbutton.clear_cookies')) {
+                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 2);
+                } else if(m_tb_prefs.getBoolPref('extensions.torbutton.cookie_jars')) {
+                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 
+                            m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled") ? 2 : 0);
+                } else if(m_tb_prefs.getBoolPref("extensions.torbutton.dual_cookie_jars")) {
+                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 0);
+                } else {
+                    m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 0);
                 }
                 break;
 
@@ -139,7 +140,6 @@
                     if(m_tb_prefs.prefHasUserValue("general.platform.override"))
                         m_tb_prefs.clearUserPref("general.platform.override");
                     
-                    // XXX: Is this ok on ff2?
                     if(m_tb_prefs.prefHasUserValue("general.oscpu.override"))
                         m_tb_prefs.clearUserPref("general.oscpu.override");
                     if(m_tb_prefs.prefHasUserValue("general.buildID.override"))
@@ -155,20 +155,34 @@
                 }
                 break;
 
+            case "extensions.torbutton.no_tor_plugins":
+                torbutton_update_status(
+                        m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled"),
+                        true);
             case "extensions.torbutton.disable_referer":
-                if(!m_tb_prefs.getBoolPref("extensions.torbutton.disable_referer")) {
-                    m_tb_prefs.setBoolPref("network.http.sendSecureXSiteReferrer", true);
-                    m_tb_prefs.setIntPref("network.http.sendRefererHeader", 2);
-                }
-            case "extensions.torbutton.no_tor_plugins":
+            case "extensions.torbutton.disable_domstorage":
             case "extensions.torbutton.no_updates":
             case "extensions.torbutton.no_search":
+            case "extensions.torbutton.block_tforms":
             case "extensions.torbutton.block_cache":
+            case "extensions.torbutton.block_thwrite":
+                if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
+                    var o_stringbundle = torbutton_get_stringbundle();
+                    var warning = o_stringbundle.GetStringFromName("torbutton.popup.toggle.warning");
+                    window.alert(warning);
+                }
+                break;
+
             case "extensions.torbutton.block_nthwrite":
-            case "extensions.torbutton.block_thwrite":
-            case "extensions.torbutton.shutdown_method":
+            case "extensions.torbutton.block_ntforms":
+                if(!m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
+                    var o_stringbundle = torbutton_get_stringbundle();
+                    var warning = o_stringbundle.GetStringFromName("torbutton.popup.toggle.warning");
+                    window.alert(warning);
+                }
+                break;
+
             case "extensions.torbutton.spoof_english":
-            case "extensions.torbutton.resize_on_toggle":
                 torbutton_log(1, "Got update message, updating status");
                 torbutton_update_status(
                         m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled"),
@@ -537,6 +551,68 @@
     }
 }
 
+function torbutton_setIntPref(pref, save, val, mode, changed) {
+    if(!changed) return; // Handle the pref change cases via observers
+    if(mode) {
+        if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.setIntPref("extensions.torbutton.saved."+save,
+                    m_tb_prefs.getIntPref(pref));
+        } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+        }
+        m_tb_prefs.setIntPref(pref, val);
+    } else {
+        if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.setIntPref(pref, 
+                    m_tb_prefs.getIntPref("extensions.torbutton.saved."+save));
+        } else if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.clearUserPref(pref);
+        }
+    }
+}
+
+function torbutton_setCharPref(pref, save, val, mode, changed) {
+    if(!changed) return; // Handle the pref change cases via observers
+    if(mode) {
+        if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.setCharPref("extensions.torbutton.saved."+save,
+                    m_tb_prefs.getCharPref(pref));
+        } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+        }
+        m_tb_prefs.setCharPref(pref, val);
+    } else {
+        if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.setCharPref(pref, 
+                    m_tb_prefs.getCharPref("extensions.torbutton.saved."+save));
+        } else if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.clearUserPref(pref);
+        }
+    }
+}
+
+function torbutton_setBoolPref(pref, save, val, mode, changed) {
+    if(!changed) return; // Handle the pref change cases via observers
+    if(mode) {
+        if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.setBoolPref("extensions.torbutton.saved."+save,
+                    m_tb_prefs.getBoolPref(pref));
+        } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+        }
+        m_tb_prefs.setBoolPref(pref, val);
+    } else {
+        if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+            m_tb_prefs.setBoolPref(pref, 
+                    m_tb_prefs.getBoolPref("extensions.torbutton.saved."+save));
+        } else if(m_tb_prefs.prefHasUserValue(pref)) {
+            m_tb_prefs.clearUserPref(pref);
+        }
+    }
+}
+
+// NOTE: If you touch any additional prefs in here, be sure to update
+// the list in torbutton_util.js::torbutton_reset_browser_prefs()
 function torbutton_update_status(mode, force_update) {
     var o_toolbutton = false;
     var o_statuspanel = false;
@@ -647,12 +723,23 @@
     // FIXME: This is not ideal, but the refspoof method is not compatible
     // with FF2.0
     if(torprefs.getBoolPref("disable_referer")) {
-        m_tb_prefs.setBoolPref("network.http.sendSecureXSiteReferrer", !mode);
-        m_tb_prefs.setIntPref("network.http.sendRefererHeader", mode ? 0 : 2);
+        torbutton_setBoolPref("network.http.sendSecureXSiteReferrer", 
+                "sendSecureXSiteReferrer", !mode, mode, changed);
+        torbutton_setIntPref("network.http.sendRefererHeader", 
+                "sendRefererHeader", mode?0:2, mode, changed);
+    } else {
+        torbutton_setBoolPref("network.http.sendSecureXSiteReferrer", 
+                "sendSecureXSiteReferrer", true, mode, changed);
+        torbutton_setIntPref("network.http.sendRefererHeader", 
+                "sendRefererHeader", 2, mode, changed);
     }
 
     if(torprefs.getBoolPref("disable_domstorage")) {
-        m_tb_prefs.setBoolPref("dom.storage.enabled", !mode);
+        torbutton_setBoolPref("dom.storage.enabled", 
+                "dom_storage", !mode, mode, changed);
+    } else {
+        torbutton_setBoolPref("dom.storage.enabled", 
+                "dom_storage", true, mode, changed);
     }
 
     if(torprefs.getBoolPref("spoof_english") && mode) {
@@ -679,15 +766,35 @@
     // XXX: All updates are now required to be authenticated on FF3.. 
     // Perhaps this should be a diff pref.. or default to off?
     if (torprefs.getBoolPref("no_updates")) {
-        m_tb_prefs.setBoolPref("extensions.update.enabled", !mode);
-        m_tb_prefs.setBoolPref("app.update.enabled", !mode);
-        m_tb_prefs.setBoolPref("app.update.auto", !mode);
-        m_tb_prefs.setBoolPref("browser.search.update", !mode);
+        torbutton_setBoolPref("extensions.update.enabled", "extension_update",
+                !mode, mode, changed);
+        torbutton_setBoolPref("app.update.enabled", "app_update",
+                !mode, mode, changed);
+        torbutton_setBoolPref("app.update.auto", "auto_update",
+                !mode, mode, changed);
+        torbutton_setBoolPref("browser.search.update", "search_update",
+                !mode, mode, changed);
+    } else {
+        torbutton_setBoolPref("extensions.update.enabled", "extension_update",
+                true, mode, changed);
+        torbutton_setBoolPref("app.update.enabled", "app_update",
+                true, mode, changed);
+        torbutton_setBoolPref("app.update.auto", "auto_update",
+                true, mode, changed);
+        torbutton_setBoolPref("browser.search.update", "search_update",
+                true, mode, changed);
     }
 
     if (torprefs.getBoolPref('block_cache')) {
-        m_tb_prefs.setBoolPref("browser.cache.memory.enable", !mode);
-        m_tb_prefs.setBoolPref("network.http.use-cache", !mode);
+        torbutton_setBoolPref("browser.cache.memory.enable", 
+                "mem_cache", !mode, mode, changed);
+        torbutton_setBoolPref("network.http.use-cache", 
+                "http_cache", !mode, mode, changed);
+    } else {
+        torbutton_setBoolPref("browser.cache.memory.enable", 
+                "mem_cache", true, mode, changed);
+        torbutton_setBoolPref("network.http.use-cache", 
+                "http_cache", true, mode, changed);
     }
 
     var children = m_tb_prefs.getChildList("network.protocol-handler.warn-external", 
@@ -703,15 +810,16 @@
         }
     }
     
-
     // Always block disk cache during Tor. We clear it on toggle, 
     // so no need to keep it around for someone to rifle through.
-    m_tb_prefs.setBoolPref("browser.cache.disk.enable", !mode);
+    torbutton_setBoolPref("browser.cache.disk.enable", "disk_cache", !mode, 
+            mode, changed);
 
     // Disable safebrowsing in Tor for FF2. It fetches some info in 
     // cleartext with no HMAC (Firefox Bug 360387)
     if(!m_tb_ff3) {
-        m_tb_prefs.setBoolPref("browser.safebrowsing.enabled", !mode);
+        torbutton_setBoolPref("browser.safebrowsing.enabled", "safebrowsing", 
+                !mode, mode, changed);
     }
 
     // I think this pref is evil (and also hidden from user configuration, 
@@ -728,110 +836,85 @@
     m_tb_prefs.setCharPref("network.security.ports.banned", 
             m_tb_prefs.getCharPref("extensions.torbutton.banned_ports"));
    
-    if (torprefs.getBoolPref("no_search")) {
-        m_tb_prefs.setBoolPref("browser.search.suggest.enabled", !mode);
+    if (m_tb_prefs.getBoolPref("extensions.torbutton.no_search")) {
+        torbutton_setBoolPref("browser.search.suggest.enabled", 
+                "search_suggest", !mode, mode, changed);
+    } else {
+        torbutton_setBoolPref("browser.search.suggest.enabled", 
+                "search_suggest", true, mode, changed);
     }
         
-    if(torprefs.getBoolPref("no_tor_plugins")) {
-        m_tb_prefs.setBoolPref("security.enable_java", !mode);
+    if(m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins")) {
+        torbutton_setBoolPref("security.enable_java", "enable_java", !mode, 
+                mode, changed);
+    } else {
+        torbutton_setBoolPref("security.enable_java", "enable_java", true,
+                mode, changed);
     }
 
-
-    if (torprefs.getBoolPref('clear_cache')) {
+    if (m_tb_prefs.getBoolPref('extensions.torbutton.clear_cache')) {
         var cache = Components.classes["@mozilla.org/network/cache-service;1"].
         getService(Components.interfaces.nsICacheService);
         cache.evictEntries(0);
     }
 
-    if (torprefs.getBoolPref('clear_history')) {
+    if (m_tb_prefs.getBoolPref('extensions.torbutton.clear_history')) {
         torbutton_clear_history();
     }
 
-    // FIXME: This is kind of not so user friendly to people who like
-    // to keep their own prefs.. Not sure what to do though..
     if(mode) {
-        if(torprefs.getBoolPref('block_thwrite')) {
-            if(m_tb_ff3) {
-                m_tb_prefs.setIntPref("browser.history_expire_days", 0);
-            }
-            m_tb_prefs.setIntPref("browser.download.manager.retention", 0);
-        } else {
-            if(m_tb_ff3) {
-                // XXX: save user value..
-                if(m_tb_prefs.prefHasUserValue("browser.history_expire_days")) {
-                    m_tb_prefs.clearUserPref("browser.history_expire_days");
-                }
-            }
-            m_tb_prefs.setIntPref("browser.download.manager.retention", 2);
-        }
+        if(m_tb_prefs.getBoolPref('extensions.torbutton.block_thwrite')) {
+            torbutton_setIntPref("browser.history_expire_days", 
+                    "expire_history", 0, mode, changed);
+            torbutton_setIntPref("browser.download.manager.retention", 
+                    "download_retention", 0, mode, changed);
+        } 
 
-        if(torprefs.getBoolPref('block_tforms')) {
-            m_tb_prefs.setBoolPref("browser.formfill.enable", false);
-            m_tb_prefs.setBoolPref("signon.rememberSignons", false);
-        } else {
-            m_tb_prefs.setBoolPref("browser.formfill.enable", true);
-            m_tb_prefs.setBoolPref("signon.rememberSignons", true);
+        if(m_tb_prefs.getBoolPref('extensions.torbutton.block_tforms')) {
+            torbutton_setBoolPref("browser.formfill.enable", "formfill",
+                    false, mode, changed);
+            torbutton_setBoolPref("signon.rememberSignons", "remember_signons", 
+                    false, mode, changed);
         }
     } else {
-        if(torprefs.getBoolPref('block_nthwrite')) {
-            if(m_tb_ff3) {
-                m_tb_prefs.setIntPref("browser.history_expire_days", 0);
-            }
-            m_tb_prefs.setIntPref("browser.download.manager.retention", 0);
+        if(m_tb_prefs.getBoolPref('extensions.torbutton.block_nthwrite')) {
+            m_tb_prefs.setBoolPref("browser.history_expire_days", 0);
+            m_tb_prefs.setBoolPref("browser.download.manager.retention", 0);
         } else {
-            if(m_tb_ff3) {
-                // XXX: save user value..
-                if(m_tb_prefs.prefHasUserValue("browser.history_expire_days")) {
-                    m_tb_prefs.clearUserPref("browser.history_expire_days");
-                }
-            }
-            m_tb_prefs.setIntPref("browser.download.manager.retention", 2);
+            torbutton_setIntPref("browser.history_expire_days", 
+                    "expire_history", 0, mode, changed);
+            torbutton_setIntPref("browser.download.manager.retention", 
+                    "download_retention", 0, mode, changed);
         }
 
-        if(torprefs.getBoolPref('block_ntforms')) {
+        if(m_tb_prefs.getBoolPref('extensions.torbutton.block_ntforms')) {
             m_tb_prefs.setBoolPref("browser.formfill.enable", false);
             m_tb_prefs.setBoolPref("signon.rememberSignons", false);
         } else {
-            m_tb_prefs.setBoolPref("browser.formfill.enable", true);
-            m_tb_prefs.setBoolPref("signon.rememberSignons", true);
+            torbutton_setBoolPref("browser.formfill.enable", "formfill", 
+                    false, mode, changed);
+            torbutton_setBoolPref("signon.rememberSignons", "remember_signons", 
+                    false, mode, changed);
         }
     }
 
     torbutton_log(2, "Prefs pretty much done");
     
-    if(torprefs.getBoolPref("no_tor_plugins")) {
-        if(mode) {
-            if(changed && m_tb_prefs.prefHasUserValue("plugin.disable_full_page_plugin_for_types")) {
-                // Update saved plugin pref
-                torprefs.setCharPref("saved.full_page_plugins", 
-                  m_tb_prefs.getCharPref("plugin.disable_full_page_plugin_for_types"));
-            }
-            // copy plugins array to pref
-            m_tb_prefs.setCharPref("plugin.disable_full_page_plugin_for_types",
-                    m_tb_plugin_string);
-        } else {
-            if(torprefs.prefHasUserValue("saved.full_page_plugins")) {
-                // restore saved pref
-                m_tb_prefs.setCharPref("plugin.disable_full_page_plugin_for_types",
-                        torprefs.getCharPref("saved.full_page_plugins"));
-            } else {
-                m_tb_prefs.clearUserPref("plugin.disable_full_page_plugin_for_types");
-            }
-        }
+    if(m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins")) {
+        torbutton_setCharPref("plugin.disable_full_page_plugin_for_types",
+                "full_page_plugins", m_tb_plugin_string, mode, changed);
+    } else {
+        torbutton_setCharPref("plugin.disable_full_page_plugin_for_types",
+                "full_page_plugins", m_tb_plugin_string, false, changed);
     }
 
     // No need to clear cookies if just updating prefs
     if(!changed && force_update)
         return;
 
-    if(mode) {
-        // XXX: This doesn't really do what we want.. 
-        m_tb_prefs.setIntPref("browser.bookmarks.livemark_refresh_seconds", 31536000);
-    } else {
-        if(m_tb_prefs.prefHasUserValue("browser.bookmarks.livemark_refresh_seconds")) {
-            m_tb_prefs.clearUserPref("browser.bookmarks.livemark_refresh_seconds");
-        }
-    }
+    // XXX: Pref for this?
+    torbutton_setIntPref("browser.bookmarks.livemark_refresh_seconds", 
+            "livemark_refresh", 31536000, mode, changed);
 
     /*
      * XXX: Windows doesn't call tzset() automatically.. Linux and MacOS
@@ -851,35 +934,28 @@
     // This call also has to be here for 3rd party proxy changers.
     torbutton_close_on_toggle(mode);
 
-    if(torprefs.getBoolPref('clear_http_auth')) {
+    if(m_tb_prefs.getBoolPref('extensions.torbutton.clear_http_auth')) {
         var auth = Components.classes["@mozilla.org/network/http-auth-manager;1"].
         getService(Components.interfaces.nsIHttpAuthManager);
         auth.clearAll();
     }
 
-    // Prevent tor cookies from being written to disk
-    if(torprefs.getBoolPref('clear_cookies') 
-            || torprefs.getBoolPref('cookie_jars')) {
-        torbutton_log(2, "Changing cookie lifetime");
-        if(mode) {
-            torprefs.setIntPref("saved.cookieLifetime", 
-                    m_tb_prefs.getIntPref("network.cookie.lifetimePolicy"));
-            m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 2);
-        } else {
-            m_tb_prefs.setIntPref("network.cookie.lifetimePolicy",
-                    torprefs.getIntPref("saved.cookieLifetime")); 
-        }
-        torbutton_log(2, "Cookie lifetime changed");
+    if(m_tb_prefs.getBoolPref('extensions.torbutton.clear_cookies')) {
+        m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 2);
+    } else if(m_tb_prefs.getBoolPref('extensions.torbutton.cookie_jars')) {
+        m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", mode ? 2 : 0);
+    } else if(m_tb_prefs.getBoolPref("extensions.torbutton.dual_cookie_jars")) {
+        m_tb_prefs.setIntPref("network.cookie.lifetimePolicy", 0);
     }
 
-    if (torprefs.getBoolPref('clear_cookies')) {
+    if (m_tb_prefs.getBoolPref('extensions.torbutton.clear_cookies')) {
         torbutton_clear_cookies();
-    } else if (torprefs.getBoolPref('cookie_jars') 
-            || torprefs.getBoolPref('dual_cookie_jars')) {
+    } else if (m_tb_prefs.getBoolPref('extensions.torbutton.cookie_jars') 
+            || m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars')) {
         torbutton_jar_cookies(mode);
     }
 
-    if (torprefs.getBoolPref('jar_certs')) {
+    if (m_tb_prefs.getBoolPref('extensions.torbutton.jar_certs')) {
         torbutton_jar_certs(mode);
     }
 }
@@ -1678,7 +1754,14 @@
         // Still called by pref observer:
         // torbutton_update_status(false, false);
 
-        // Clear out prefs set regardless of Tor state 
+        // Reset all browser prefs that torbutton touches just in case
+        // they get horked. Better everything gets set back to default
+        // than some arcane pref gets wedged with no clear way to do it.
+        // Technical users who tuned these by themselves will be able to fix it.
+        // It's the non-technical ones we should make it easy for
+        torbutton_reset_browser_prefs();
+
+        /*
         if(m_tb_prefs.prefHasUserValue("browser.send_pings"))
             m_tb_prefs.clearUserPref("browser.send_pings");
 
@@ -1688,7 +1771,7 @@
         if(!m_tb_ff3) {
             if(m_tb_prefs.prefHasUserValue("network.security.ports.banned"))
                 m_tb_prefs.clearUserPref("network.security.ports.banned");
-        }
+        }*/
     }
 
     if((m_tb_prefs.getIntPref("extensions.torbutton.shutdown_method") == 1 && 

Modified: torbutton/trunk/src/chrome/content/torbutton_util.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton_util.js	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/chrome/content/torbutton_util.js	2008-06-22 06:15:31 UTC (rev 15402)
@@ -41,6 +41,27 @@
     return o_branch;
 }
 
+function torbutton_reset_browser_prefs() {
+    var o_all_prefs = torbutton_get_prefbranch('');
+    var prefs = ["network.http.sendSecureXSiteReferrer", 
+        "network.http.sendRefererHeader", "dom.storage.enabled", 
+        "extensions.update.enabled", "app.update.enabled",
+        "app.update.auto", "browser.search.update", 
+        "browser.cache.memory.enable", "network.http.use-cache", 
+        "browser.cache.disk.enable", "browser.safebrowsing.enabled",
+        "browser.send_pings", "browser.safebrowsing.remoteLookups",
+        "network.security.ports.banned", "browser.search.suggest.enabled",
+        "security.enable_java", "browser.history_expire_days",
+        "browser.download.manager.retention", "browser.formfill.enable",
+        "signon.rememberSignons", "plugin.disable_full_page_plugin_for_types",
+        "browser.bookmarks.livemark_refresh_seconds", 
+        "network.cookie.lifetimePolicy" ];
+    for(var i = 0; i < prefs.length; i++) {
+        if(o_all_prefs.prefHasUserValue(prefs[i]))
+            o_all_prefs.clearUserPref(prefs[i]);
+    }
+}
+
 // check if the socks_remote_dns preference exists
 function torbutton_check_socks_remote_dns()
 {

Modified: torbutton/trunk/src/chrome/locale/en-US/torbutton.properties
===================================================================
--- torbutton/trunk/src/chrome/locale/en-US/torbutton.properties	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/chrome/locale/en-US/torbutton.properties	2008-06-22 06:15:31 UTC (rev 15402)
@@ -11,3 +11,4 @@
 torbutton.popup.plugin.warning = Torbutton blocked direct Tor load of plugin content.\n\nUse Save-As instead.\n\n
 torbutton.popup.confirm_ca_certs = Torbutton Note: It appears you have no custom Certificate Authorities. Examining the Certificate Authority list is a slow operation and slows down Tor toggle. Would you like to disable the isolation of Certificate Authority certificates? (If you don't understand this, it is safe to click OK)
 torbutton.popup.ff3.warning = Warning!\n\nTorbutton on Firefox 3 is known to leak your timezone and livemark feeds during Tor usage. In addition, it has not been as extensively tested for Tor security and usability as Firefox 2.\n\nDo you wish to continue anyway?
+torbutton.popup.toggle.warning = You need to toggle Tor for your settings to take effect.

Modified: torbutton/trunk/src/components/crash-observer.js
===================================================================
--- torbutton/trunk/src/components/crash-observer.js	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/components/crash-observer.js	2008-06-22 06:15:31 UTC (rev 15402)
@@ -38,7 +38,7 @@
 
   this.logger = Components.classes["@torproject.org/torbutton-logger;1"]
       .getService(Components.interfaces.nsISupports).wrappedJSObject;
-  dump("New crash observer\n");
+  //dump("New crash observer\n");
   this.logger.log(3, "New StoreWrapper");
 
   this._store = function() {
@@ -62,7 +62,7 @@
 
     if(iid.equals(Components.interfaces.nsIClassInfo)) {
       var ret = this._store().QueryInterface(iid);
-      dump("classInfo: "+ret.classID);
+      //dump("classInfo: "+ret.classID);
       return ret;
     }
 
@@ -70,7 +70,7 @@
         var store = this._store().QueryInterface(iid);
         if (store) this.copyMethods(store);
     } catch(e) {
-        dump("Exception on QI for crash detector\n");
+        //dump("Exception on QI for crash detector\n");
         Components.returnCode = Cr.NS_ERROR_NO_INTERFACE;
         return null;
     }
@@ -106,7 +106,7 @@
 
   observe: function(aSubject, aTopic, aData) {
     if(aTopic == "app-startup") {
-      dump("App startup\n");
+      //dump("App startup\n");
       this.logger.log(3, "Got app-startup");
       this._startup = true;
       var observerService = Cc["@mozilla.org/observer-service;1"].
@@ -124,7 +124,7 @@
 
     // This is so lame. But the exposed API is braindead so it 
     // must be hacked around
-    dump("new doRestore\n");
+    //dump("new doRestore\n");
     this.logger.log(3, "Got doRestore");
     ret = this._store().doRestore();
     if(this._startup) {
@@ -183,7 +183,7 @@
                                   fileSpec, 
                                   location, 
                                   type);
-  dump("Registered crash observer\n");
+  //dump("Registered crash observer\n");
 };
 
 StoreWrapperModule.getClassObject = function (compMgr, cid, iid)

Modified: torbutton/trunk/src/defaults/preferences/preferences.js
===================================================================
--- torbutton/trunk/src/defaults/preferences/preferences.js	2008-06-22 06:03:48 UTC (rev 15401)
+++ torbutton/trunk/src/defaults/preferences/preferences.js	2008-06-22 06:15:31 UTC (rev 15402)
@@ -49,8 +49,27 @@
 pref("extensions.torbutton.saved.socks_host","");
 pref("extensions.torbutton.saved.socks_version",0);
 pref("extensions.torbutton.saved.socks_port",0);
+
 pref("extensions.torbutton.saved.cookieLifetime",0);
 pref("extensions.torbutton.saved.full_page_plugins","");
+pref("extensions.torbutton.saved.disk_cache",true);
+pref("extensions.torbutton.saved.safebrowsing",true);
+pref("extensions.torbutton.saved.search_suggest",true);
+pref("extensions.torbutton.saved.enable_java", true);
+pref("extensions.torbutton.saved.expire_history", 9);
+pref("extensions.torbutton.saved.download_retention", 2);
+pref("extensions.torbutton.saved.formfill", true);
+pref("extensions.torbutton.saved.remember_signons", true);
+pref("extensions.torbutton.saved.livemark_refresh", true);
+pref("extensions.torbutton.saved.sendSecureXSiteReferrer", true);
+pref("extensions.torbutton.saved.sendRefererHeader", 2);
+pref("extensions.torbutton.saved.dom_storage", true);
+pref("extensions.torbutton.saved.mem_cache", true);
+pref("extensions.torbutton.saved.http_cache", true);
+pref("extensions.torbutton.saved.extension_update", true);
+pref("extensions.torbutton.saved.app_update", true);
+pref("extensions.torbutton.saved.auto_update", true);
+pref("extensions.torbutton.saved.search_update", true);
 
 // State prefs:
 pref("extensions.torbutton.tor_enabled",false);