[tbb-commits] [torbutton/master] Bug 9906: Warn users before closing all windows and performing new identity.

mikeperry at torproject.org mikeperry at torproject.org
Fri Feb 13 07:21:46 UTC 2015


commit 2310af87aafc831db955c06616e282d3def99e21
Author: Mike Perry <mikeperry-git at torproject.org>
Date:   Tue Feb 10 15:07:38 2015 -0800

    Bug 9906: Warn users before closing all windows and performing new identity.
---
 src/chrome/content/torbutton.js           |   28 +++++++++++++++++++++++++++-
 src/chrome/locale/en/torbutton.properties |    1 +
 src/defaults/preferences/preferences.js   |    1 +
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 4fa3d63..cd534a7 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1558,7 +1558,33 @@ function torbutton_new_identity() {
     // Make sure that we can only click once on New Identiy to avoid race
     // conditions leading to failures (see bug 11783 for an example).
     document.getElementById("torbutton-new-identity").disabled = true;
-    torbutton_do_new_identity();
+
+    let shouldConfirm =  m_tb_prefs.getBoolPref("extensions.torbutton.confirm_newnym");
+
+    if (shouldConfirm) {
+      let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+                      .getService(Ci.nsIPromptService);
+
+      // Display two buttons, both with string titles.
+      let flags = prompts.STD_YES_NO_BUTTONS;
+
+      let message = torbutton_get_property_string("torbutton.popup.confirm_newnym");
+      let askAgainText = torbutton_get_property_string("torbutton.popup.never_ask_again");
+      let askAgain = {value: false};
+
+      let confirmed = (prompts.confirmEx(null, "", message, flags, null, null, null,
+          askAgainText, askAgain) == 0);
+
+      m_tb_prefs.setBoolPref("extensions.torbutton.confirm_newnym", !askAgain.value);
+
+      if (confirmed) {
+        torbutton_do_new_identity();
+      } else {
+        document.getElementById("torbutton-new-identity").disabled = false;
+      }
+    } else {
+        torbutton_do_new_identity();
+    }
   } catch(e) {
     // If something went wrong make sure we have the New Identity button
     // enabled (again).
diff --git a/src/chrome/locale/en/torbutton.properties b/src/chrome/locale/en/torbutton.properties
index c3e85a3..505f31b 100644
--- a/src/chrome/locale/en/torbutton.properties
+++ b/src/chrome/locale/en/torbutton.properties
@@ -51,6 +51,7 @@ torbutton.popup.short_torbrowser = Important Torbutton Information!\n\nTorbutton
 
 torbutton.popup.confirm_plugins = Plugins such as Flash can harm your privacy and anonymity.\n\nThey can also bypass Tor to reveal your current location and IP address.\n\nAre you sure you want to enable plugins?\n\n
 torbutton.popup.never_ask_again = Never ask me again
+torbutton.popup.confirm_newnym = Tor Browser will close all windows and tabs. All website sessions will be lost.\n\nRestart Tor Browser now to reset your identity?\n\n
 
 # Canvas permission prompt. Strings are kept here for ease of translation.
 canvas.siteprompt=This website (%S) attempted to extract HTML5 canvas image data, which may be used to uniquely identify your computer.\n\nShould Tor Browser allow this website to extract HTML5 canvas image data?
diff --git a/src/defaults/preferences/preferences.js b/src/defaults/preferences/preferences.js
index 6dde983..3584581 100644
--- a/src/defaults/preferences/preferences.js
+++ b/src/defaults/preferences/preferences.js
@@ -221,6 +221,7 @@ pref("extensions.torbutton.useragent_vendorSub","");
 
 pref("extensions.torbutton.prompt_torbrowser", true);
 pref("extensions.torbutton.confirm_plugins", true);
+pref("extensions.torbutton.confirm_newnym", true);
 
 // Browser home page, and spell checker dictionary:
 pref("browser.startup.homepage", "chrome://torbutton/locale/browser.properties");





More information about the tbb-commits mailing list