Skip to content

Commit 0c192ee

Browse files
committed
Add restore to defaults on long click
1 parent fc634b3 commit 0c192ee

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/chrome/content/code/FennecUI.jsm

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function unloadFromWindow() {
4343
*/
4444

4545
function addToggleItemToMenu(enabled) {
46-
if (menuId) { aWindow.NativeWindow.menu.remove(menuId); };
46+
if (menuId) { aWindow.NativeWindow.menu.remove(menuId); }
4747
var menuLabel = enabled ? "HTTPS Everywhere on" : "HTTPS Everywhere off";
4848
menuId = aWindow.NativeWindow.menu.add(menuLabel, null, function() {
4949
popupToggleMenu(aWindow, enabled);
@@ -71,9 +71,8 @@ function popupToggleMenu(aWindow, enabled) {
7171

7272

7373
/*
74-
* The HTTPS Everywhere icon in the URL bar shows a menu of rules that the
75-
* user can activate/deactivate. Here's some code to create it and update the
76-
* rule list dynamically.
74+
* The HTTPS Everywhere icon in the URL bar shows a popup of rules that the
75+
* user can activate/deactivate. On long click, reset all rules to defaults.
7776
*/
7877

7978
var popupInfo = {
@@ -120,11 +119,8 @@ var urlbarOptions = {
120119
icon: "chrome://https-everywhere/skin/https-everywhere-128.png",
121120

122121
clickCallback: function() {
123-
124122
popupInfo.fill();
125-
126123
rulesPrompt.setMultiChoiceItems(popupInfo.ruleItems);
127-
128124
rulesPrompt.show(function(data) {
129125
var db = data.button;
130126
if (db === -1) { return null; } // user didn't click the accept button
@@ -144,7 +140,9 @@ var urlbarOptions = {
144140
reloadTab();
145141
return null;
146142
});
147-
}
143+
},
144+
145+
longClickCallback: function() { popupResetDefaultsMenu(aWindow); }
148146
};
149147

150148
var rulesPrompt = new Prompt({
@@ -153,6 +151,24 @@ var rulesPrompt = new Prompt({
153151
buttons: ["Apply changes"]
154152
});
155153

154+
function popupResetDefaultsMenu(aWindow) {
155+
var buttons = [
156+
{
157+
label: "Yes",
158+
callback: function() {
159+
resetToDefaults();
160+
var msg = "Default rules reset.";
161+
aWindow.NativeWindow.toast.show(msg, "short");
162+
return true;
163+
}
164+
}, {
165+
label: "No",
166+
callback: function() { return false; }
167+
}
168+
];
169+
aWindow.NativeWindow.doorhanger.show("Reset all HTTPS Everywhere rules to defaults?", "doorhanger2", buttons);
170+
}
171+
156172

157173
/*
158174
* Some useful utils
@@ -170,7 +186,8 @@ function toggleEnabledState(){
170186
}
171187

172188
function resetToDefaults() {
173-
return HTTPSEverywhere.https_rules.resetRulesetsToDefaults()
189+
HTTPSEverywhere.https_rules.resetRulesetsToDefaults();
190+
reloadTab();
174191
}
175192

176193
function getWindow() {

0 commit comments

Comments
 (0)