[tbb-commits] [torbutton/master] Bug 20264: Change security slider to 3 options (H, M, L)
gk at torproject.org
gk at torproject.org
Wed Nov 9 15:14:05 UTC 2016
commit 6c423a9aa505882bbb7685f3175dc131baad8809
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Wed Oct 19 11:55:21 2016 -0700
Bug 20264: Change security slider to 3 options (H,M,L)
---
src/chrome/content/preferences.js | 13 ++++++++---
src/chrome/content/preferences.xul | 47 ++++++--------------------------------
src/chrome/locale/en/torbutton.dtd | 3 +--
src/modules/security-prefs.js | 19 ++++++++++-----
4 files changed, 31 insertions(+), 51 deletions(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 7856ef1..3bb6c0c 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -7,11 +7,16 @@ let { getBoolPref, getIntPref, setBoolPref, setIntPref } =
// Description elements have the follow names.
const descNames =
- [, "desc_high", "desc_medium_high", "desc_medium_low", "desc_low"];
+ [, "desc_high", "desc_medium", "desc_low"];
// A single `state` object that reflects the user settings in this UI.
let state = { slider : 0, custom : false};
+// Utility functions to convert between the legacy 4-value pref index
+// and the 3-valued security slider.
+let sliderPositionToPrefSetting = pos => [, 1, 2, 4][pos];
+let prefSettingToSliderPosition = pref => [, 1, 2, 2, 3][pref];
+
// Set the desired slider value and update UI.
function torbutton_set_slider(sliderPosition) {
state.slider = sliderPosition;
@@ -33,12 +38,14 @@ function torbutton_set_custom(customValue) {
// Read prefs 'extensions.torbutton.security_slider' and
// 'extensions.torbutton.security_custom', and initialize the UI.
function torbutton_init_security_ui() {
- torbutton_set_slider(getIntPref("extensions.torbutton.security_slider"));
+ torbutton_set_slider(prefSettingToSliderPosition(
+ getIntPref("extensions.torbutton.security_slider")));
torbutton_set_custom(getBoolPref("extensions.torbutton.security_custom"));
};
// Write the two prefs from the current settings.
function torbutton_save_security_settings() {
- setIntPref("extensions.torbutton.security_slider", state.slider);
+ setIntPref("extensions.torbutton.security_slider",
+ sliderPositionToPrefSetting(state.slider));
setBoolPref("extensions.torbutton.security_custom", state.custom);
};
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index 53abd7f..c6432e0 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -28,7 +28,7 @@
<vbox>
<hbox height="200">
<vbox>
- <scale id="torbutton_sec_slider" flex="1" min="1" max="4"
+ <scale id="torbutton_sec_slider" flex="1" min="1" max="3"
movetoclick="true" orient="vertical"
onchange="torbutton_set_slider(this.value)"/>
</vbox>
@@ -41,22 +41,15 @@
</description>
</hbox>
<hbox flex="1" align="center">
- <description id="torbutton_sec_med_high"
+ <description id="torbutton_sec_medium"
onclick="torbutton_set_slider(2);"
- tooltip="mh_preview">
- &torbutton.prefs.sec_med_high;
- </description>
- </hbox>
- <hbox flex="1" align="center">
- <description id="torbutton_sec_med_low"
- onclick="torbutton_set_slider(3);"
- tooltip="ml_preview">
- &torbutton.prefs.sec_med_low;
+ tooltip="medium_preview">
+ &torbutton.prefs.sec_medium;
</description>
</hbox>
<hbox flex="1" align="end">
<description id="torbutton_sec_low"
- onclick="torbutton_set_slider(4);"
+ onclick="torbutton_set_slider(3);"
tooltip="low_preview">
&torbutton.prefs.sec_low;
</description>
@@ -101,7 +94,7 @@
&torbutton.prefs.sec_webfonts_desc;
</description>
</vbox>
- <vbox id="desc_medium_high" collapsed="true">
+ <vbox id="desc_medium" collapsed="true">
<description
class="slider-text-size, slider-text-weight">
&torbutton.prefs.sec_gen_desc;
@@ -127,24 +120,6 @@
&torbutton.prefs.sec_font_rend_desc;
</description>
</vbox>
- <vbox id="desc_medium_low" collapsed="true">
- <description
- class="slider-text-size, slider-text-weight">
- &torbutton.prefs.sec_gen_desc;
- </description>
- <description class="slider-text-size"
- tooltiptext="&torbutton.prefs.sec_jit_desc_tooltip;">
- &torbutton.prefs.sec_some_jit_desc; &torbutton.prefs.sec_jit_slower_desc;
- </description>
- <description class="slider-text-size"
- tooltiptext="&torbutton.prefs.sec_html5_tooltip;">
- &torbutton.prefs.sec_html5_desc;
- </description>
- <description class="slider-text-size"
- tooltiptext="&torbutton.prefs.sec_mathml_desc_tooltip;">
- &torbutton.prefs.sec_mathml_desc;
- </description>
- </vbox>
<vbox id="desc_low" collapsed="false">
<description
class="slider-text-size, slider-text-weight">
@@ -185,7 +160,7 @@
<html:div>&torbutton.prefs.sec_svg_desc;</html:div>
<html:div>&torbutton.prefs.sec_webfonts_desc;</html:div>
</tooltip>
- <tooltip id="mh_preview">
+ <tooltip id="medium_preview">
<html:b>&torbutton.prefs.sec_gen_desc;</html:b>
<html:br></html:br>
<html:br></html:br>
@@ -195,14 +170,6 @@
<html:div>&torbutton.prefs.sec_mathml_desc;</html:div>
<html:div>&torbutton.prefs.sec_font_rend_desc;</html:div>
</tooltip>
- <tooltip id="ml_preview">
- <html:b>&torbutton.prefs.sec_gen_desc;</html:b>
- <html:br></html:br>
- <html:br></html:br>
- <html:div>&torbutton.prefs.sec_some_jit_desc; &torbutton.prefs.sec_jit_slower_desc;</html:div>
- <html:div>&torbutton.prefs.sec_html5_desc;</html:div>
- <html:div>&torbutton.prefs.sec_mathml_desc;</html:div>
- </tooltip>
<tooltip id="low_preview">
<html:b>&torbutton.prefs.sec_low_desc;</html:b>
<html:br></html:br>
diff --git a/src/chrome/locale/en/torbutton.dtd b/src/chrome/locale/en/torbutton.dtd
index 0c10406..97a994f 100644
--- a/src/chrome/locale/en/torbutton.dtd
+++ b/src/chrome/locale/en/torbutton.dtd
@@ -37,7 +37,6 @@
<!ENTITY torbutton.prefs.sec_low_usable_desc "This provides the most usable experience.">
<!ENTITY torbutton.prefs.sec_low_desc "At this security level, all browser features are enabled.">
<!ENTITY torbutton.prefs.sec_font_rend_svg_tooltip "The SVG OpenType font rendering mechanism is disabled.">
-<!ENTITY torbutton.prefs.sec_med_low "Medium-Low">
<!ENTITY torbutton.prefs.sec_gen_desc "At this security level, the following changes apply (mouseover for details):">
<!ENTITY torbutton.prefs.sec_html5_desc "HTML5 video and audio media become click-to-play via NoScript.">
<!ENTITY torbutton.prefs.sec_html5_tooltip "On some sites, you might need to use the NoScript toolbar button to enable these media objects.">
@@ -47,7 +46,7 @@
<!ENTITY torbutton.prefs.sec_jit_slower_desc "Scripts on some sites may run slower.">
<!ENTITY torbutton.prefs.sec_mathml_desc "Some mechanisms of displaying math equations are disabled.">
<!ENTITY torbutton.prefs.sec_mathml_desc_tooltip "MathML is disabled.">
-<!ENTITY torbutton.prefs.sec_med_high "Medium-High">
+<!ENTITY torbutton.prefs.sec_medium "Medium">
<!ENTITY torbutton.prefs.sec_all_jit_desc "On sites where JavaScript is enabled, performance optimizations are disabled.">
<!ENTITY torbutton.prefs.sec_font_rend_desc "Some font rendering features are disabled.">
<!ENTITY torbutton.prefs.sec_font_rend_graphite_tooltip "The Graphite font rendering mechanism is disabled.">
diff --git a/src/modules/security-prefs.js b/src/modules/security-prefs.js
index fa30aba..e6a888c 100644
--- a/src/modules/security-prefs.js
+++ b/src/modules/security-prefs.js
@@ -15,18 +15,19 @@ let log = (level, msg) => logger.log(level, msg);
// __kSecuritySettings__.
// A table of all prefs bound to the security slider, and the value
-// for each security setting.
+// for each security setting. Note that 2-m and 3-m are identical,
+// corresponding to the old 2-medium-high setting.
const kSecuritySettings = {
- // Preference name : [0, 1-high 2-mh 3-ml 4-low]
+ // Preference name : [0, 1-high 2-m 3-m 4-low]
"javascript.options.ion.content" : [, false, false, false, true ],
"javascript.options.typeinference" : [, false, false, false, true ],
"noscript.forbidMedia" : [, true, true, true, false],
"media.webaudio.enabled" : [, false, false, false, true ],
"mathml.disabled" : [, true, true, true, false],
- "javascript.options.baselinejit.content" : [, false, false, true, true ],
- "gfx.font_rendering.opentype_svg.enabled" : [, false, false, true, true ],
- "noscript.global" : [, false, false, true, true ],
- "noscript.globalHttpsWhitelist" : [, false, true, false, false],
+ "javascript.options.baselinejit.content" : [, false, false, false, true ],
+ "gfx.font_rendering.opentype_svg.enabled" : [, false, false, false, true ],
+ "noscript.global" : [, false, false, false, true ],
+ "noscript.globalHttpsWhitelist" : [, false, true, true, false],
"noscript.forbidFonts" : [, true, false, false, false],
"svg.in-content.enabled" : [, false, true, true, true ],
};
@@ -123,6 +124,12 @@ var initialize = function () {
setBoolPref(kCustomPref, false);
}
});
+ // Migrate from old medium-low (3) to new medium (2).
+ if (getBoolPref("extensions.torbutton.security_custom") === false &&
+ getIntPref("extensions.torbutton.security_slider") === 3) {
+ setIntPref("extensions.torbutton.security_slider", 2);
+ write_setting_to_prefs(2);
+ }
log(4, "security-prefs.js initialization complete");
};
More information about the tbb-commits
mailing list