Bug 1354245 - Don't call CaptivePortalService::Start() in SetConnectivityInternal if the captive portal service is disabled via pref. r=mcmanus, a=jcristau
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 12 Apr 2017 17:52:14 +0300
changeset 375927 f3784c1c6bd45a7c4b8fddfa8670e3946527c7ab
parent 375926 30801f76e945300a891b36408b9ee2fd113b18f6
child 375928 9f51f12863d75798d9d8d38173faa70a7a7d9ac9
push id11058
push userryanvm@gmail.com
push dateFri, 14 Apr 2017 20:06:37 +0000
treeherdermozilla-aurora@e53f7f1785eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, jcristau
bugs1354245
milestone54.0a2
Bug 1354245 - Don't call CaptivePortalService::Start() in SetConnectivityInternal if the captive portal service is disabled via pref. r=mcmanus, a=jcristau MozReview-Commit-ID: 4xCkBgWDZ2b
netwerk/base/nsIOService.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -79,17 +79,17 @@ namespace net {
 #define NECKO_BUFFER_CACHE_SIZE_PREF  "network.buffer.cache.size"
 #define NETWORK_NOTIFY_CHANGED_PREF   "network.notify.changed"
 #define NETWORK_CAPTIVE_PORTAL_PREF   "network.captive-portal-service.enabled"
 
 #define MAX_RECURSION_COUNT 50
 
 nsIOService* gIOService = nullptr;
 static bool gHasWarnedUploadChannel2;
-
+static bool gCaptivePortalEnabled = false;
 static LazyLogModule gIOServiceLog("nsIOService");
 #undef LOG
 #define LOG(args)     MOZ_LOG(gIOServiceLog, LogLevel::Debug, args)
 
 // A general port blacklist.  Connections to these ports will not be allowed
 // unless the protocol overrides.
 //
 // TODO: I am sure that there are more ports to be added.  
@@ -1153,17 +1153,17 @@ nsIOService::SetConnectivityInternal(boo
     }
     mConnectivity = aConnectivity;
 
     // This is used for PR_Connect PR_Close telemetry so it is important that
     // we have statistic about network change event even if we are offline.
     mLastConnectivityChange = PR_IntervalNow();
 
     if (mCaptivePortalService) {
-        if (aConnectivity && !xpc::AreNonLocalConnectionsDisabled()) {
+        if (aConnectivity && !xpc::AreNonLocalConnectionsDisabled() && gCaptivePortalEnabled) {
             // This will also trigger a captive portal check for the new network
             static_cast<CaptivePortalService*>(mCaptivePortalService.get())->Start();
         } else {
             static_cast<CaptivePortalService*>(mCaptivePortalService.get())->Stop();
         }
     }
 
     nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
@@ -1296,20 +1296,19 @@ nsIOService::PrefsChanged(nsIPrefBranch 
         bool allow;
         nsresult rv = prefs->GetBoolPref(NETWORK_NOTIFY_CHANGED_PREF, &allow);
         if (NS_SUCCEEDED(rv)) {
             mNetworkNotifyChanged = allow;
         }
     }
 
     if (!pref || strcmp(pref, NETWORK_CAPTIVE_PORTAL_PREF) == 0) {
-        bool captivePortalEnabled;
-        nsresult rv = prefs->GetBoolPref(NETWORK_CAPTIVE_PORTAL_PREF, &captivePortalEnabled);
+        nsresult rv = prefs->GetBoolPref(NETWORK_CAPTIVE_PORTAL_PREF, &gCaptivePortalEnabled);
         if (NS_SUCCEEDED(rv) && mCaptivePortalService) {
-            if (captivePortalEnabled && !xpc::AreNonLocalConnectionsDisabled()) {
+            if (gCaptivePortalEnabled && !xpc::AreNonLocalConnectionsDisabled()) {
                 static_cast<CaptivePortalService*>(mCaptivePortalService.get())->Start();
             } else {
                 static_cast<CaptivePortalService*>(mCaptivePortalService.get())->Stop();
             }
         }
     }
 }