Skip to content

Commit dd2d93d

Browse files
committed
Merge the experimental cohort code from 3.0, but don't use it
(Mostly because it has some refactoring that we want to keep consistent) Conflicts: src/components/https-everywhere.js
1 parent b7d885b commit dd2d93d

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

src/components/https-everywhere.js

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

98+
const N_COHORTS = 1000;
99+
98100
const DUMMY_OBJ = {};
99101
DUMMY_OBJ.wrappedJSObject = DUMMY_OBJ;
100102
const DUMMY_FUNC = function() {}
@@ -495,27 +497,47 @@ HTTPSEverywhere.prototype = {
495497
SERVICE_CTRID, false, true);
496498
}
497499
} 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-
that.chrome_opener("chrome://https-everywhere/content/observatory-popup.xul");
512-
};
513-
if (!shown && !enabled)
514-
ssl_observatory.registerProxyTestNotification(obs_popup_callback);
500+
this.maybeShowObservatoryPopup();
515501
}
516502
return;
517503
},
518504

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