Bug 241972 (new window opened by window.open('xxx.exe') or target="_blank" isn't closed automatically when a download begins). Fix stores state on the channel indicating whether a window was opened specifically for the download. The external helper app service then closes the window if there is no refresh header and if the window was opened specifically for the download. r=cbiesinger, sr=darin
git-svn-id: svn://10.0.0.236/trunk@201538 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -819,6 +819,9 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP)
|
||||
flags |= INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_NEW_WINDOW)
|
||||
flags |= INTERNAL_LOAD_FLAGS_NEW_WINDOW;
|
||||
|
||||
rv = InternalLoad(aURI,
|
||||
referrer,
|
||||
owner,
|
||||
@@ -4530,6 +4533,9 @@ NS_IMETHODIMP nsDocShell::SetupRefreshURI(nsIChannel * aChannel)
|
||||
if (!refreshHeader.IsEmpty()) {
|
||||
SetupReferrerFromChannel(aChannel);
|
||||
rv = SetupRefreshURIFromHeader(mCurrentURI, refreshHeader);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return NS_REFRESHURI_HEADER_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
@@ -6372,6 +6378,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
isNewWindow = PR_TRUE;
|
||||
aFlags |= INTERNAL_LOAD_FLAGS_NEW_WINDOW;
|
||||
|
||||
nsDependentString name(aWindowTarget);
|
||||
nsCOMPtr<nsIDOMWindow> newWin;
|
||||
rv = win->Open(EmptyString(), // URL to load
|
||||
@@ -6718,7 +6726,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
rv = DoURILoad(aURI, aReferrer,
|
||||
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
|
||||
owner, aTypeHint, aPostData, aHeadersData, aFirstParty,
|
||||
aDocShell, getter_AddRefs(req));
|
||||
aDocShell, getter_AddRefs(req),
|
||||
aFlags & INTERNAL_LOAD_FLAGS_NEW_WINDOW);
|
||||
if (req && aRequest)
|
||||
NS_ADDREF(*aRequest = req);
|
||||
|
||||
@@ -6778,7 +6787,8 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
nsIInputStream * aHeadersData,
|
||||
PRBool aFirstParty,
|
||||
nsIDocShell ** aDocShell,
|
||||
nsIRequest ** aRequest)
|
||||
nsIRequest ** aRequest,
|
||||
PRBool aIsNewWindowTarget)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURILoader> uriLoader;
|
||||
@@ -6948,6 +6958,15 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
channel->SetOwner(aOwner);
|
||||
}
|
||||
|
||||
if (aIsNewWindowTarget) {
|
||||
nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(channel);
|
||||
if (props) {
|
||||
props->SetPropertyAsBool(
|
||||
NS_LITERAL_STRING("docshell.newWindowTarget"),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
rv = DoChannelLoad(channel, uriLoader);
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user