Commit e4aa6395 authored by valenting's avatar valenting
Browse files

Bug 1800603 - Do not instantiate captive portal detector if it's too early to...

Bug 1800603 - Do not instantiate captive portal detector if it's too early to run JS r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D166525
parent ec379681
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ nsresult CaptivePortalService::PerformCheck() {
  if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) {
    return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
  }
  if (!mCanUseJS) {
    return NS_ERROR_NOT_INITIALIZED;
  }

  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
  nsresult rv;
  if (!mCaptivePortalDetector) {
@@ -133,6 +137,7 @@ nsresult CaptivePortalService::Initialize() {
    observerService->AddObserver(this, kAbortCaptivePortalLoginEvent, true);
    observerService->AddObserver(this, kCaptivePortalLoginSuccessEvent, true);
    observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
    observerService->AddObserver(this, "app-startup", true);
  }

  LOG(("Initialized CaptivePortalService\n"));
@@ -334,6 +339,9 @@ CaptivePortalService::Observe(nsISupports* aSubject, const char* aTopic,
  } else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
    Stop();
    return NS_OK;
  } else if (!strcmp(aTopic, "app-startup")) {
    mCanUseJS = true;
    return NS_OK;
  }

  // Send notification so that the captive portal state is mirrored in the
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class CaptivePortalService : public nsICaptivePortalService,
  bool mInitialized{false};
  bool mRequestInProgress{false};
  bool mEverBeenCaptive{false};
  bool mCanUseJS{false};

  uint32_t mDelay{kDefaultInterval};
  int32_t mSlackCount{0};