[or-cvs] r10610: Created preferences tabbox for all options. Connected option (in torbutton/trunk/src: chrome/content chrome/locale/en-US components defaults/preferences)
mikeperry at seul.org
mikeperry at seul.org
Fri Jun 15 07:59:46 UTC 2007
Author: mikeperry
Date: 2007-06-15 03:59:46 -0400 (Fri, 15 Jun 2007)
New Revision: 10610
Modified:
torbutton/trunk/src/chrome/content/jshooks.js
torbutton/trunk/src/chrome/content/preferences.js
torbutton/trunk/src/chrome/content/preferences.xul
torbutton/trunk/src/chrome/content/torbutton.js
torbutton/trunk/src/chrome/content/torbutton.xul
torbutton/trunk/src/chrome/content/torbutton_util.js
torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd
torbutton/trunk/src/components/ignore-history.js
torbutton/trunk/src/defaults/preferences/preferences.js
Log:
Created preferences tabbox for all options. Connected
options to code. They seem to apply. Improved history
blocking, improved Date() hooking, did some code cleanup.
Modified: torbutton/trunk/src/chrome/content/jshooks.js
===================================================================
--- torbutton/trunk/src/chrome/content/jshooks.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/jshooks.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -1,16 +1,19 @@
-/* dump("Loading torbutton/jshooks.js\n"); */
-
-function __HookObjects() {
+var __HookObjects = function() {
+ /* XXX: Removeme once verified not to run twice */
+ if (typeof(window.__tb_hooks_ran) != 'undefined') {
+ alert("Error, double jshook!");
+ return;
+ }
+
/* TODO: It might be a good idea to hook window sizes also..
- But that will almost certainly fuck with rendering */
+ But that will almost certainly fuck with rendering.. Maybe set
+ user's window to a fixed size? */
- /* XXX: Is it possible this breaks plugin install or other weird shit
+ /* Hrmm.. Is it possible this breaks plugin install or other weird shit
for non-windows OS's? */
- navigator.__defineGetter__("platform",
- function() { return "Windows";});
-
- navigator.__defineGetter__("oscpu",
- function() { return "Win32 i686";});
+ /* XXX: navigator.userAgent? navigator.plugins? */
+ navigator.__defineGetter__("platform", function() { return "Windows";});
+ navigator.__defineGetter__("oscpu", function() { return "Win32 i686";});
/* Timezone fix for http://gemal.dk/browserspy/css.html */
var reparseDate = function(d, str) {
@@ -29,7 +32,7 @@
var s = str.toLowerCase();
var re = new RegExp('\\(.*\\)', "gm");
s = s.replace(re, "");
- dump(s);
+
/* Step 2: Look for +/-. If found, do nothing */
if(s.indexOf("+") == -1 && s.indexOf("-") == -1) {
/* Step 3: Look for timezone string from
@@ -148,7 +151,9 @@
Date.UTC=function(){return tmp.apply(tmp, arguments); }
}
-if (typeof(window.__tb_hooks_ran) == 'undefined') {
+if (__HookObjects) {
+ __HookObjects();
+ __HookObjects = undefined;
+ /* XXX: Removeme */
window.__tb_hooks_ran = true;
- __HookObjects();
}
Modified: torbutton/trunk/src/chrome/content/preferences.js
===================================================================
--- torbutton/trunk/src/chrome/content/preferences.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/preferences.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -136,12 +136,39 @@
doc.getElementById('torbutton_socksPort').value = o_torprefs.getIntPref('socks_port');
// doc.getElementById('torbutton_warnUponExcludedSite').checked = o_torprefs.getBoolPref('prompt_before_visiting_excluded_sites');
- // XXX: work this in with recommended settigns stuff?
doc.getElementById('torbutton_disablePlugins').checked = o_torprefs.getBoolPref('no_tor_plugins');
doc.getElementById('torbutton_clearHistory').checked = o_torprefs.getBoolPref('clear_history');
- doc.getElementById('torbutton_clearCache').checked = o_torprefs.getBoolPref('clear_cache');
- doc.getElementById('torbutton_clearCookies').checked = o_torprefs.getBoolPref('clear_cookies');
doc.getElementById('torbutton_killBadJS').checked = o_torprefs.getBoolPref('kill_bad_js');
+
+ if(o_torprefs.getBoolPref('clear_cache')) {
+ doc.getElementById('torbutton_cacheGroup').selectedItem =
+ doc.getElementById('torbutton_clearCache');
+ o_torprefs.setBoolPref('block_cache', false);
+ } else {
+ doc.getElementById('torbutton_cacheGroup').selectedItem =
+ doc.getElementById('torbutton_blockCache');
+ o_torprefs.setBoolPref('block_cache', true);
+ o_torprefs.setBoolPref('clear_cache', false);
+ }
+
+ if(o_torprefs.getBoolPref('clear_cookies')) {
+ doc.getElementById('torbutton_cookieGroup').selectedItem =
+ doc.getElementById('torbutton_clearCookies');
+ o_torprefs.setBoolPref('cookie_jars', false);
+ } else {
+ doc.getElementById('torbutton_cookieGroup').selectedItem =
+ doc.getElementById('torbutton_cookieJars');
+ o_torprefs.setBoolPref('cookie_jars', true);
+ o_torprefs.setBoolPref('clear_cookies', false);
+ }
+
+ doc.getElementById('torbutton_blockTorHRead').checked = o_torprefs.getBoolPref('block_thread');
+ doc.getElementById('torbutton_blockTorHWrite').checked = o_torprefs.getBoolPref('block_thwrite');
+ doc.getElementById('torbutton_blockNonTorHRead').checked = o_torprefs.getBoolPref('block_nthread');
+ doc.getElementById('torbutton_blockNonTorHWrite').checked = o_torprefs.getBoolPref('block_nthwrite');
+ doc.getElementById('torbutton_noSearch').checked = o_torprefs.getBoolPref('no_search');
+ doc.getElementById('torbutton_noUpdates').checked = o_torprefs.getBoolPref('no_updates');
+
torbutton_prefs_set_field_attributes(doc);
}
@@ -180,13 +207,22 @@
}
// o_torprefs.setBoolPref('prompt_before_visiting_excluded_sites', doc.getElementById('torbutton_warnUponExcludedSite').checked);
- // XXX: work this in with recommended settigns stuff?
o_torprefs.setBoolPref('no_tor_plugins', doc.getElementById('torbutton_disablePlugins').checked);
o_torprefs.setBoolPref('clear_history', doc.getElementById('torbutton_clearHistory').checked);
- o_torprefs.setBoolPref('clear_cache', doc.getElementById('torbutton_clearCache').checked);
- o_torprefs.setBoolPref('clear_cookies', doc.getElementById('torbutton_clearCookies').checked);
o_torprefs.setBoolPref('kill_bad_js', doc.getElementById('torbutton_killBadJS').checked);
+ o_torprefs.setBoolPref('clear_cache', doc.getElementById('torbutton_clearCache').selected);
+ o_torprefs.setBoolPref('block_cache', doc.getElementById('torbutton_blockCache').selected);
+ o_torprefs.setBoolPref('clear_cookies', doc.getElementById('torbutton_clearCookies').selected);
+ o_torprefs.setBoolPref('cookie_jars', doc.getElementById('torbutton_cookieJars').selected);
+
+ o_torprefs.setBoolPref('block_thread', doc.getElementById('torbutton_blockTorHRead').checked);
+ o_torprefs.setBoolPref('block_thwrite', doc.getElementById('torbutton_blockTorHWrite').checked);
+ o_torprefs.setBoolPref('block_nthread', doc.getElementById('torbutton_blockNonTorHRead').checked);
+ o_torprefs.setBoolPref('block_nthwrite', doc.getElementById('torbutton_blockNonTorHWrite').checked);
+ o_torprefs.setBoolPref('no_search', doc.getElementById('torbutton_noSearch').checked);
+ o_torprefs.setBoolPref('no_updates', doc.getElementById('torbutton_noUpdates').checked);
+
// if tor settings were initially active, update the active settings to reflect any changes
if (tor_enabled) torbutton_activate_tor_settings();
}
Modified: torbutton/trunk/src/chrome/content/preferences.xul
===================================================================
--- torbutton/trunk/src/chrome/content/preferences.xul 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/preferences.xul 2007-06-15 07:59:46 UTC (rev 10610)
@@ -112,19 +112,67 @@
</groupbox>
<groupbox>
<caption label="&torbutton.prefs.sec_settings;"/>
+ <tabbox>
+ <tabs>
+ <tab label="&torbutton.prefs.js_plugins;"/>
+ <tab label="&torbutton.prefs.cookies;"/>
+ <tab label="&torbutton.prefs.cache;"/>
+ <tab label="&torbutton.prefs.history;"/>
+ </tabs>
+ <tabpanels>
+ <tabpanel id="plugins">
+ <vbox>
<checkbox id="torbutton_disablePlugins" label="&torbutton.prefs.disable_plugins;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
<checkbox id="torbutton_killBadJS" label="&torbutton.prefs.kill_bad_js;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
- <checkbox id="torbutton_clearCookies" label="&torbutton.prefs.clear_cookies;"
+ <checkbox id="torbutton_noUpdates" label="&torbutton.prefs.no_updates;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
- <checkbox id="torbutton_clearCache" label="&torbutton.prefs.clear_cache;"
+ <checkbox id="torbutton_noSearch" label="&torbutton.prefs.no_search;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
- <checkbox id="torbutton_clearHistory" label="&torbutton.prefs.clear_history;"
+ </vbox>
+ </tabpanel>
+ <tabpanel id="cookies">
+ <vbox>
+ <radiogroup id="torbutton_cookieGroup">
+ <radio id="torbutton_clearCookies"
+ label="&torbutton.prefs.clear_cookies;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/> <radio id="torbutton_cookieJars"
+ label="&torbutton.prefs.cookie_jars;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ </radiogroup>
+ </vbox>
+ </tabpanel>
+ <tabpanel id="cache">
+ <vbox>
+ <radiogroup id="torbutton_cacheGroup">
+ <radio id="torbutton_clearCache"
+ label="&torbutton.prefs.clear_cache;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <radio id="torbutton_blockCache"
+ label="&torbutton.prefs.block_cache;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ </radiogroup>
+ </vbox>
+ </tabpanel>
+ <tabpanel id="history">
+ <vbox>
+ <checkbox id="torbutton_blockTorHRead" label="&torbutton.prefs.block_thread;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <checkbox id="torbutton_blockTorHWrite" label="&torbutton.prefs.block_thwrite;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <checkbox id="torbutton_blockNonTorHRead" label="&torbutton.prefs.block_nthread;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <checkbox id="torbutton_blockNonTorHWrite" label="&torbutton.prefs.block_nthwrite;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <checkbox id="torbutton_clearHistory" label="&torbutton.prefs.clear_history;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ </vbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
</groupbox>
-
<!--
<checkbox id="torbutton_warnUponExcludedSite" label="&torbutton.prefs.prompt_before_visiting_excluded_sites;" />
<description>
Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/torbutton.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -1,3 +1,18 @@
+// XXX unresolved security issues:
+// - http://www.w3.org/TR/REC-CSS2/selector.html#dynamic-pseudo-classes
+// - Create an nsIContentPolicy based on tor tag state.
+// - can CSS create popups? a cached fetch may not go through content
+// policy, open an (untagged/safe tagged) window, and fetch some urls
+// - Clearing cache on tor state change blocks this, but worth
+// investigating
+// - http://meyerweb.com/eric/css/edge/popups/demo.html
+// - http://meyerweb.com/eric/css/edge/popups/demo2.html
+// - http://www.tjkdesign.com/articles/css%20pop%20ups/default.asp
+// - http://www.brunildo.org/test/CPop.html
+// - http://www.brunildo.org/test/cssPopMenus.html
+// - http://bucarotechelp.com/design/csseasy/97112700.asp
+//
+
// status
var m_wasinited = false;
var m_prefs = false; // FIXME: make into singleton with rest of cached globals?
@@ -157,15 +172,16 @@
.addEventListener('DOMNodeInserted', torbutton_init_toolbutton, false);
}
- if (!m_wasinited) {
+ if (!m_wasinited) {
+ // Runs every time a new window is opened
m_prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
- torbutton_init_pluginbutton();
torbutton_init_jshooks();
torbutton_log(5, 'registering pref observer');
- torbutton_pref_observer.register();
+ // XXX: Hrmm... Do we really need a pref observer for each window?
+ torbutton_pref_observer.register();
m_wasinited = true;
} else {
torbutton_log(5, 'skipping pref observer init');
@@ -327,12 +343,9 @@
if (torbutton_check_socks_remote_dns())
liveprefs.setBoolPref('socks_remote_dns', savprefs.getBoolPref('socks_remote_dns'));
- // XXX: hrmm..
+ // FIXME: hrmm..
var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
- if(torprefs.getBoolPref("no_tor_plugins")) {
- torprefs.setBoolPref("allow_plugins", true);
- }
}
function torbutton_disable_tor()
@@ -351,9 +364,9 @@
function torbutton_update_toolbutton(mode)
{
+ // XXX: These are globals... elsewhere too
o_toolbutton = torbutton_get_toolbutton();
if (!o_toolbutton) return;
- // XXX: This is a global... elsewhere too
o_stringbundle = torbutton_get_stringbundle();
if (mode) {
@@ -398,15 +411,46 @@
var label;
var tooltip;
-
var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
+ var changed = (torprefs.getBoolPref('tor_enabled') != mode);
torprefs.setBoolPref('tor_enabled', mode);
torbutton_log(2, 'called update_status('+mode+')');
torbutton_update_toolbutton(mode);
torbutton_update_statusbar(mode);
- torbutton_update_plugin_status(!mode);
+ // this function is called every time there is a new window! Alot of this
+ // stuff expects to be called on toggle only.. like the cookie jars and
+ // history/cookie clearing
+ if(!changed) return;
+
+ // XXX: store user settings for these groups
+ // - never enable them if user wants them off.
+ if (torprefs.getBoolPref("no_updates")) {
+ m_prefs.setBoolPref("extensions.update.enabled", !mode);
+ m_prefs.setBoolPref("app.update.enabled", !mode);
+ m_prefs.setBoolPref("app.update.auto", !mode);
+ m_prefs.setBoolPref("browser.search.update", !mode);
+ }
+
+ if (torprefs.getBoolPref('block_cache')) {
+ m_prefs.setBoolPref("browser.cache.memory.enable", !mode);
+ m_prefs.setBoolPref("browser.cache.disk.enable", !mode);
+ m_prefs.setBoolPref("network.http.use-cache", !mode);
+ }
+
+ if (torprefs.getBoolPref("no_search")) {
+ m_prefs.setBoolPref("browser.search.suggest.enabled", !mode);
+ }
+
+ if(torprefs.getBoolPref("no_tor_plugins")) {
+ m_prefs.setBoolPref("security.enable_java", !mode);
+ }
+
+ torbutton_toggle_jsplugins(!mode,
+ torprefs.getBoolPref("kill_bad_js"),
+ torprefs.getBoolPref("no_tor_plugins"));
+
// TODO: Investigate Firefox privacy clear-data settings..
// Form data, download history, passwords?
// Can these items be excluded from being recorded during tor usage?
@@ -414,26 +458,18 @@
ClearHistory();
}
- // XXX: Offer option of cookie jars vs clearing cookies
- // Clearing cookies should be the default (Fuck cookies ;)
if (torprefs.getBoolPref('clear_cookies')) {
- ClearCookies(mode);
+ ClearCookies();
+ } else if (torprefs.getBoolPref('jar_cookies')) {
+ JarCookies(mode);
}
- /* XXX: Offer option for this? Ugh, so many options..
-19:09 < coderman> mikeperry : to disable CSS history hacks and such (regarding
- browser cache) i had to set browser.cache.memory.enable off,
- browser.cache.disk.enable off , and network.http.use-cache
- off. as for clearing at switch, or leaving off, i don't
- know. depends on what you're doing i suppose...
-
- */
-
if (torprefs.getBoolPref('clear_cache')) {
var cache = Components.classes["@mozilla.org/network/cache-service;1"].
getService(Components.interfaces.nsICacheService);
cache.evictEntries(0);
}
+
}
function torbutton_open_prefs_dialog() {
@@ -555,15 +591,15 @@
hist.removeAllPages();
}
-function ClearCookies(mode) {
+function ClearCookies() {
torbutton_log(2, 'called ClearCookies');
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager);
-
- // XXX: Check pref to fully clear or not
- //cm.removeAll();
+ cm.removeAll();
+}
+function JarCookies(mode) {
var selector =
Components.classes["@stanford.edu/cookie-jar-selector;1"]
.getService(Components.interfaces.nsISupports)
@@ -581,89 +617,65 @@
// -------------- JS/PLUGIN HANDLING CODE ---------------------
-function TagDocshellForJS(browser, allowed) {
+function CheckDocshellTagForJS(browser, allowed, js_enabled) {
if (typeof(browser.__tb_js_state) == 'undefined') {
torbutton_log(5, "UNTAGGED WINDOW!!!!!!!!!");
}
- if(browser.__tb_js_state == allowed) {
- // States match, js ok
- browser.docShell.allowJavascript =
- m_prefs.getBoolPref("javascript.enabled");
- } else {
+ if(browser.__tb_js_state == allowed) { // States match, js ok
+ browser.docShell.allowJavascript = js_enabled;
+ } else { // States differ or undefined, js not ok
// XXX: hrmm.. way to check for navigator windows?
// non-navigator windows are not tagged..
- // States differ or undefined, js not ok
browser.docShell.allowJavascript = false;
}
}
-function torbutton_allow_win_jsplugins(win, allowed) {
+function torbutton_toggle_win_jsplugins(win, allowed, js_enabled, kill_js,
+ kill_plugins) {
var browser = win.getBrowser();
- browser.docShell.allowPlugins = allowed;
- TagDocshellForJS(browser, allowed);
+ if(kill_js) CheckDocshellTagForJS(browser, allowed, js_enabled);
+ if(kill_plugins) browser.docShell.allowPlugins = allowed;
var browsers = browser.browsers;
for (var i = 0; i < browsers.length; ++i) {
var b = browser.browsers[i];
if (b) {
- b.docShell.allowPlugins = allowed;
+ if(kill_plugins) b.docShell.allowPlugins = allowed;
+ if(kill_js) CheckDocshellTagForJS(b, allowed, js_enabled);
+ // kill meta-refresh and existing page loading
b.webNavigation.stop(b.webNavigation.STOP_ALL);
- TagDocshellForJS(b, allowed);
}
}
}
// This is an ugly beast.. But unfortunately it has to be so..
// Looping over all tabs twice is not somethign we wanna do..
-function torbutton_allow_jsplugins(allowed) {
+function torbutton_toggle_jsplugins(allowed, kill_js, kill_plugins) {
torbutton_log(1, "Plugins: "+allowed);
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
+ var js_enabled = m_prefs.getBoolPref("javascript.enabled");
var enumerator = wm.getEnumerator("navigator:browser");
while(enumerator.hasMoreElements()) {
var win = enumerator.getNext();
- torbutton_allow_win_jsplugins(win, allowed);
+ torbutton_toggle_win_jsplugins(win, allowed, js_enabled, kill_js,
+ kill_plugins);
}
}
-function torbutton_init_pluginbutton() {
- torbutton_update_plugin_status(!torbutton_check_status());
-}
+function TagNewBrowser(browser, tor_tag, no_plugins) {
+ if (!tor_tag && no_plugins) {
+ browser.docShell.allowPlugins = tor_tag;
+ }
-
-function torbutton_update_plugin_status(nMode) {
- torbutton_log(2, 'called update_plugin_status('+nMode+')');
- if (!window.statusbar.visible)
- return;
- torbutton_log(2, 'visible statusbar: ('+nMode+')');
- var o_stringbundle = torbutton_get_stringbundle();
- var override = !m_prefs.getBoolPref("extensions.torbutton.no_tor_plugins");
- var tooltip;
-
- if(override) nMode = true;
-
- if(nMode) {
- tooltip = o_stringbundle.GetStringFromName("torbutton.panel.plugins.enabled");
- } else {
- tooltip = o_stringbundle.GetStringFromName("torbutton.panel.plugins.disabled");
+ // Only tag new windows
+ if (typeof(browser.__tb_js_state) == 'undefined') {
+ browser.__tb_js_state = tor_tag;
}
-
- // FIXME: hrmm.. consider caching this value
- document.getElementById("plugins-status").setAttribute("status", nMode ? "1" : "0");
- document.getElementById("plugins-status").setAttribute('tooltiptext', tooltip);
-
- if(override) return;
-
- // XXX: Don't set these to true if user had it off to begin with!
- m_prefs.setBoolPref("security.enable_java", nMode);
- m_prefs.setBoolPref("extensions.update.enabled", nMode);
-
- // FIXME: Allow option to kill all JS during tor usage.
- torbutton_allow_jsplugins(nMode);
}
// ---------------------- Event handlers -----------------
@@ -672,37 +684,32 @@
{
// listening for new tabs
torbutton_log(1, "New tab");
+ var tor_tag = !m_prefs.getBoolPref("extensions.torbutton.tor_enabled");
+ var no_plugins = m_prefs.getBoolPref("extensions.torbutton.no_tor_plugins");
+ var browser = event.currentTarget;
+ TagNewBrowser(browser, tor_tag, no_plugins);
+
// Fucking garbage.. event is delivered to the current tab, not the
// newly created one. Need to traverse the current window for it.
- if(m_prefs.getBoolPref("extensions.torbutton.tor_enabled")
- && m_prefs.getBoolPref("extensions.torbutton.no_tor_plugins")) {
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var browserWindow = wm.getMostRecentWindow("navigator:browser");
- torbutton_allow_win_jsplugins(browserWindow, false);
+ for (var i = 0; i < browser.browsers.length; ++i) {
+ TagNewBrowser(browser.browsers[i], tor_tag, no_plugins);
}
}
-// XXX: Does this get the first window?
function NewWindowEvent(event)
{
torbutton_log(1, "New window");
+ var browser = getBrowser();
if (!m_wasinited) {
torbutton_init();
}
- if (torbutton_check_status()) {
- if(m_prefs.getBoolPref("extensions.torbutton.no_tor_plugins")) {
- getBrowser().docShell.allowPlugins = false;
- }
- TagDocshellForJS(getBrowser(), false, false);
- } else {
- TagDocshellForJS(getBrowser(), true, true);
- }
+ TagNewBrowser(browser,
+ !m_prefs.getBoolPref("extensions.torbutton.tor_enabled"),
+ m_prefs.getBoolPref("extensions.torbutton.no_tor_plugins"));
-
- getBrowser().addProgressListener(myListener,
+ browser.addProgressListener(myListener,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT|
Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
}
@@ -735,7 +742,7 @@
return null;
}
-function hookDoc(win, doc) {
+function hookDoc(doc) {
torbutton_log(1, "Hooking document");
if(doc.doctype) {
torbutton_log(1, "Hooking document: "+doc.doctype.name);
@@ -744,10 +751,10 @@
torbutton_init();
}
- if(typeof(win.__tb_did_hook) != 'undefined')
+ if(typeof(doc.__tb_did_hook) != 'undefined')
return; // Ran already
- win.__tb_did_hook = true;
+ doc.__tb_did_hook = true;
torbutton_log(1, "JS to be set to: " +m_prefs.getBoolPref("javascript.enabled"));
var browser = getBrowser();
@@ -824,7 +831,7 @@
if(aProgress) {
torbutton_log(1, "location progress");
var doc = aProgress.DOMWindow.document;
- if(doc) hookDoc(aProgress.DOMWindow, doc);
+ if(doc) hookDoc(doc);
else torbutton_log(3, "No DOM at location event!");
} else {
torbutton_log(3, "No aProgress for location!");
Modified: torbutton/trunk/src/chrome/content/torbutton.xul
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.xul 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/torbutton.xul 2007-06-15 07:59:46 UTC (rev 10610)
@@ -43,6 +43,6 @@
onclick="if (event.button == 0) torbutton_toggle()"/>
<popup id="torbutton-context-menu"/>
- <statusbarpanel context="clipmenu" class="statusbarpanel-iconic" id="plugins-status" tooltip="plugin-tooltip" onclick="torbutton_toggle_plugins();"/>
+<!-- <statusbarpanel context="clipmenu" class="statusbarpanel-iconic" id="plugins-status" tooltip="plugin-tooltip" onclick="torbutton_toggle_plugins();"/> -->
</statusbar>
</overlay>
Modified: torbutton/trunk/src/chrome/content/torbutton_util.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton_util.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/content/torbutton_util.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -120,12 +120,5 @@
liveprefs.setBoolPref('socks_remote_dns', true);
}
liveprefs.setIntPref('type', 1);
-
- // XXX: hrmm.. This seems awfully inefficient
- var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
-
- if(torprefs.getBoolPref("no_tor_plugins")) {
- torprefs.setBoolPref("allow_plugins", false);
- }
}
Modified: torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd
===================================================================
--- torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd 2007-06-15 07:59:46 UTC (rev 10610)
@@ -14,12 +14,24 @@
<!ENTITY torbutton.prefs.proxy.host.gopher "Gopher Proxy:">
<!ENTITY torbutton.prefs.proxy.host.socks "SOCKS Host:">
<!ENTITY torbutton.prefs.proxy.port "Port:">
-<!ENTITY torbutton.prefs.sec_settings "Security Settings">
-<!ENTITY torbutton.prefs.clear_history "Clear history on Tor toggle (optional)">
-<!ENTITY torbutton.prefs.clear_cache "Clear cache on Tor toggle (recommended)">
-<!ENTITY torbutton.prefs.clear_cookies "Clear cookies on Tor toggle (recommended)">
-<!ENTITY torbutton.prefs.disable_plugins "Disable plugins during Tor usage (recommended)">
-<!ENTITY torbutton.prefs.kill_bad_js "Block dangerous javascript (recommended)">
+<!ENTITY torbutton.prefs.sec_settings "Security Settings">
+<!ENTITY torbutton.prefs.block_thread "Block history read during Tor (recomended)">
+<!ENTITY torbutton.prefs.block_thwrite "Block history write during Tor (recomended)">
+<!ENTITY torbutton.prefs.block_nthread "Block history read during Non-Tor (optional)">
+<!ENTITY torbutton.prefs.block_nthwrite "Block history write during Non-Tor (optional)">
+<!ENTITY torbutton.prefs.clear_history "Clear history on Tor toggle (optional)">
+<!ENTITY torbutton.prefs.clear_cache "Clear cache on Tor toggle">
+<!ENTITY torbutton.prefs.block_cache "Block cache during Tor">
+<!ENTITY torbutton.prefs.cookie_jars "Store Non-Tor cookies in a protected jar">
+<!ENTITY torbutton.prefs.clear_cookies "Clear cookies on Tor toggle">
+<!ENTITY torbutton.prefs.disable_plugins "Disable plugins during Tor usage (recommended)">
+<!ENTITY torbutton.prefs.kill_bad_js "Block dangerous javascript (recommended)">
+<!ENTITY torbutton.prefs.no_updates "Disable updates during Tor usage (recommended)">
+<!ENTITY torbutton.prefs.js_plugins "Plugins+javascript">
+<!ENTITY torbutton.prefs.cookies "Cookies">
+<!ENTITY torbutton.prefs.cache "Cache">
+<!ENTITY torbutton.prefs.history "History">
+<!ENTITY torbutton.prefs.no_search "Disable search suggestions (optional)">
<!ENTITY torbutton.about.title "About Torbutton">
<!ENTITY torbutton.pref_connection.notice "Disable Torbutton to change these settings.">
<!ENTITY torbutton.pref_connection.more_info "More information">
Modified: torbutton/trunk/src/components/ignore-history.js
===================================================================
--- torbutton/trunk/src/components/ignore-history.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/components/ignore-history.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -5,7 +5,7 @@
* queries and sometimes ignores addURI commands.
* Designed as a component of FoxTor, http://cups.cs.cmu.edu/foxtor/
* Copyright 2006, distributed under the same (open source) license as FoxTor
- * - XXX: ??? Which license is this? Unspecified on website/src!
+ * - XXX: ??? Which license is this? Unspecified on website/src
*
* Contributor(s):
* Collin Jackson <mozilla at collinjackson.com>
@@ -13,8 +13,6 @@
*************************************************************************/
// Module specific constants
-const kTORBUTTON_STATUS_PREF = "extensions.torbutton.tor_enabled";
-const kSTATUS_THRESHOLD = 300; // ignore history if status >= threshold
const kMODULE_NAME = "Ignore History";
const kMODULE_CONTRACTID = "@mozilla.org/browser/global-history;2";
const kMODULE_CID = Components.ID("bc666d45-a9a1-4096-9511-f6db6f686881");
@@ -25,6 +23,9 @@
const kHistoryInterfaces = [ "nsIBrowserHistory", "nsIGlobalHistory2" ];
function HistoryWrapper() {
+ this._prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
+
this._history = function() {
var history = kREAL_HISTORY.getService();
for (var i = 0; i < kHistoryInterfaces.length; i++) {
@@ -50,12 +51,23 @@
/*
* Determine whether we should hide visited links
*/
- getIgnoreHistoryPref: function() {
- return Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch)
- .getBoolPref(kTORBUTTON_STATUS_PREF);
+ blockReadHistory: function() {
+ return ((this._prefs.getBoolPref("extensions.torbutton.block_thread")
+ && this._prefs.getBoolPref("extensions.torbutton.tor_enabled"))
+ ||
+ (this._prefs.getBoolPref("extensions.torbutton.block_nthread")
+ && !this._prefs.getBoolPref("extensions.torbutton.tor_enabled")));
},
+ blockWriteHistory: function() {
+ return ((this._prefs.getBoolPref("extensions.torbutton.block_thwrite")
+ && this._prefs.getBoolPref("extensions.torbutton.tor_enabled"))
+ ||
+ (this._prefs.getBoolPref("extensions.torbutton.block_nthwrite")
+ && !this._prefs.getBoolPref("extensions.torbutton.tor_enabled")));
+ },
+
+
/*
* Copies methods from the true history object we are wrapping
*/
@@ -74,7 +86,7 @@
* Maybe lie about whether link was visited
*/
isVisited: function(aURI) {
- return (!this.getIgnoreHistoryPref() &&
+ return (!this.blockReadHistory() &&
this._history().isVisited(aURI));
},
@@ -82,8 +94,7 @@
* Maybe add the URI to the history
*/
addURI: function(aURI, redirect, toplevel, referrer) {
- // XXX: make it possible to make history writeonly.
- if(!this.getIgnoreHistoryPref())
+ if(!this.blockWriteHistory())
this._history().addURI(aURI, redirect, toplevel, referrer);
},
@@ -91,7 +102,7 @@
* Maybe set the title of a URI in the history
*/
setPageTitle: function(URI, title) {
- if(!this.getIgnoreHistoryPref())
+ if(!this.blockWriteHistory())
this._history().setPageTitle(URI, title);
},
@@ -126,7 +137,6 @@
var HistoryWrapperModule = new Object();
-// XXX: Interesting.. Can we more easily override Date this way?
HistoryWrapperModule.registerSelf =
function (compMgr, fileSpec, location, type){
var nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
Modified: torbutton/trunk/src/defaults/preferences/preferences.js
===================================================================
--- torbutton/trunk/src/defaults/preferences/preferences.js 2007-06-15 06:01:04 UTC (rev 10609)
+++ torbutton/trunk/src/defaults/preferences/preferences.js 2007-06-15 07:59:46 UTC (rev 10610)
@@ -41,7 +41,14 @@
pref("extensions.torbutton.tor_enabled",false);
pref("extensions.torbutton.no_tor_plugins",true);
pref("extensions.torbutton.clear_cookies",true);
+pref("extensions.torbutton.cookie_jars",false);
pref("extensions.torbutton.clear_cache",true);
+pref("extensions.torbutton.block_cache",false);
pref("extensions.torbutton.clear_history",false);
pref("extensions.torbutton.kill_bad_js",true);
-
+pref("extensions.torbutton.block_thread",true);
+pref("extensions.torbutton.block_thwrite",true);
+pref("extensions.torbutton.block_nthread",true);
+pref("extensions.torbutton.block_nthwrite",false);
+pref("extensions.torbutton.no_updates",true);
+pref("extensions.torbutton.no_search",true);
More information about the tor-commits
mailing list