Skip to content

Commit 0d75f76

Browse files
committed
Use special magic for opening windows to avoid Torbutton's control-freakery
1 parent 785d1a5 commit 0d75f76

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/chrome/content/about.xul

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
height="550"
1414
align="center">
1515

16+
<script type="application/x-javascript"
17+
src="chrome://https-everywhere/content/preferences.js"/>
1618
<vbox>
1719
<label style="text-align:center; font-weight:bold; font-size:22px;">HTTPS Everywhere</label>
1820
<label style="text-align:center; font-size:18px; margin-bottom:10px;">Encrypt the Web! Automatically use HTTPS security on many sites.</label>
@@ -48,14 +50,14 @@
4850
style="color: blue; cursor:hand; text-decoration:underline; font-style:bold"
4951
onmouseover="event.target.style.cursor='pointer'"
5052
onmouseout="event.target.style.cursor='default'"
51-
onclick="window.open('https://www.torproject.org/donate/donate.html.en')"/>
53+
onclick="window_opener('https://www.torproject.org/donate/donate.html.en')"/>
5254
or
5355
<label id="donate link2"
5456
value="Donating to EFF"
5557
style="color: blue; cursor:hand; text-decoration:underline; font-style:bold"
5658
onmouseover="event.target.style.cursor='pointer'"
5759
onmouseout="event.target.style.cursor='default'"
58-
onclick="window.open('https://www.eff.org/donate')"/>
60+
onclick="window_opener('https://www.eff.org/donate')"/>
5961
</label>
6062
</vbox>
6163
</dialog>

src/chrome/content/preferences.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const CC = Components.classes;
2+
const CI = Components.interfaces;
23
VERB=1;
34
DBUG=2;
45
INFO=3;
@@ -111,3 +112,10 @@ function https_prefs_init(doc) {
111112

112113
st.view = treeView;
113114
}
115+
116+
function window_opener(uri, opts) {
117+
// we don't use window.open, because we need to work around TorButton's state control
118+
CC['@mozilla.org/appshell/window-mediator;1'].getService(CI.nsIWindowMediator)
119+
.getMostRecentWindow('navigator:browser')
120+
.open(uri, '','centerscreen' );
121+
}

src/chrome/content/preferences.xul

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
style="color: blue; cursor:hand; text-decoration:underline;"
4141
onmouseover="event.target.style.cursor='pointer'"
4242
onmouseout="event.target.style.cursor='default'"
43-
onclick="window.open('https://eff.org/https-everywhere/rulesets')"/>.
43+
onclick="window_opener('https://eff.org/https-everywhere/rulesets')"/>.
4444
</vbox>
4545
</dialog>

src/chrome/content/toolbar_button.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,10 @@ function open_in_tab(url) {
9191
var recentWindow = wm.getMostRecentWindow("navigator:browser");
9292
recentWindow.delayedOpenTab(url, null, null, null, null);
9393
}
94+
95+
function chrome_opener(uri, opts) {
96+
// we don't use window.open, because we need to work around TorButton's state control
97+
CC['@mozilla.org/appshell/window-mediator;1'].getService(CI.nsIWindowMediator)
98+
.getMostRecentWindow('navigator:browser')
99+
.open(uri,'', 'chrome,centerscreen' );
100+
}

src/chrome/content/toolbar_button.xul

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@
2121
label="HTTPS Everywhere"
2222
context="https-everywhere-context-menu"
2323
buttonstyle="pictures"
24-
type="menu" >
24+
type="menu">
2525

2626
<menupopup id="https-everywhere-context" onpopupshowing="show_applicable_list()"></menupopup>
2727
</toolbarbutton>
2828
</toolbarpalette>
2929
<commandset>
30-
<command id="https-everywhere-menuitem-preferences" oncommand="window.open('chrome://https-everywhere/content/preferences.xul', '', 'chrome,centerscreen');" />
31-
<command id="https-everywhere-menuitem-about" oncommand="window.open('chrome://https-everywhere/content/about.xul', '', 'chrome,centerscreen');" />
32-
<command id="https-everywhere-menuitem-donate-eff" oncommand="open_in_tab('https://www.eff.org/donate');" />
33-
<command id="https-everywhere-menuitem-donate-tor" oncommand="open_in_tab('https://www.torproject.org/donate');" />
30+
<command id="https-everywhere-menuitem-preferences"
31+
oncommand="chrome_opener('chrome://https-everywhere/content/preferences.xul');" />
32+
<command id="https-everywhere-menuitem-about"
33+
oncommand="chrome_opener('chrome://https-everywhere/content/about.xul');" />
34+
<command id="https-everywhere-menuitem-donate-eff"
35+
oncommand="open_in_tab('https://www.eff.org/donate');" />
36+
<command id="https-everywhere-menuitem-donate-tor"
37+
oncommand="open_in_tab('https://www.torproject.org/donate');" />
3438
</commandset>
3539
</overlay>

0 commit comments

Comments
 (0)