Skip to content

Commit e33b31b

Browse files
committed
Popup asking Tor users if they want to use the Observatory
Apologies for the creeping spaghetti this commit is feeding...
1 parent 13af80f commit e33b31b

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed

makexpi.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rm -f "../$XPI_NAME"
6262
if [ -n "$CHANGES" ]; then
6363
printf >&2 "WARNING: uncommitted changes were included:\n%s\n" "$CHANGES"
6464
fi
65-
zip -v -X -9r "../$XPI_NAME" . "-x@../.build_exclusions"
65+
zip -q -X -9r "../$XPI_NAME" . "-x@../.build_exclusions"
6666

6767
ret="$?"
6868
if [ "$ret" != 0 ]; then

src/chrome/content/observatory-popup.xul

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<commandgroup>
1818
<command id="enable" oncommand="enable_observatory() ; popup_done()" />
19-
<command id="nope" oncommand="popup_done()" />
19+
<command id="nope" oncommand="disable_observatory() ; popup_done()" />
2020
<command id="later" oncommand="window.close()" />
2121
<command id="more-info"
2222
oncommand='popup_done() ;

src/chrome/content/observatory-preferences.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function observatory_prefs_init(doc) {
4848
// The user has responded to the popup in a final way; don't show it to them
4949
// again
5050
function popup_done() {
51-
ssl_observatory.popup_responded = true;
51+
obsprefs.setBoolPref("extensions.https_everywhere._observatory.popup_shown", true);
5252
window.close();
5353
}
5454

@@ -111,6 +111,11 @@ function enable_observatory() {
111111
obsprefs.setBoolPref("extensions.https_everywhere._observatory.enabled", true);
112112
}
113113

114+
function disable_observatory() {
115+
// default but be sure...
116+
obsprefs.setBoolPref("extensions.https_everywhere._observatory.enabled", false);
117+
}
118+
114119
// called from within the prefs window, we have more work to do:
115120
function toggle_enabled() {
116121
var use_obs = document.getElementById("use-observatory").checked;

src/components/https-everywhere.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function HTTPSEverywhere() {
167167
.getService(Components.interfaces.nsIObserverService);
168168
this.obsService.addObserver(this, "profile-before-change", false);
169169
this.obsService.addObserver(this, "profile-after-change", false);
170+
this.obsService.addObserver(this, "sessionstore-windows-restored", false);
170171
return;
171172
}
172173

@@ -430,6 +431,15 @@ HTTPSEverywhere.prototype = {
430431
// hook on redirections (non persistent, otherwise crashes on 1.8.x)
431432
catman.addCategoryEntry("net-channel-event-sinks", SERVICE_CTRID,
432433
SERVICE_CTRID, false, true);
434+
} else if (topic == "sessionstore-windows-restored") {
435+
var ssl_observatory = CC["@eff.org/ssl-observatory;1"]
436+
.getService(Components.interfaces.nsISupports)
437+
.wrappedJSObject;
438+
// FIXME This prefs code is terrible spaghetti
439+
var gbp = ssl_observatory.prefs.getBoolPref;
440+
var shown = gbp("extensions.https_everywhere._observatory.popup_shown");
441+
if (!shown && ssl_observatory.torbutton_installed)
442+
chrome_opener("chrome://https-everywhere/content/observatory-popup.xul");
433443
}
434444
return;
435445
},
@@ -553,6 +563,15 @@ HTTPSEverywhere.prototype = {
553563

554564
};
555565

566+
function chrome_opener(uri) {
567+
// we don't use window.open, because we need to work around TorButton's
568+
// state control
569+
CC['@mozilla.org/appshell/window-mediator;1']
570+
.getService(CI.nsIWindowMediator)
571+
.getMostRecentWindow('navigator:browser')
572+
.open(uri,'', 'chrome,centerscreen' );
573+
}
574+
556575
var prefs = 0;
557576
var econsole = 0;
558577
function https_everywhereLog(level, str) {

src/components/ssl-observatory.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ SSLObservatory.prototype = {
163163

164164
// Wifi status listener
165165
onChange: function(accessPoints) {
166-
var max_ap = accessPoints[0].mac;
166+
try {
167+
var max_ap = accessPoints[0].mac;
168+
} catch(e) {
169+
return null; // accessPoints[0] is undefined
170+
}
167171
var max_signal = accessPoints[0].signal;
168172
var old_max_present = false;
169173
for (var i=0; i<accessPoints.length; i++) {

src/defaults/preferences/preferences.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pref("extensions.https_everywhere._observatory.submit_during_nontor",true);
1313
pref("extensions.https_everywhere._observatory.cache_submitted",true);
1414

1515
pref("extensions.https_everywhere._observatory.use_custom_proxy",false);
16+
pref("extensions.https_everywhere._observatory.popup_shown",false);
1617
pref("extensions.https_everywhere._observatory.proxy_host","");
1718
pref("extensions.https_everywhere._observatory.proxy_port",0);
1819
pref("extensions.https_everywhere._observatory.proxy_type","direct");

0 commit comments

Comments
 (0)