Skip to content

Commit 0c2841e

Browse files
committed
Add pageaction UI
1 parent c650775 commit 0c2841e

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/chrome/content/code/FennecUI.jsm

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var EXPORTED_SYMBOLS = ["FennecUI"];
22

33
var menuId;
4+
var urlbarId;
5+
var aWindow = getWindow();
46

57
function getWindow() {
68
return Components.classes['@mozilla.org/appshell/window-mediator;1']
@@ -9,19 +11,43 @@ function getWindow() {
911
}
1012

1113
function loadIntoWindow() {
12-
var window = getWindow();
13-
menuId = window.NativeWindow.menu.add("HTTPS Everywhere", null, function() {
14-
popupMenu(window);
14+
if (!aWindow) {
15+
return;
16+
}
17+
menuId = aWindow.NativeWindow.menu.add("HTTPS Everywhere", null, function() {
18+
popupToggleMenu(aWindow);
1519
});
20+
urlbarId = aWindow.NativeWindow.pageactions.add(urlbarOptions);
1621
}
1722

1823
function unloadFromWindow() {
19-
var window = getWindow();
20-
window.NativeWindow.menu.remove(menuId);
24+
if (!aWindow) {
25+
return;
26+
}
27+
aWindow.NativeWindow.menu.remove(menuId);
28+
aWindow.NativeWindow.pageactions.remove(urlbarId);
29+
}
30+
31+
function popupToggleMenu(aWindow) {
32+
buttons = [
33+
{
34+
label: "Yes",
35+
callback: function() {
36+
aWindow.NativeWindow.toast.show("HTTPS Everywhere disabled!", "short");
37+
}
38+
}, {
39+
label: "No",
40+
callback: function() {
41+
}
42+
}
43+
]
44+
aWindow.NativeWindow.doorhanger.show("Would you like to turn off HTTPS Everywhere?", "doorhanger-test", buttons);
2145
}
2246

23-
function popupMenu(window) {
24-
window.console.log('https everywhere');
47+
var urlbarOptions = {
48+
title: "HTTPS Everywhere",
49+
icon: "chrome://https-everywhere/skin/https-everywhere-128.png",
50+
clickCallback: function() {return;}
2551
}
2652

2753
var FennecUI = {
13 KB
Loading

0 commit comments

Comments
 (0)