[tbb-commits] [torbutton/master] Bug 8400: Prompt for restart if disk records are enabled/disabled.
mikeperry at torproject.org
mikeperry at torproject.org
Fri Feb 13 07:21:46 UTC 2015
commit 1e5da0646b288f3621588af08aa81efca09063fa
Author: Mike Perry <mikeperry-git at torproject.org>
Date: Mon Feb 9 18:39:53 2015 -0800
Bug 8400: Prompt for restart if disk records are enabled/disabled.
The private browsing pref doesn't actually take effect until restart..
---
src/chrome/content/preferences.js | 43 ++++++++++++++++++++++++++++++++++++
src/chrome/content/preferences.xul | 3 ++-
src/chrome/content/torbutton.js | 1 +
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 1151176..eaaa059 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -6,6 +6,7 @@
// torbutton_prefs_save() -- on dialog save
var tor_enabled = false;
+const Cc = Components.classes, Ci = Components.interfaces;
function torbutton_prefs_set_field_attributes(doc)
{
@@ -473,3 +474,45 @@ function torbutton_toggle_slider(doc, pos) {
sec_custom.checked = false;
}
}
+
+function torbutton_prefs_check_disk() {
+ let o_torprefs = torbutton_get_prefbranch('extensions.torbutton.');
+ let old_mode = o_torprefs.getBoolPref('block_disk');
+ let mode = document.getElementById('torbutton_blockDisk').checked;
+
+ if (mode === old_mode) {
+ // Either revert, or uncheck.
+ return;
+ }
+
+ let sb = Cc["@mozilla.org/intl/stringbundle;1"]
+ .getService(Ci.nsIStringBundleService);
+ let bundle = sb.createBundle("chrome://browser/locale/preferences/preferences.properties");
+ let brandName = sb.createBundle("chrome://branding/locale/brand.properties").GetStringFromName("brandShortName");
+
+ let msg = bundle.formatStringFromName(mode ?
+ "featureEnableRequiresRestart" : "featureDisableRequiresRestart",
+ [brandName], 1);
+ let title = bundle.formatStringFromName("shouldRestartTitle", [brandName], 1);
+ let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
+ let shouldProceed = prompts.confirm(window, title, msg)
+ if (shouldProceed) {
+ let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
+ .createInstance(Ci.nsISupportsPRBool);
+ let obsSvc = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+ obsSvc.notifyObservers(cancelQuit, "quit-application-requested",
+ "restart");
+ shouldProceed = !cancelQuit.data;
+
+ if (shouldProceed) {
+ document.documentElement.acceptDialog();
+ let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Ci.nsIAppStartup);
+ appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
+ return;
+ }
+ }
+
+ document.getElementById('torbutton_blockDisk').checked = old_mode;
+}
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index f4fcb4d..0a90f0f 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -143,7 +143,8 @@
<groupbox>
<caption label="&torbutton.prefs.priv_caption;"/>
<checkbox id="torbutton_blockDisk"
- label="&torbutton.prefs.block_disk;"/>
+ label="&torbutton.prefs.block_disk;"
+ oncommand="torbutton_prefs_check_disk();"/>
<checkbox id="torbutton_blockPlugins"
label="&torbutton.prefs.block_plugins;"/>
<checkbox id="torbutton_restrictThirdParty"
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index bdb3b2d..4fa3d63 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2042,6 +2042,7 @@ function torbutton_update_disk_prefs() {
m_tb_prefs.setBoolPref("browser.privatebrowsing.autostart", mode);
m_tb_prefs.setBoolPref("browser.cache.disk.enable", !mode);
+ m_tb_prefs.setBoolPref("places.history.enabled", !mode);
m_tb_prefs.setBoolPref("security.nocertdb", mode);
More information about the tbb-commits
mailing list