[tor-commits] [torbutton/master] Bug 4611: Notify user if New Identity fails

mikeperry at torproject.org mikeperry at torproject.org
Fri Dec 9 00:02:22 UTC 2011


commit 185df48b561df541cecc6dba63deb1b2663715a0
Author: Mike Perry <mikeperry-git at fscked.org>
Date:   Thu Dec 8 15:24:40 2011 -0800

    Bug 4611: Notify user if New Identity fails
    
    Throw up some alerts.
---
 src/chrome/content/torbutton.js |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 01adeb5..a641299 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1358,6 +1358,15 @@ function torbutton_send_ctrl_cmd(command) {
   }
 }
 
+function torbutton_new_identity() {
+  try {
+    torbutton_do_new_identity();
+  } catch(e) {
+    torbutton_log(5, "Unexpected error on new identity: "+e);
+    window.alert("Torbutton: Unexpected error on new identity: "+e);
+  }
+}
+
 /* The "New Identity" implementation does the following:
  *   1. Tag all tabs as non-tor
  *   2. Disables Javascript and plugins on all tabs
@@ -1375,7 +1384,7 @@ function torbutton_send_ctrl_cmd(command) {
  *
  * XXX: intermediate SSL certificates are not cleared.
  */
-function torbutton_new_identity() {
+function torbutton_do_new_identity() {
   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
       .getService(Components.interfaces.nsIWindowMediator);
   var enumerator = wm.getEnumerator("navigator:browser");
@@ -1478,6 +1487,7 @@ function torbutton_new_identity() {
       cache.evictEntries(0);
   } catch(e) {
       torbutton_log(5, "Exception on cache clearing: "+e);
+      window.alert("Torbutton: Unexpected error during cache clearing: "+e);
   }
 
   if (m_tb_prefs.getBoolPref('extensions.torbutton.cookie_protections')) {
@@ -1513,7 +1523,10 @@ function torbutton_new_identity() {
     window.alert(warning);
   } else {
     if(torbutton_send_ctrl_cmd("SIGNAL NEWNYM\r\n") == 0) {
+      var o_stringbundle = torbutton_get_stringbundle();
+      var warning = o_stringbundle.GetStringFromName("torbutton.popup.no_newnym");
       torbutton_log(5, "Torbutton was unable to request a new circuit from Tor");
+      window.alert(warning);
     }
   }
 
@@ -1521,7 +1534,6 @@ function torbutton_new_identity() {
   torbutton_set_window_size(gBrowser.contentWindow);
 
   torbutton_log(3, "New identity successful");
-
 }
 
 // toggles plugins: true for disabled, false for enabled





More information about the tor-commits mailing list