@@ -95,6 +95,8 @@ const WHERE_UNTRUSTED = 1;
9595const WHERE_TRUSTED = 2 ;
9696const ANYWHERE = 3 ;
9797
98+ const N_COHORTS = 1000 ;
99+
98100const DUMMY_OBJ = { } ;
99101DUMMY_OBJ . wrappedJSObject = DUMMY_OBJ ;
100102const 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 ;
0 commit comments