Skip to content

Commit b0bc2a4

Browse files
committed
Added toolbar button for global enable/disable of the addon. It works by simply removing and re-adding the listeners for now. No graphical feedback as to what the status is. TO DO: 1) Graphic feedback showing addon status {enabled, disabled} 2) Verify there are no left-over policy bits anywhere that need to be removed.
1 parent 6397c70 commit b0bc2a4

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/chrome/content/code/ApplicableList.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ ApplicableList.prototype = {
8080
while(this.menupopup.firstChild.tagName != "menuseparator") {
8181
this.menupopup.removeChild(this.menupopup.firstChild);
8282
}
83-
83+
84+
// add global enable/disable toggle button
85+
var enableLabel = document.createElement('menuitem');
86+
enableLabel.setAttribute('label', 'Enable / Disable HTTPS Everywhere');
87+
enableLabel.setAttribute('command', 'https-everywhere-menuitem-globalEnableToggle');
88+
8489
// add the label at the top
8590
var any_rules = false
8691
for (var x in this.all) {
@@ -92,7 +97,7 @@ ApplicableList.prototype = {
9297
label.setAttribute('label', 'Enable / Disable Rules');
9398
} else {
9499
if (!weird) label.setAttribute('label', '(No Rules for This Page)');
95-
else label.setAttribute('label', '(Rules for This Page Uknown)');
100+
else label.setAttribute('label', '(Rules for This Page Unknown)');
96101
}
97102
label.setAttribute('command', 'https-everywhere-menuitem-preferences');
98103

@@ -166,8 +171,9 @@ ApplicableList.prototype = {
166171
this.add_menuitem(this.active[x], 'active');
167172
for (var x in this.breaking)
168173
this.add_menuitem(this.breaking[x], 'breaking');
169-
174+
170175
this.prepend_child(label);
176+
this.prepend_child(enableLabel);
171177
},
172178

173179
prepend_child: function(node) {

src/chrome/content/toolbar_button.xul

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
</toolbarbutton>
4343
</toolbarpalette>
4444
<commandset>
45+
<command id="https-everywhere-menuitem-globalEnableToggle"
46+
oncommand="HTTPSEverywhere.toggleEnabledState();" />
4547
<command id="https-everywhere-menuitem-preferences"
4648
oncommand="HTTPSEverywhere.chrome_opener('chrome://https-everywhere/content/preferences.xul');" />
4749
<command id="https-everywhere-menuitem-about"

src/components/https-everywhere.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function HTTPSEverywhere() {
158158
this.https_rules = HTTPSRules;
159159
this.INCLUDE=INCLUDE;
160160
this.ApplicableList = ApplicableList;
161+
this.globalEnable = false;
161162

162163
// We need to use observers instead of categories for FF3.0 for these:
163164
// https://developer.mozilla.org/en/Observer_Notifications
@@ -170,6 +171,7 @@ function HTTPSEverywhere() {
170171
this.obsService.addObserver(this, "profile-before-change", false);
171172
this.obsService.addObserver(this, "profile-after-change", false);
172173
this.obsService.addObserver(this, "sessionstore-windows-restored", false);
174+
this.globalEnable = true;
173175
return;
174176
}
175177

@@ -616,8 +618,30 @@ HTTPSEverywhere.prototype = {
616618
.getService(CI.nsIWindowMediator)
617619
.getMostRecentWindow('navigator:browser')
618620
.open(uri,'', 'chrome,centerscreen' );
619-
}
621+
},
620622

623+
toggleEnabledState: function() {
624+
if(this.globalEnable){
625+
this.obsService.removeObserver(this, "profile-before-change", false);
626+
this.obsService.removeObserver(this, "profile-after-change", false);
627+
this.obsService.removeObserver(this, "sessionstore-windows-restored", false);
628+
OS.removeObserver(this, "cookie-changed", false);
629+
OS.removeObserver(this, "http-on-modify-request", false);
630+
OS.removeObserver(this, "http-on-examine-merged-response", false);
631+
OS.removeObserver(this, "http-on-examine-response", false);
632+
this.globalEnable = false;
633+
}
634+
else{
635+
this.obsService.addObserver(this, "profile-before-change", false);
636+
this.obsService.addObserver(this, "profile-after-change", false);
637+
this.obsService.addObserver(this, "sessionstore-windows-restored", false);
638+
OS.addObserver(this, "cookie-changed", false);
639+
OS.addObserver(this, "http-on-modify-request", false);
640+
OS.addObserver(this, "http-on-examine-merged-response", false);
641+
OS.addObserver(this, "http-on-examine-response", false);
642+
this.globalEnable = true;
643+
}
644+
}
621645
};
622646

623647
var prefs = 0;

0 commit comments

Comments
 (0)