forked from mirrors/gecko-dev
Bug 1611588 - Handle null BrowsingContext in ExternalHelperAppParent. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D61309 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f862fc3ecb
commit
d70ca2b3dc
2 changed files with 22 additions and 18 deletions
|
|
@ -80,14 +80,16 @@ void ExternalHelperAppParent::Init(
|
|||
SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
|
||||
referrer);
|
||||
|
||||
WindowGlobalParent* parent = aContext->Canonical()->GetCurrentWindowGlobal();
|
||||
if (parent) {
|
||||
RefPtr<BrowserParent> browser = parent->GetBrowserParent();
|
||||
if (browser) {
|
||||
bool isPrivate = false;
|
||||
nsCOMPtr<nsILoadContext> loadContext = browser->GetLoadContext();
|
||||
loadContext->GetUsePrivateBrowsing(&isPrivate);
|
||||
SetPrivate(isPrivate);
|
||||
if (aContext) {
|
||||
WindowGlobalParent* parent = aContext->Canonical()->GetCurrentWindowGlobal();
|
||||
if (parent) {
|
||||
RefPtr<BrowserParent> browser = parent->GetBrowserParent();
|
||||
if (browser) {
|
||||
bool isPrivate = false;
|
||||
nsCOMPtr<nsILoadContext> loadContext = browser->GetLoadContext();
|
||||
loadContext->GetUsePrivateBrowsing(&isPrivate);
|
||||
SetPrivate(isPrivate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1526,16 +1526,18 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|||
aChannel->GetContentLength(&mContentLength);
|
||||
}
|
||||
|
||||
mMaybeCloseWindowHelper = new MaybeCloseWindowHelper(mBrowsingContext);
|
||||
mMaybeCloseWindowHelper->SetShouldCloseWindow(mShouldCloseWindow);
|
||||
if (mBrowsingContext) {
|
||||
mMaybeCloseWindowHelper = new MaybeCloseWindowHelper(mBrowsingContext);
|
||||
mMaybeCloseWindowHelper->SetShouldCloseWindow(mShouldCloseWindow);
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
|
||||
// Determine whether a new window was opened specifically for this request
|
||||
if (props) {
|
||||
bool tmp = false;
|
||||
if (NS_SUCCEEDED(props->GetPropertyAsBool(
|
||||
NS_LITERAL_STRING("docshell.newWindowTarget"), &tmp))) {
|
||||
mMaybeCloseWindowHelper->SetShouldCloseWindow(tmp);
|
||||
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
|
||||
// Determine whether a new window was opened specifically for this request
|
||||
if (props) {
|
||||
bool tmp = false;
|
||||
if (NS_SUCCEEDED(props->GetPropertyAsBool(
|
||||
NS_LITERAL_STRING("docshell.newWindowTarget"), &tmp))) {
|
||||
mMaybeCloseWindowHelper->SetShouldCloseWindow(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue