@@ -190,6 +190,8 @@ function HTTPSEverywhere() {
190190
191191 this . prefs = this . get_prefs ( ) ;
192192 this . rule_toggle_prefs = this . get_prefs ( PREFBRANCH_RULE_TOGGLE ) ;
193+
194+ this . httpNowhereEnabled = this . prefs . getBoolPref ( "http_nowhere.enabled" ) ;
193195
194196 // We need to use observers instead of categories for FF3.0 for these:
195197 // https://developer.mozilla.org/en/Observer_Notifications
@@ -475,16 +477,21 @@ HTTPSEverywhere.prototype = {
475477
476478 if ( topic == "http-on-modify-request" ) {
477479 if ( ! ( channel instanceof CI . nsIHttpChannel ) ) return ;
478-
480+
479481 this . log ( DBUG , "Got http-on-modify-request: " + channel . URI . spec ) ;
480- var lst = this . getApplicableListForChannel ( channel ) ; // null if no window is associated (ex: xhr)
482+ // lst is null if no window is associated (ex: some XHR)
483+ var lst = this . getApplicableListForChannel ( channel ) ;
481484 if ( channel . URI . spec in https_everywhere_blacklist ) {
482485 this . log ( DBUG , "Avoiding blacklisted " + channel . URI . spec ) ;
483- if ( lst ) lst . breaking_rule ( https_everywhere_blacklist [ channel . URI . spec ] ) ;
484- else this . log ( NOTE , "Failed to indicate breakage in content menu" ) ;
486+ if ( lst ) {
487+ lst . breaking_rule ( https_everywhere_blacklist [ channel . URI . spec ] ) ;
488+ }
489+ else {
490+ this . log ( NOTE , "Failed to indicate breakage in content menu" ) ;
491+ }
485492 return ;
486493 }
487- HTTPS . replaceChannel ( lst , channel ) ;
494+ HTTPS . replaceChannel ( lst , channel , this . httpNowhereEnabled ) ;
488495 } else if ( topic == "http-on-examine-response" ) {
489496 this . log ( DBUG , "Got http-on-examine-response @ " + ( channel . URI ? channel . URI . spec : '' ) ) ;
490497 HTTPS . handleSecureCookies ( channel ) ;
@@ -520,13 +527,13 @@ HTTPSEverywhere.prototype = {
520527 Thread . hostRunning = false ;
521528 } else if ( topic == "profile-after-change" ) {
522529 this . log ( DBUG , "Got profile-after-change" ) ;
523-
530+
524531 if ( this . prefs . getBoolPref ( "globalEnabled" ) ) {
525532 OS . addObserver ( this , "cookie-changed" , false ) ;
526533 OS . addObserver ( this , "http-on-modify-request" , false ) ;
527534 OS . addObserver ( this , "http-on-examine-merged-response" , false ) ;
528535 OS . addObserver ( this , "http-on-examine-response" , false ) ;
529-
536+
530537 var dls = CC [ '@mozilla.org/docloaderservice;1' ]
531538 . getService ( CI . nsIWebProgress ) ;
532539 dls . addProgressListener ( this , CI . nsIWebProgress . NOTIFY_LOCATION ) ;
@@ -804,66 +811,33 @@ HTTPSEverywhere.prototype = {
804811 let prefService = Services . prefs ;
805812 let thisBranch =
806813 prefService . getBranch ( "extensions.https_everywhere.http_nowhere." ) ;
807- let networkBranch = prefService . getBranch ( "network." ) ;
808814 let securityBranch = prefService . getBranch ( "security." ) ;
809815
810- // Proxy type. 0: none, 1: manual, 2: autoconfig by URL, 3: same as 0,
811- // 4: autodetect proxy settings, 5: use system proxy settings (default)
812- let PROXY_TYPE = "proxy.type" ;
813- // HTTP proxy host
814- let PROXY_HTTP = "proxy.http" ;
815- // HTTP proxy port
816- let PROXY_PORT = "proxy.http_port" ;
817-
818816 // Whether cert is treated as invalid when OCSP connection fails
819817 let OCSP_REQUIRED = "OCSP.require" ;
820818
821- // Original settings
822- let ORIG_PROXY_TYPE = "orig.proxy.type" ;
823- let ORIG_PROXY_HTTP = "orig.proxy.http" ;
824- let ORIG_PROXY_PORT = "orig.proxy.http_port" ;
819+ // Branch to save original settings
825820 let ORIG_OCSP_REQUIRED = "orig.ocsp.required" ;
826821
827822
828823 if ( thisBranch . getBoolPref ( "enabled" ) ) {
829- // Restore original proxy/ OCSP settings. TODO: What if user manually edits
824+ // Restore original OCSP settings. TODO: What if user manually edits
830825 // these while HTTP Nowhere is enabled?
831- let origProxyType = thisBranch . getIntPref ( ORIG_PROXY_TYPE ) ;
832- networkBranch . setIntPref ( PROXY_TYPE , origProxyType ) ;
833-
834- let origProxyHttp = thisBranch . getCharPref ( ORIG_PROXY_HTTP ) ;
835- networkBranch . setCharPref ( PROXY_HTTP , origProxyHttp ) ;
836-
837- let origProxyPort = thisBranch . getIntPref ( ORIG_PROXY_PORT ) ;
838- networkBranch . setIntPref ( PROXY_PORT , origProxyPort ) ;
839-
840826 let origOcspRequired = thisBranch . getBoolPref ( ORIG_OCSP_REQUIRED ) ;
841827 securityBranch . setBoolPref ( OCSP_REQUIRED , origOcspRequired ) ;
842828
843829 thisBranch . setBoolPref ( "enabled" , false ) ;
830+ this . httpNowhereEnabled = false ;
844831 } else {
845- // Save original proxy settings in HTTP Nowhere preferences branch.
846- let origProxyType = networkBranch . getIntPref ( PROXY_TYPE ) ;
847- thisBranch . setIntPref ( ORIG_PROXY_TYPE , origProxyType ) ;
848-
849- let origProxyHttp = networkBranch . getCharPref ( PROXY_HTTP ) ;
850- thisBranch . setCharPref ( ORIG_PROXY_HTTP , origProxyHttp ) ;
851-
852- let origProxyPort = networkBranch . getIntPref ( PROXY_PORT ) ;
853- thisBranch . setIntPref ( ORIG_PROXY_PORT , origProxyPort ) ;
854-
832+ // Save original OCSP settings in HTTP Nowhere preferences branch.
855833 let origOcspRequired = securityBranch . getBoolPref ( OCSP_REQUIRED ) ;
856834 thisBranch . setBoolPref ( ORIG_OCSP_REQUIRED , origOcspRequired ) ;
857835
858- // Set a null proxy for HTTP requests
859- networkBranch . setIntPref ( PROXY_TYPE , 1 ) ; // manual
860- networkBranch . setCharPref ( PROXY_HTTP , "localhost" ) ;
861- networkBranch . setIntPref ( PROXY_PORT , 4 ) ; // any arbitrary unused port
862-
863836 // Disable OCSP enforcement
864837 securityBranch . setBoolPref ( OCSP_REQUIRED , false ) ;
865838
866839 thisBranch . setBoolPref ( "enabled" , true ) ;
840+ this . httpNowhereEnabled = true ;
867841 }
868842 }
869843} ;
0 commit comments