[or-cvs] r16119: Try to catch false positives of crash recovery so we don't a (in torbutton/trunk/src: . chrome/content defaults/preferences)

mikeperry at seul.org mikeperry at seul.org
Tue Jul 22 12:35:11 UTC 2008


Author: mikeperry
Date: 2008-07-22 08:35:11 -0400 (Tue, 22 Jul 2008)
New Revision: 16119

Modified:
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/defaults/preferences/preferences.js
   torbutton/trunk/src/install.rdf
Log:

Try to catch false positives of crash recovery so we don't
accidentally clear cookies and infringe upon "users' rights".



Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2008-07-22 12:10:18 UTC (rev 16118)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2008-07-22 12:35:11 UTC (rev 16119)
@@ -130,13 +130,13 @@
 
                 break;
 
+            // These two are set from the Torbutton crash-observer component
+            // (which itself just wrappes the sessionstartup firefox
+            // component to get doRestore notification)
             case "extensions.torbutton.crashed":
-                // can we say ghetto hack, boys and girls?
                 torbutton_crash_recover();
                 break;
-
             case "extensions.torbutton.noncrashed":
-               // can we say ghetto hack, boys and girls?
                torbutton_set_initial_state();
                break;
 
@@ -588,9 +588,7 @@
             torbutton_log(5, "Tor test failed. TorDNSEL Failure?");
             ret = 6;
         } else {
-            // XXX: Probably wise to remove this log message if it doesn't
-            // happen..
-            torbutton_log(5, "Tor test failed. Strange target: "+result.target);
+            torbutton_log(5, "Tor test failed. Strange target.");
             ret = 7;
         }
     } else {
@@ -1041,7 +1039,7 @@
     if(!changed && force_update)
         return;
 
-    // XXX: Pref for this?
+    // XXX: Pref for this? Hrmm.. It's broken anyways
     torbutton_setIntPref("browser.bookmarks.livemark_refresh_seconds", 
             "livemark_refresh", 31536000, mode, changed);
 
@@ -1112,7 +1110,7 @@
         return;
     }
 
-    // XXX: muck around with browser.tabs.warnOnClose
+    // TODO: muck around with browser.tabs.warnOnClose.. maybe..
     torbutton_log(3, "Closing tabs");
     var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
         .getService(Components.interfaces.nsIWindowMediator);
@@ -1867,6 +1865,19 @@
 
     // Crash detection code (works w/ components/crash-observer.js)
     if(m_tb_prefs.getBoolPref("extensions.torbutton.crashed")) {
+        // This may run on first install and wipe the user's cookies
+        // It may also run on upgrade
+        try {
+            if(m_tb_prefs.getBoolPref("extensions.torbutton.normal_exit")) {
+                m_tb_prefs.setBoolPref("extensions.torbutton.normal_exit", false);
+                m_tb_prefs.setBoolPref("extensions.torbutton.crashed", false);
+                torbutton_log(3, "False positive crash recovery averted");
+                return;
+            }
+        } catch(e) {
+            torbutton_log(4, "Exception on crash check: "+e);
+        }
+
         torbutton_log(4, "Crash detected, attempting recovery");
         var state = torbutton_check_status();
         if(state != m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
@@ -1888,7 +1899,7 @@
         m_tb_prefs.setBoolPref("extensions.torbutton.tor_enabled", state);
         m_tb_prefs.setBoolPref("extensions.torbutton.proxies_applied", state);
         m_tb_prefs.setBoolPref("extensions.torbutton.settings_applied", state);
-       
+      
         // Do the restore cookies first because we potentially save
         // cookies by toggling tor state in the next pref. If we
         // do this first, we can be sure we have the 'right' cookies
@@ -1927,23 +1938,19 @@
         this._uninstall = false;
       }
     }
+
   } else if (topic == "quit-application-granted") {
     if (this._uninstall) {
         torbutton_disable_tor();
+    }
 
-        /*
-        if(m_tb_prefs.prefHasUserValue("browser.send_pings"))
-            m_tb_prefs.clearUserPref("browser.send_pings");
+    // Set pref in case this is just an upgrade (So we don't
+    // mess with cookies)
+    torbutton_log(2, "Torbutton normal exit");
+    m_tb_prefs.setBoolPref("extensions.torbutton.normal_exit", true);
+    m_tb_prefs.setBoolPref("extensions.torbutton.crashed", false);
+    m_tb_prefs.setBoolPref("extensions.torbutton.noncrashed", false);
 
-        if(m_tb_prefs.prefHasUserValue("browser.safebrowsing.remoteLookups"))
-            m_tb_prefs.clearUserPref("browser.safebrowsing.remoteLookups");
-
-        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 && 
         m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled"))
         || m_tb_prefs.getIntPref("extensions.torbutton.shutdown_method") == 2) {
@@ -2076,6 +2083,16 @@
 
 function torbutton_set_initial_state() {
     if(m_tb_prefs.getBoolPref("extensions.torbutton.noncrashed")) {
+        try {
+            if(m_tb_prefs.getBoolPref("extensions.torbutton.normal_exit")) {
+                m_tb_prefs.setBoolPref("extensions.torbutton.normal_exit", false);
+            } else {
+                torbutton_log(4, "Conflict between noncrashed and normal_exit states?");
+            }
+        } catch(e) {
+            torbutton_log(4, "Exception on noncrashed check: "+e);
+        }
+
         var startup_state = m_tb_prefs.getIntPref("extensions.torbutton.startup_state");
         
         torbutton_log(3, "Setting initial state to: "+startup_state);
@@ -2511,7 +2528,7 @@
             // enabled.
             str2 += "window.__tb_set_uagent=false;\r\n";
         }
-        if(torprefs.getBoolPref("spoof_english")) {
+        if(m_tb_prefs.getBoolPref("extensions.torbutton.spoof_english")) {
             str2 += "window.__tb_locale=\""+m_tb_prefs.getCharPref('extensions.torbutton.spoof_locale')+"\";\r\n";
         } else {
             str2 += "window.__tb_locale=false;\r\n";

Modified: torbutton/trunk/src/defaults/preferences/preferences.js
===================================================================
--- torbutton/trunk/src/defaults/preferences/preferences.js	2008-07-22 12:10:18 UTC (rev 16118)
+++ torbutton/trunk/src/defaults/preferences/preferences.js	2008-07-22 12:35:11 UTC (rev 16119)
@@ -85,6 +85,7 @@
 pref("extensions.torbutton.asked_ca_disable",false);
 pref("extensions.torbutton.warned_ff3",false);
 pref("extensions.torbutton.fresh_install",true);
+pref("extensions.torbutton.normal_exit",false);
 
 // Security prefs:
 pref("extensions.torbutton.no_tor_plugins",true);

Modified: torbutton/trunk/src/install.rdf
===================================================================
--- torbutton/trunk/src/install.rdf	2008-07-22 12:10:18 UTC (rev 16118)
+++ torbutton/trunk/src/install.rdf	2008-07-22 12:35:11 UTC (rev 16119)
@@ -6,7 +6,7 @@
         <em:name>Torbutton</em:name>
         <em:creator>Mike Perry &amp; Scott Squires</em:creator>
         <em:id>{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}</em:id>
-        <em:version>1.2.0rc6</em:version>
+        <em:version>1.2.0rc6-dev</em:version>
         <em:homepageURL>https://torbutton.torproject.org/dev/</em:homepageURL>
         <em:optionsURL>chrome://torbutton/content/preferences.xul</em:optionsURL>
         <em:iconURL>chrome://torbutton/skin/tor.png</em:iconURL>



More information about the tor-commits mailing list