Bug 1354245 - Don't call CaptivePortalService::Start() in SetConnectivityInternal if the captive portal service is disabled via pref r=mcmanus draft
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 12 Apr 2017 17:52:14 +0300
changeset 561343 8bce4e1fb98e9c8dd2c8119ee59df2cfbb62efb3
parent 559608 731639fccc709a4dd95fed7e9dda88efb2227906
child 623948 5223ad0f0a669682fd8b7a8f25d4bbeed147244e
push id53702
push uservalentin.gosu@gmail.com
push dateWed, 12 Apr 2017 14:53:24 +0000
reviewersmcmanus
bugs1354245
milestone55.0a1
Bug 1354245 - Don't call CaptivePortalService::Start() in SetConnectivityInternal if the captive portal service is disabled via pref r=mcmanus 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.  
@@ -1158,17 +1158,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();
@@ -1300,20 +1300,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();
             }
         }
     }
 }