Skip to content

Commit bc66f96

Browse files
committed
Start making the applicable list menu
1 parent 0c2841e commit bc66f96

2 files changed

Lines changed: 62 additions & 5 deletions

File tree

‎src/chrome/content/code/FennecUI.jsm‎

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
var EXPORTED_SYMBOLS = ["FennecUI"];
22

3+
const CC = Components.classes;
4+
const CI = Components.interfaces;
5+
const CU = Components.utils;
6+
7+
var HTTPSEverywhere = CC["@eff.org/https-everywhere;1"]
8+
.getService(CI.nsISupports).wrappedJSObject;
9+
10+
CU.import("resource://gre/modules/Prompt.jsm");
11+
312
var menuId;
413
var urlbarId;
514
var aWindow = getWindow();
615

716
function getWindow() {
8-
return Components.classes['@mozilla.org/appshell/window-mediator;1']
9-
.getService(Components.interfaces.nsIWindowMediator)
17+
return CC['@mozilla.org/appshell/window-mediator;1']
18+
.getService(CI.nsIWindowMediator)
1019
.getMostRecentWindow('navigator:browser');
1120
}
1221

@@ -44,14 +53,62 @@ function popupToggleMenu(aWindow) {
4453
aWindow.NativeWindow.doorhanger.show("Would you like to turn off HTTPS Everywhere?", "doorhanger-test", buttons);
4554
}
4655

56+
/*
57+
* The HTTPS Everywhere icon in the URL bar shows a menu of rules that the
58+
* user can activate/deactivate. Here's some code to create it and update the
59+
* rule list dynamically.
60+
*/
61+
4762
var urlbarOptions = {
4863
title: "HTTPS Everywhere",
4964
icon: "chrome://https-everywhere/skin/https-everywhere-128.png",
50-
clickCallback: function() {return;}
65+
clickCallback: function() {
66+
rulesPrompt.setMultiChoiceItems(ruleItems);
67+
rulesPrompt.show(function(data) {
68+
aWindow.alert(JSON.stringify(getApplicableList()));
69+
})
70+
}
71+
};
72+
73+
// The prompt that shows up when someone clicks on the icon
74+
var rulesPrompt = new Prompt({
75+
window: aWindow,
76+
title: "Enable/disable rules"
77+
});
78+
79+
// Rulesets to show in the list
80+
var ruleItems = [
81+
{ label: "rule 1" },
82+
{ label: "rule 2", disabled: true },
83+
{ label: "rule 3", selected: true }
84+
];
85+
86+
function getApplicableList() {
87+
var domWin = getWindow().content.document.defaultView.top;
88+
if (!(domWin instanceof CI.nsIDOMWindow)) {
89+
aWindow.console.log('something went wrong getting top window');
90+
return null;
91+
}
92+
var alist = HTTPSEverywhere.getExpando(domWin,"applicable_rules", null);
93+
return alist.all;
94+
}
95+
96+
function toggleRule(rule_id) {
97+
// toggle the rule state
98+
HTTPSEverywhere.https_rules.rulesetsByID[rule_id].toggle();
99+
reloadTab();
51100
}
52101

102+
function reloadTab() { return; }
103+
104+
function toggleEnabledState(){
105+
HTTPSEverywhere.toggleEnabledState();
106+
reloadTab();
107+
}
108+
109+
// Here's the external API to this UI module
53110
var FennecUI = {
54111
init: function() {
55112
loadIntoWindow();
56113
}
57-
}
114+
};

‎src/defaults/preferences/preferences.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pref("extensions.https_everywhere.LogLevel", 3);
1+
pref("extensions.https_everywhere.LogLevel", 5);
22
pref("extensions.https_everywhere.globalEnabled",true);
33

44
// this is the HTTPS Everywhere preferences version (for migrations)

0 commit comments

Comments
 (0)