Skip to content

Commit 8db7dee

Browse files
committed
Final plan: offer the Observatory to 5% of HTTPS E 3.0.0 users
1 parent c8b85b8 commit 8db7dee

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

src/components/https-everywhere.js

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ const WHERE_UNTRUSTED = 1;
9595
const WHERE_TRUSTED = 2;
9696
const ANYWHERE = 3;
9797

98+
const N_COHORTS = 1000; // For now 50 / 1000 stable non-Tor users get the popup
99+
const OBS_COHORTS = 50; // asking them if they'd like to turn on the
100+
// Decentralized SSL Observatory
101+
98102
const DUMMY_OBJ = {};
99103
DUMMY_OBJ.wrappedJSObject = DUMMY_OBJ;
100104
const DUMMY_FUNC = function() {}
@@ -495,29 +499,49 @@ HTTPSEverywhere.prototype = {
495499
SERVICE_CTRID, false, true);
496500
}
497501
} else if (topic == "sessionstore-windows-restored") {
498-
var ssl_observatory = CC["@eff.org/ssl-observatory;1"]
499-
.getService(Components.interfaces.nsISupports)
500-
.wrappedJSObject;
501-
// Show the popup at most once. Users who enabled the Observatory before
502-
// a version that would have shown it to them, don't need to see it
503-
// again.
504-
var shown = ssl_observatory.myGetBoolPref("popup_shown");
505-
var enabled = ssl_observatory.myGetBoolPref("enabled");
506-
var that = this;
507-
var obs_popup_callback = function(result) {
508-
if (result) that.log(INFO, "Got positive proxy test.");
509-
else that.log(INFO, "Got negative proxy text.");
510-
// We are now ready to show the popup in its most informative state
511-
// (actually for temporary scalability reasons let's only show it if
512-
// the user has Tor available too...)
513-
if (result) that.chrome_opener("chrome://https-everywhere/content/observatory-popup.xul");
514-
};
515-
if (!shown && !enabled)
516-
ssl_observatory.registerProxyTestNotification(obs_popup_callback);
502+
this.maybeShowObservatoryPopup();
517503
}
518504
return;
519505
},
520506

507+
maybeShowObservatoryPopup: function() {
508+
// Show the popup at most once. Users who enabled the Observatory before
509+
// a version that would have shown it to them, don't need to see it
510+
// again.
511+
var ssl_observatory = CC["@eff.org/ssl-observatory;1"]
512+
.getService(Components.interfaces.nsISupports)
513+
.wrappedJSObject;
514+
var shown = ssl_observatory.myGetBoolPref("popup_shown");
515+
var enabled = ssl_observatory.myGetBoolPref("enabled");
516+
var that = this;
517+
var cohort = this.getExperimentalFeatureCohort();
518+
var obs_popup_callback = function(result) {
519+
if (result) that.log(INFO, "Got positive proxy test.");
520+
else that.log(INFO, "Got negative proxy text.");
521+
// We are now ready to show the popup in its most informative state
522+
// (actually for temporary scalability reasons let's only show it if
523+
// the user has Tor available too, or is in a small cohort...)
524+
if (result || cohort < OBS_COHORTS)
525+
that.chrome_opener("chrome://https-everywhere/content/observatory-popup.xul");
526+
};
527+
if (!shown && !enabled)
528+
ssl_observatory.registerProxyTestNotification(obs_popup_callback);
529+
},
530+
531+
getExperimentalFeatureCohort: function() {
532+
// This variable is used for gradually turning on features for testing and
533+
// scalability purposes. It is a random integer [0,N_COHORTS) generated
534+
// once and stored thereafter.
535+
var cohort;
536+
try {
537+
cohort = this.prefs.getIntPref("experimental_feature_cohort");
538+
} catch(e) {
539+
cohort = Math.round(Math.random() * N_COHORTS);
540+
this.prefs.setIntPref("experimental_feature_cohort", cohort);
541+
}
542+
return cohort;
543+
},
544+
521545
// nsIChannelEventSink implementation
522546
onChannelRedirect: function(oldChannel, newChannel, flags) {
523547
const uri = newChannel.URI;

src/defaults/preferences/preferences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pref("extensions.https_everywhere.LogLevel", 5);
2+
pref("extensions.https_everywhere.globalEnabled",true);
23

34
// SSl Observatory preferences
4-
pref("extensions.https_everywhere.globalEnabled",true);
55
pref("extensions.https_everywhere._observatory.enabled",false);
66

77
// "testing" currently means send unecessary fingerprints and other test-suite

0 commit comments

Comments
 (0)