[tor-commits] [torbutton/master] Remove toggle-on-startup and crash detection code.
mikeperry at torproject.org
mikeperry at torproject.org
Thu Feb 14 06:09:25 UTC 2013
commit dbe7b143eeb9c3d181f329a2dd312ee6065ae433
Author: Mike Perry <mikeperry-git at fscked.org>
Date: Tue Feb 5 16:13:47 2013 -0800
Remove toggle-on-startup and crash detection code.
---
src/chrome/content/preferences.js | 13 --
src/chrome/content/torbutton.js | 282 +------------------------------
src/components/crash-observer.js | 22 ---
src/defaults/preferences/preferences.js | 6 -
4 files changed, 3 insertions(+), 320 deletions(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index e8f6f27..131c2a6 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -280,14 +280,6 @@ function torbutton_prefs_init(doc) {
= doc.getElementById('torbutton_allShutdown');
}
- if(o_torprefs.getBoolPref('restore_tor')) {
- doc.getElementById('torbutton_restoreTorGroup').selectedItem =
- doc.getElementById('torbutton_restoreTor');
- } else {
- doc.getElementById('torbutton_restoreTorGroup').selectedItem =
- doc.getElementById('torbutton_restoreNonTor');
- }
-
/*
switch(o_torprefs.getIntPref('startup_state')) {
case 0: // non-tor
@@ -537,10 +529,6 @@ function torbutton_prefs_save(doc) {
}
- o_torprefs.setBoolPref('restore_tor',
- doc.getElementById('torbutton_restoreTorGroup').selectedItem ==
- doc.getElementById('torbutton_restoreTor'));
-
/*
if(doc.getElementById('torbutton_startupStateGroup').selectedItem ==
doc.getElementById('torbutton_startNonTor')) {
@@ -727,7 +715,6 @@ function torbutton_prefs_reset_defaults() {
torbutton_reset_browser_prefs();
chrome.torbutton_init_prefs();
- chrome.torbutton_do_fresh_install();
torbutton_log(3, "Prefs reset");
if(was_enabled) {
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index c924eff..f3c098f 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -11,7 +11,6 @@
var m_tb_wasinited = false;
var m_tb_prefs = false;
var m_tb_jshooks = false;
-var m_tb_plugin_mimetypes = false;
var m_tb_plugin_string = false;
var m_tb_is_main_window = false;
var m_tb_hidden_browser = false;
@@ -2860,87 +2859,6 @@ function torbutton_reload_homepage() {
gBrowser.loadURI(homepage, null, null);
}
-// Bug 1506 P0: There are no states, only Tor.
-function torbutton_set_launch_state(state, session_restore) {
- if (!m_tb_wasinited) torbutton_init();
- var no_plugins = m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins");
-
- torbutton_log(3, "Conditional set");
-
- // Need to set the tag on all tabs, some of them can be mis-set when
- // the first window is created (before session restore)
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var enumerator = wm.getEnumerator("navigator:browser");
- var js_enabled = m_tb_prefs.getBoolPref("javascript.enabled");
- while(enumerator.hasMoreElements()) {
- var win = enumerator.getNext();
- var browser = win.getBrowser();
- if(!browser) {
- // XXX: Could add a location here..
- torbutton_log(5, "No browser for plugin window in set_launch_state.");
- continue;
- }
- var browsers = browser.browsers;
-
- for (var i = 0; i < browsers.length; ++i) {
- var b = browser.browsers[i];
-
- if (state) {
- if(b && b.docShell){
- if(no_plugins && !m_tb_tbb) b.docShell.allowPlugins = false;
- if(m_tb_ff35) {
- if (!m_tb_ff36) /* Unified with nsIDocShell in 3.6 */
- b.docShell.QueryInterface(Ci.nsIDocShell_MOZILLA_1_9_1_dns);
- b.docShell.allowDNSPrefetch = false;
- }
- } else {
- try {
- if (b && b.currentURI)
- torbutton_log(5, "Initial docShell is null for: "+b.currentURI.spec);
- else
- torbutton_log(5, "Initial docShell is null for unknown URL");
- } catch(e) {
- torbutton_log(5, "Initial docShell is null for unparsable URL: "+e);
- }
- }
- }
- }
- }
-
-
- if (torbutton_check_status() == state) {
- // Do a quick toggle if tor is always enabled to ensure we update prefs properly
- // in the event of an upgrade, offline proxy change, etc
- if (state) {
- torbutton_disable_tor();
- torbutton_enable_tor(true);
- torbutton_log(3, "Tor state updated.");
-
- torbutton_do_async_versioncheck();
-
- // Load our homepage again. We just killed it via the toggle.
- if (!session_restore) {
- torbutton_reload_homepage();
- }
- } else {
- torbutton_log(3, "Leaving tor disabled");
- }
- } else {
- torbutton_log(4, "Restoring proper tor state");
-
- if(state) torbutton_enable_tor(true);
- else torbutton_disable_tor();
-
- torbutton_do_async_versioncheck();
-
- // Load our homepage again. We just killed it via the toggle.
- if (!session_restore) {
- torbutton_reload_homepage();
- }
- }
-}
-
// Bug 1506 P0: Toggle, kill it.
function torbutton_restore_cookies(tor_enabled)
{
@@ -2965,92 +2883,6 @@ function torbutton_restore_cookies(tor_enabled)
}
}
-// Bug 1506 P0: We only care about crashes in a toggle world. Kill this.
-function torbutton_crash_recover()
-{
- if (!m_tb_wasinited) torbutton_init();
- torbutton_log(3, "Crash recover check");
-
- // Crash detection code (works w/ components/crash-observer.js)
- if(m_tb_prefs.getBoolPref("extensions.torbutton.crashed")) {
- torbutton_log(4, "Crash detected, attempting recovery");
-
- /* These prefs get set in this order during toggle: */
- /* extentions.torbutton.saved.* */
- var te = m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled");
- var state = torbutton_check_status();
- var pa = m_tb_prefs.getBoolPref("extensions.torbutton.proxies_applied");
- var sa = m_tb_prefs.getBoolPref("extensions.torbutton.settings_applied");
-
- // TODO: This might not properly preserve a user's settings if
- // Firefox crashes on the very *first* toggle they ever do,
- // but it should at least not break in that case either.
- if(state != te || state != pa || state != sa) {
- if (state != te && state != pa && state != sa) {
- // redo the whole toggle from the top
- torbutton_log(4, "Crash state conflict: "+state+","
- +te+","+pa+","+sa);
-
- if (te) {
- torbutton_activate_tor_settings();
- } else {
- torbutton_activate_nontor_settings();
- }
- } else if (state == te && state != pa && state != sa) {
- // redo the whole toggle from the top
- torbutton_log(4, "Crash state conflict: "+state+","
- +te+","+pa+","+sa);
- // Update_status did not run at all..
- torbutton_update_status(state, true);
- } else if (state == te && state == pa && state != sa) {
- // Tor->Non-Tor is safe to redo, so long as first_toggle is
- // false..
- // However, Non-Tor->Tor needs to first perform Tor->Non-Tor
- // and then retry
- if (state) {
- torbutton_restore_cookies(true); // Restore Tor cookies
- torbutton_update_status(false, true); // Toggle into Non-Tor
- torbutton_update_status(true, true); // Toggle into Tor
- } else {
- torbutton_restore_cookies(true); // Restore Tor cookies
- torbutton_update_status(false, true); // Toggle into Non-Tor
- }
- } else {
- window.alert("Torbutton crash state conflict! Please file bug report with these four values: "
- +state+","+te+","+pa+","+sa);
- torbutton_log(5, "Crash state conflict: "+state+","
- +te+","+pa+","+sa);
- }
- } else {
- // 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
- // currently loaded before the switch writes out a new jar
- if(m_tb_prefs.getBoolPref("extensions.torbutton.reload_crashed_jar"))
- torbutton_restore_cookies(state);
- }
-
- 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);
-
- if(m_tb_prefs.getBoolPref("extensions.torbutton.restore_tor"))
- torbutton_set_launch_state(true, !m_tb_prefs.getBoolPref("extensions.torbutton.notor_sessionstore"));
- else
- torbutton_set_launch_state(false, !m_tb_prefs.getBoolPref("extensions.torbutton.nonontor_sessionstore"));
-
- m_tb_prefs.setBoolPref("extensions.torbutton.crashed", false);
-
- // Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
- }
-
- torbutton_log(3, "End crash recover check");
-}
-
-
// ---------------------- Event handlers -----------------
// Bug 1506 P1/P3: This removes any platform-specific junk
@@ -3125,56 +2957,6 @@ function torbutton_do_main_window_startup()
SSC_startup();
}
-// Bug 1506 P0: We should always start with Tor enabled based on
-// prefs.js. We probably don't need this code to enforce it.
-function torbutton_set_initial_state() {
- if(m_tb_prefs.getBoolPref("extensions.torbutton.noncrashed")) {
- var restore_tor = m_tb_prefs.getBoolPref("extensions.torbutton.restore_tor");
-
- torbutton_log(3, "Setting initial tor state to: "+restore_tor);
-
- torbutton_set_launch_state(restore_tor, false);
-
- m_tb_prefs.setBoolPref("extensions.torbutton.noncrashed", false);
-
- // Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
- }
-}
-
-// Bug 1506 P1: This is a relic of the need to sync up user prefs to
-// tor prefs. See #3100 for a more generalized approach
-function torbutton_do_fresh_install()
-{
- if(m_tb_prefs.getBoolPref("extensions.torbutton.fresh_install")) {
- if(!m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
- // Make our cookie prefs more closely match the user's
- // so we don't change people's settings on install.
- if(m_tb_prefs.getIntPref("network.cookie.lifetimePolicy") == 2) {
- m_tb_prefs.setBoolPref("extensions.torbutton.nontor_memory_jar",
- true);
- }
- // perform updates in ff3 if the user's non-tor prefs allow it
- if(m_tb_ff3 && m_tb_prefs.getBoolPref("app.update.auto")
- && m_tb_prefs.getBoolPref("extensions.update.enabled")) {
- m_tb_prefs.setBoolPref("extensions.torbutton.no_updates", false);
- }
- } else {
- // Punt. Allow updates via Tor now.
- if(m_tb_ff3) {
- // Perform updates if FF3. They are secure now.
- m_tb_prefs.setBoolPref("extensions.torbutton.no_updates", false);
- }
- }
-
- m_tb_prefs.setBoolPref("extensions.torbutton.fresh_install", false);
-
- torbutton_log(4, "First time startup completed");
- }
-}
-
// Bug 1506 P4: Most of this function is now useless, save
// for the very important SOCKS environment vars at the end.
// Those could probably be rolled into a function with the
@@ -3182,55 +2964,17 @@ function torbutton_do_fresh_install()
function torbutton_do_startup()
{
if(m_tb_prefs.getBoolPref("extensions.torbutton.startup")) {
- // Do this before the unique pref observer is registered
- // in torbutton_do_main_window_startup to avoid
- // popup notification.
- torbutton_do_fresh_install();
-
- // The cookie protections pref was added recently, and we would like
- // it to be the new default. We must update the older prefs to match
- // if it is set, to handle upgrade inconsistencies.
- //
- // We do this before the pref observers get registered to avoid
- // popups and non-tor policy changes.
- if (m_tb_prefs.getBoolPref('extensions.torbutton.cookie_protections')) {
- m_tb_prefs.setBoolPref('extensions.torbutton.cookie_jars', false);
- m_tb_prefs.setBoolPref('extensions.torbutton.dual_cookie_jars', true);
- m_tb_prefs.setBoolPref('extensions.torbutton.clear_cookies', false);
- }
-
// Bug 1506: Should probably be moved to an XPCOM component
torbutton_do_main_window_startup();
- // This is due to Bug 908: UserAgent Switcher is resetting
- // the user agent at startup to default
- if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
- && m_tb_prefs.getBoolPref("extensions.torbutton.set_uagent")) {
- torbutton_set_uagent();
- }
- var tor_enabled = torbutton_check_status();
-
// Bug 1506: Still want to do this
torbutton_set_timezone(tor_enabled, true);
- // FIXME: This is probably better done by reimplementing the
- // component.
- if(m_tb_prefs.getBoolPref("extensions.torbutton.block_remoting")) {
- var appSupport = Cc["@mozilla.org/toolkit/native-app-support;1"]
- .getService(Ci.nsINativeAppSupport);
- if(!appSupport.stop()) {
- torbutton_log(5, "Remoting stop() failed. Forcing quit");
- // We really want this thing gone.
- appSupport.quit();
- } else {
- torbutton_log(3, "Remoting window closed.");
- }
- }
-
// Bug 1506: Still want to do this
- torbutton_toggle_plugins(tor_enabled
- && m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins"));
+ torbutton_toggle_plugins(tor_enabled &&
+ m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins"));
+ // Still need this in case people shove this thing back into FF
if (!m_tb_tbb && m_tb_prefs.getBoolPref("extensions.torbutton.prompt_torbrowser")) {
var o_stringbundle = torbutton_get_stringbundle();
var warning = o_stringbundle.GetStringFromName("torbutton.popup.short_torbrowser");
@@ -3243,22 +2987,6 @@ function torbutton_do_startup()
}
}
-// Bug 1506 P0: Old way of blocking plugins. Kill it
-function torbutton_get_plugin_mimetypes()
-{
- m_tb_plugin_mimetypes = { null : null };
- var plugin_list = [];
- for(var i = 0; i < window.navigator.mimeTypes.length; ++i) {
- var mime = window.navigator.mimeTypes.item(i);
- if(mime && mime.enabledPlugin) {
- m_tb_plugin_mimetypes[mime.type] = true;
- plugin_list.push(mime.type);
- }
- }
- m_tb_plugin_string = plugin_list.join();
-}
-
-
// Bug 1506 P0: Has some tagging code (can be removed)
// and the language prompt (probably the wrong place for the
// call)
@@ -3393,10 +3121,6 @@ function torbutton_new_window(event)
browser.tabContainer.addEventListener("TabOpen", torbutton_new_tab, false);
torbutton_do_startup();
- torbutton_crash_recover();
- torbutton_set_initial_state();
-
- torbutton_get_plugin_mimetypes();
torbutton_set_window_size(browser.contentWindow);
diff --git a/src/components/crash-observer.js b/src/components/crash-observer.js
index 5ecac6a..89b0f49 100644
--- a/src/components/crash-observer.js
+++ b/src/components/crash-observer.js
@@ -5,9 +5,6 @@
/*************************************************************************
* Crash observer (JavaScript XPCOM component)
*
- * Provides the chrome with a notification ("extensions.torbutton.crashed"
- * pref event) that the browser in fact crashed.
- *
* Cases tested (each during Tor and Non-Tor, FF4 and FF3.6)
* 1. Crash
* 2. Upgrade
@@ -163,16 +160,7 @@ CrashObserver.prototype = {
if(topic == "profile-after-change") {
// Bug 1506 P1: We listen to these prefs as signals for startup,
// but only for hackish reasons.
- if(this._prefs.getBoolPref("extensions.torbutton.fresh_install")) {
- this._prefs.setBoolPref("extensions.torbutton.normal_exit", true);
- }
this._prefs.setBoolPref("extensions.torbutton.startup", true);
- if (this._prefs.getBoolPref("extensions.torbutton.normal_exit")) {
- this._prefs.setBoolPref("extensions.torbutton.noncrashed", true);
- } else {
- this._prefs.setBoolPref("extensions.torbutton.crashed", true);
- }
- this._prefs.setBoolPref("extensions.torbutton.normal_exit", false);
this.getProxySettings();
} else if (topic == "em-action-requested") {
@@ -213,16 +201,6 @@ CrashObserver.prototype = {
}
}
- // Remove the cookie observer so clearing cookies below does not
- // issue a new request.
- if (chrome) chrome.torbutton_cookie_observer.unregister();
-
- // Set pref in case this is just an upgrade (So we don't
- // mess with cookies)
- this._prefs.setBoolPref("extensions.torbutton.normal_exit", true);
- this._prefs.setBoolPref("extensions.torbutton.crashed", false);
- this._prefs.setBoolPref("extensions.torbutton.noncrashed", false);
-
if((this._prefs.getIntPref("extensions.torbutton.shutdown_method") == 1 &&
this._prefs.getBoolPref("extensions.torbutton.tor_enabled"))
|| this._prefs.getIntPref("extensions.torbutton.shutdown_method") == 2) {
diff --git a/src/defaults/preferences/preferences.js b/src/defaults/preferences/preferences.js
index de15e0e..4fb1d9e 100644
--- a/src/defaults/preferences/preferences.js
+++ b/src/defaults/preferences/preferences.js
@@ -104,13 +104,9 @@ pref("extensions.torbutton.tor_enabled",false);
pref("extensions.torbutton.proxies_applied",false);
pref("extensions.torbutton.settings_applied",false);
pref("extensions.torbutton.startup",false);
-pref("extensions.torbutton.crashed",false);
-pref("extensions.torbutton.noncrashed",false);
pref("extensions.torbutton.block_cert_dialogs",false);
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);
pref("extensions.torbutton.inserted_button",false);
pref("extensions.torbutton.prompted_language",false);
@@ -136,7 +132,6 @@ pref("extensions.torbutton.no_search",true);
pref("extensions.torbutton.set_uagent",true);
pref("extensions.torbutton.notor_sessionstore",true);
pref("extensions.torbutton.nonontor_sessionstore",false);
-pref("extensions.torbutton.restore_tor",true);
pref("extensions.torbutton.reload_crashed_jar",true);
pref("extensions.torbutton.spoof_english",true);
pref("extensions.torbutton.spoof_charset",'iso-8859-1,*,utf-8');
@@ -159,7 +154,6 @@ pref("extensions.torbutton.block_nontor_file_net",false);
pref("extensions.torbutton.jar_certs",false);
pref("extensions.torbutton.jar_ca_certs",false);
pref("extensions.torbutton.startup_state", 2); // 0=non-tor, 1=tor, 2=last
-pref("extensions.torbutton.block_remoting",false);
pref("extensions.torbutton.tor_memory_jar",false);
pref("extensions.torbutton.nontor_memory_jar",false);
pref("extensions.torbutton.tz_string","");
More information about the tor-commits
mailing list