Bug 800952 - Make sure that the privacy override information on a channel is correctly transferred to a channel when we setup a replacement channel for it; f=jdm r=jduell

This is required when a channel with an overridden privacy status (such as
a favicon HTTP load channel) gets redirected, for example.
This commit is contained in:
Ehsan Akhgari 2012-10-12 14:59:39 -04:00
parent 47ea65c276
commit bcd437d0de
2 changed files with 18 additions and 0 deletions

View File

@ -77,6 +77,15 @@ nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags,
newChannel->SetNotificationCallbacks(mCallbacks); newChannel->SetNotificationCallbacks(mCallbacks);
newChannel->SetLoadFlags(mLoadFlags | LOAD_REPLACE); newChannel->SetLoadFlags(mLoadFlags | LOAD_REPLACE);
// Try to preserve the privacy bit if it has been overridden
if (mPrivateBrowsingOverriden) {
nsCOMPtr<nsIPrivateBrowsingChannel> newPBChannel =
do_QueryInterface(newChannel);
if (newPBChannel) {
newPBChannel->SetPrivate(mPrivateBrowsing);
}
}
nsCOMPtr<nsIWritablePropertyBag> bag = ::do_QueryInterface(newChannel); nsCOMPtr<nsIWritablePropertyBag> bag = ::do_QueryInterface(newChannel);
if (bag) if (bag)
mPropertyHash.EnumerateRead(CopyProperties, bag.get()); mPropertyHash.EnumerateRead(CopyProperties, bag.get());

View File

@ -1542,6 +1542,15 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
newChannel->SetNotificationCallbacks(mCallbacks); newChannel->SetNotificationCallbacks(mCallbacks);
newChannel->SetLoadFlags(newLoadFlags); newChannel->SetLoadFlags(newLoadFlags);
// Try to preserve the privacy bit if it has been overridden
if (mPrivateBrowsingOverriden) {
nsCOMPtr<nsIPrivateBrowsingChannel> newPBChannel =
do_QueryInterface(newChannel);
if (newPBChannel) {
newPBChannel->SetPrivate(mPrivateBrowsing);
}
}
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(newChannel); nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(newChannel);
if (!httpChannel) if (!httpChannel)
return NS_OK; // no other options to set return NS_OK; // no other options to set