Skip to content

Commit fc634b3

Browse files
committed
Improve code organization
1 parent d8dd283 commit fc634b3

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

src/chrome/content/code/FennecUI.jsm

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var EXPORTED_SYMBOLS = ["FennecUI"];
2-
31
const CC = Components.classes;
42
const CI = Components.interfaces;
53
const CU = Components.utils;
@@ -13,11 +11,10 @@ var menuId;
1311
var urlbarId;
1412
var aWindow = getWindow();
1513

16-
function getWindow() {
17-
return CC['@mozilla.org/appshell/window-mediator;1']
18-
.getService(CI.nsIWindowMediator)
19-
.getMostRecentWindow('navigator:browser');
20-
}
14+
15+
/*
16+
* Setup/Teardown for the UI
17+
*/
2118

2219
function loadIntoWindow() {
2320
if (!aWindow) {
@@ -40,6 +37,11 @@ function unloadFromWindow() {
4037
aWindow.NativeWindow.pageactions.remove(urlbarId);
4138
}
4239

40+
41+
/*
42+
* Add a menu item to toggle HTTPS Everywhere
43+
*/
44+
4345
function addToggleItemToMenu(enabled) {
4446
if (menuId) { aWindow.NativeWindow.menu.remove(menuId); };
4547
var menuLabel = enabled ? "HTTPS Everywhere on" : "HTTPS Everywhere off";
@@ -67,6 +69,7 @@ function popupToggleMenu(aWindow, enabled) {
6769
aWindow.NativeWindow.doorhanger.show("Would you like to turn HTTPS Everywhere "+newState, "doorhanger", buttons);
6870
}
6971

72+
7073
/*
7174
* The HTTPS Everywhere icon in the URL bar shows a menu of rules that the
7275
* user can activate/deactivate. Here's some code to create it and update the
@@ -144,13 +147,17 @@ var urlbarOptions = {
144147
}
145148
};
146149

147-
// The prompt that shows up when someone clicks on the icon
148150
var rulesPrompt = new Prompt({
149151
window: aWindow,
150152
title: "Enable/disable rules",
151153
buttons: ["Apply changes"]
152154
});
153155

156+
157+
/*
158+
* Some useful utils
159+
*/
160+
154161
function reloadTab() {
155162
// There seems to be no API to do this directly?
156163
aWindow.BrowserApp.selectedTab.window.location.reload();
@@ -162,7 +169,21 @@ function toggleEnabledState(){
162169
reloadTab();
163170
}
164171

165-
// Here's the external API to this UI module
172+
function resetToDefaults() {
173+
return HTTPSEverywhere.https_rules.resetRulesetsToDefaults()
174+
}
175+
176+
function getWindow() {
177+
return CC['@mozilla.org/appshell/window-mediator;1']
178+
.getService(CI.nsIWindowMediator)
179+
.getMostRecentWindow('navigator:browser');
180+
}
181+
182+
183+
/*
184+
* Here's the external API to this UI module
185+
*/
186+
166187
var FennecUI = {
167188
init: function() {
168189
loadIntoWindow();
@@ -171,3 +192,5 @@ var FennecUI = {
171192
unloadFromWindow();
172193
}
173194
};
195+
196+
var EXPORTED_SYMBOLS = ["FennecUI"];

0 commit comments

Comments
 (0)