@@ -95,6 +95,10 @@ const WHERE_UNTRUSTED = 1;
9595const WHERE_TRUSTED = 2 ;
9696const 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+
98102const DUMMY_OBJ = { } ;
99103DUMMY_OBJ . wrappedJSObject = DUMMY_OBJ ;
100104const 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 ;
0 commit comments