[or-cvs] [torbutton/master 10/30] Fix bug 1219: Fix the toggle warning loop.
mikeperry at torproject.org
mikeperry at torproject.org
Fri Apr 9 22:54:00 UTC 2010
Author: Mike Perry <mikeperry-git at fscked.org>
Date: Mon, 29 Mar 2010 18:25:54 -0700
Subject: Fix bug 1219: Fix the toggle warning loop.
Commit: 1612dfb32507ffa579915d12ca416a2b54bf62e8
It should now only display once per settings window close.
---
src/chrome/content/preferences.js | 11 +++++++++++
src/chrome/content/torbutton.js | 17 ++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 92f1742..a922d20 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -336,6 +336,17 @@ function torbutton_prefs_save(doc) {
var o_torprefs = torbutton_get_prefbranch('extensions.torbutton.');
var o_customprefs = torbutton_get_prefbranch('extensions.torbutton.custom.');
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ var enumerator = wm.getEnumerator("navigator:browser");
+ while(enumerator.hasMoreElements()) {
+ var win = enumerator.getNext();
+ if(win != window && win.m_tb_is_main_window) {
+ torbutton_log(3, "Found main window for popup hack.");
+ win.torbutton_unique_pref_observer.did_toggle_warning = false;
+ }
+ }
+
o_torprefs.setBoolPref('display_panel', doc.getElementById('torbutton_displayStatusPanel').checked);
o_torprefs.setCharPref('panel_style', doc.getElementById('torbutton_panelStyle').value);
o_torprefs.setCharPref('settings_method', doc.getElementById('torbutton_settingsMethod').value);
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index ce7f4da..5540fad 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -67,6 +67,7 @@ var torbutton_unique_pref_observer =
this.forced_ua = false;
var pref_service = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranchInternal);
+ this.did_toggle_warning = false;
this._branch = pref_service.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
this._branch.addObserver("extensions.torbutton", this, false);
this._branch.addObserver("network.proxy", this, false);
@@ -263,18 +264,22 @@ var torbutton_unique_pref_observer =
case "extensions.torbutton.block_tforms":
case "extensions.torbutton.block_cache":
case "extensions.torbutton.block_thwrite":
- if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
+ if(!this.did_toggle_warning &&
+ m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
var o_stringbundle = torbutton_get_stringbundle();
var warning = o_stringbundle.GetStringFromName("torbutton.popup.toggle.warning");
+ this.did_toggle_warning = true;
window.alert(warning);
}
break;
case "extensions.torbutton.block_nthwrite":
case "extensions.torbutton.block_ntforms":
- if(!m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
+ if(!this.did_toggle_warning &&
+ m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
var o_stringbundle = torbutton_get_stringbundle();
var warning = o_stringbundle.GetStringFromName("torbutton.popup.toggle.warning");
+ this.did_toggle_warning = true;
window.alert(warning);
}
break;
@@ -3461,8 +3466,14 @@ function torbutton_update_tags(win, new_loc) {
return;
//win.alert("No window found!");
}
- torbutton_log(2, "Got browser "+browser.contentWindow.location+" for: "
+
+ // This sometimes happens with CoolPreviews..
+ try {
+ torbutton_log(2, "Got browser "+browser.contentWindow.location+" for: "
+ win.location + ", under: "+win.top.location);
+ } catch(e) {
+ torbutton_log(4, "Missing content window? "+str(e));
+ }
// Base this tag off of proxies_applied, since we want to go
// by whatever the actual load proxy was
--
1.6.5
More information about the tor-commits
mailing list