Skip to content

Commit

Permalink
Bug 18093: Remove 'Restore Defaults' button
Browse files Browse the repository at this point in the history
  • Loading branch information
arthuredelstein committed Oct 12, 2016
1 parent 873601a commit 01ee197
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 85 deletions.
57 changes: 0 additions & 57 deletions src/chrome/content/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,63 +57,6 @@ function torbutton_prefs_save(doc) {
}
}

function torbutton_prefs_reset_defaults() {
var o_torprefs = torbutton_get_prefbranch('extensions.torbutton.');
var tmpcnt = new Object();
var children;
var i;
var loglevel = o_torprefs.getIntPref("loglevel");
var logmthd = o_torprefs.getIntPref("logmethod");

torbutton_log(3, "Starting Pref reset");

// 1. Clear torbutton settings
// 2. Clear browser proxy settings
// 3. Reset Security Slider settings

// XXX Warning: The only reason this works is because of Firefox's
// threading model. As soon as a pref is changed, all observers
// are notified by that same thread, immediately. Since torbutton's
// security state is driven by proxy pref observers, this
// causes everything to be reset in a linear order. If firefox
// ever makes pref observers asynchonous, this will all break.

children = o_torprefs.getChildList("" , tmpcnt);
for(i = 0; i < children.length; i++) {
if(o_torprefs.prefHasUserValue(children[i]))
o_torprefs.clearUserPref(children[i]);
}

// Keep logging the same.
o_torprefs.setIntPref("loglevel", loglevel);
o_torprefs.setIntPref("logmethod", logmthd);

torbutton_log(3, "Resetting browser prefs");

// Reset browser prefs that torbutton touches just in case
// they get horked. Better everything gets set back to default
// than some arcane pref gets wedged with no clear way to fix it.
// Technical users who tuned these by themselves will be able to fix it.
// It's the non-technical ones we should make it easy for
torbutton_reset_browser_prefs();

// Resetting the Security Slider preferences
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
o_torprefs.setBoolPref('security_custom', false);
o_torprefs.setIntPref('security_slider', 4);
win.torbutton_update_security_slider();

torbutton_log(4, "Preferences reset to defaults");
torbutton_prefs_init(window.document);

// In all cases, force prefs to be synced to disk
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
prefService.savePrefFile(null);
}

function torbutton_toggle_slider(doc, pos) {
doc.getElementById("torbutton_sec_slider").value = pos;
// Make sure the custom checkbox is unchecked as the user seems to want one
Expand Down
4 changes: 1 addition & 3 deletions src/chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="&torbutton.prefs.security_settings;"
buttons="accept,cancel,extra1"
buttonlabelextra1="&torbutton.prefs.restore_defaults;"
ondialogextra1="torbutton_prefs_reset_defaults();"
buttons="accept,cancel"
persist="screenX screenY width height"
onload="torbutton_prefs_init(document)"
align="stretch"
Expand Down
24 changes: 0 additions & 24 deletions src/chrome/content/torbutton_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,6 @@ function torbutton_get_prefbranch(branch_name) {
return o_branch;
}

// Bug 1506 P3: This would be a semi-polite thing to do on uninstall
// for pure Firefox users. The most polite thing would be to save
// all their original prefs.. But meh?
function torbutton_reset_browser_prefs() {
var o_all_prefs = torbutton_get_prefbranch('');
var prefs = ["network.http.sendSecureXSiteReferrer",
"network.http.sendRefererHeader", "dom.storage.enabled",
"extensions.update.enabled", "app.update.enabled",
"app.update.auto", "browser.search.update",
"browser.cache.memory.enable", "network.http.use-cache",
"browser.cache.disk.enable", "browser.safebrowsing.enabled",
"browser.send_pings", "browser.safebrowsing.remoteLookups",
"network.security.ports.banned", "browser.search.suggest.enabled",
"security.enable_java", "browser.history_expire_days",
"browser.download.manager.retention", "browser.formfill.enable",
"signon.rememberSignons", "plugin.disable_full_page_plugin_for_types",
"browser.bookmarks.livemark_refresh_seconds",
"network.cookie.lifetimePolicy" ];
for(var i = 0; i < prefs.length; i++) {
if(o_all_prefs.prefHasUserValue(prefs[i]))
o_all_prefs.clearUserPref(prefs[i]);
}
}

// load localization strings
function torbutton_get_stringbundle()
{
Expand Down
1 change: 0 additions & 1 deletion src/chrome/locale/en/torbutton.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!ENTITY torbutton.context_menu.cookieProtections.key "C">
<!ENTITY torbutton.button.tooltip "Click to initialize Torbutton">
<!ENTITY torbutton.prefs.security_settings "Security Settings">
<!ENTITY torbutton.prefs.restore_defaults "Restore Defaults">
<!ENTITY torbutton.cookiedialog.title "Manage Cookie Protections">
<!ENTITY torbutton.cookiedialog.lockCol "Protected">
<!ENTITY torbutton.cookiedialog.domainCol "Host">
Expand Down

0 comments on commit 01ee197

Please sign in to comment.