Skip to content

Commit 32baf58

Browse files
committed
Make Tools->HTTPS Everywhere a clone of the context menu
1 parent 7d68682 commit 32baf58

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/chrome.manifest

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@ component {0f9ab521-986d-4ad8-9c1f-6934e195c15c} components/ssl-observatory.js
2121
contract @eff.org/ssl-observatory;1 {0f9ab521-986d-4ad8-9c1f-6934e195c15c}
2222

2323
category profile-after-change SSLObservatory @eff.org/ssl-observatory;1
24-
25-
overlay chrome://browser/content/browser.xul chrome://https-everywhere/content/browser-overlay.xul
26-
overlay chrome://navigator/content/navigatorOverlay.xul chrome://https-everywhere/content/browser-overlay.xul
27-

src/chrome/content/code/ApplicableList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ApplicableList.prototype = {
5555
dst.setUserData(key, data, this.dom_handler);
5656
},
5757

58-
populate_menu: function(document) {
58+
populate_menu: function(document, menupopup) {
5959

6060
// The base URI of the dom tends to be loaded from some /other/
6161
// ApplicableList, so pretend we're loading it from here.
@@ -64,7 +64,7 @@ ApplicableList.prototype = {
6464
this.document = document;
6565

6666
// get the menu popup
67-
this.menupopup = document.getElementById('https-everywhere-context');
67+
this.menupopup = menupopup;
6868

6969
// empty it all of its menuitems
7070
while(this.menupopup.firstChild.tagName != "menuseparator") {

src/chrome/content/toolbar_button.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ function https_everywhere_load() {
3333
} catch(e) { }
3434
}
3535

36-
function show_applicable_list() {
36+
function stitch_context_menu() {
37+
// the same menu appears both under Tools and via the toolbar button:
38+
var menu = document.getElementById("https-everywhere-menu");
39+
if (!menu.firstChild) {
40+
var popup = document.getElementById("https-everywhere-context");
41+
menu.appendChild(popup.cloneNode(true));
42+
}
43+
}
44+
45+
function show_applicable_list(menupopup) {
3746
var domWin = content.document.defaultView.top;
3847
if (!(domWin instanceof CI.nsIDOMWindow)) {
3948
alert(domWin + " is not an nsIDOMWindow");
@@ -49,7 +58,7 @@ function show_applicable_list() {
4958
// away.
5059
alist = new ApplicableList(HTTPSEverywhere.log, document, domWin);
5160
}
52-
alist.populate_menu(document);
61+
alist.populate_menu(document, menupopup);
5362
}
5463

5564
function toggle_rule(rule_id) {

src/chrome/content/toolbar_button.xul

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
<overlay id="https-everywhere-button-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
1010
<script type="application/x-javascript" src="chrome://https-everywhere/content/toolbar_button.js"/>
11-
12-
<toolbar id="nav-bar">
13-
<popup id="https-everywhere-context-menu"/>
14-
</toolbar>
11+
12+
<!-- this works in Firefox, we need a Seamonkey version too... -->
13+
<menupopup id="menu_ToolsPopup" onpopupshowing="stitch_context_menu()">
14+
<menu id="https-everywhere-menu" label="&https-everywhere.about.ext_name;">
15+
<!-- "https-everywhere-context" below gets .cloneNode()ed in here -->
16+
</menu>
17+
</menupopup>
1518

1619
<toolbarpalette id="BrowserToolbarPalette">
1720
<toolbarbutton
@@ -24,7 +27,7 @@
2427
buttonstyle="pictures"
2528
type="menu">
2629

27-
<menupopup id="https-everywhere-context" onpopupshowing="show_applicable_list()">
30+
<menupopup id="https-everywhere-context" onpopupshowing="show_applicable_list(this)">
2831
<!-- entries will be written here by ApplicableList.populate_menu() -->
2932
<menuseparator />
3033
<menuitem label="&https-everywhere.menu.observatory;" command="https-everywhere-menuitem-observatory" />

0 commit comments

Comments
 (0)