Commit d70ca2b3 authored by Matt Woodrow's avatar Matt Woodrow
Browse files

Bug 1611588 - Handle null BrowsingContext in ExternalHelperAppParent. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D61309

--HG--
extra : moz-landing-system : lando
parent f862fc3e
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ void ExternalHelperAppParent::Init(
    SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
                           referrer);

  if (aContext) {
    WindowGlobalParent* parent = aContext->Canonical()->GetCurrentWindowGlobal();
    if (parent) {
      RefPtr<BrowserParent> browser = parent->GetBrowserParent();
@@ -90,6 +91,7 @@ void ExternalHelperAppParent::Init(
        SetPrivate(isPrivate);
      }
    }
  }

  helperAppService->CreateListener(aMimeContentType, this, aContext, aForceSave,
                                   nullptr, getter_AddRefs(mListener));
+13 −11
Original line number Diff line number Diff line
@@ -1526,6 +1526,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
    aChannel->GetContentLength(&mContentLength);
  }

  if (mBrowsingContext) {
    mMaybeCloseWindowHelper = new MaybeCloseWindowHelper(mBrowsingContext);
    mMaybeCloseWindowHelper->SetShouldCloseWindow(mShouldCloseWindow);

@@ -1538,6 +1539,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
        mMaybeCloseWindowHelper->SetShouldCloseWindow(tmp);
      }
    }
  }

  // Now get the URI
  if (aChannel) {
@@ -1552,7 +1554,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
  // download. We don't run this in the content process, since we have
  // an instance running in the parent as well, which will handle this
  // if needed.
  if (!XRE_IsContentProcess()) {
  if (!XRE_IsContentProcess() && mMaybeCloseWindowHelper) {
    mBrowsingContext = mMaybeCloseWindowHelper->MaybeCloseWindow();
  }