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
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 12 Oct 2012 14:59:39 -0400
changeset 110476 007e45a1f6c9b05b52ea3e937c1baa5dd64b88c7
parent 110475 e54a4777f65a41a9dac22a3091a6b90bba3aa1d2
child 110477 1cbaabb841d962f6a4c673fb5cd8b47f8add1c7c
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjduell
bugs800952
milestone19.0a1
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.
netwerk/base/src/nsBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
--- a/netwerk/base/src/nsBaseChannel.cpp
+++ b/netwerk/base/src/nsBaseChannel.cpp
@@ -72,16 +72,25 @@ nsBaseChannel::Redirect(nsIChannel *newC
   SUSPEND_PUMP_FOR_SCOPE();
 
   // Transfer properties
 
   newChannel->SetLoadGroup(mLoadGroup);
   newChannel->SetNotificationCallbacks(mCallbacks);
   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);
   if (bag)
     mPropertyHash.EnumerateRead(CopyProperties, bag.get());
 
   // Notify consumer, giving chance to cancel redirect.  For backwards compat,
   // we support nsIHttpEventSink if we are an HTTP channel and if this is not
   // an internal redirect.
 
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1537,16 +1537,25 @@ HttpBaseChannel::SetupReplacementChannel
 
   // Do not pass along LOAD_CHECK_OFFLINE_CACHE
   newLoadFlags &= ~nsICachingChannel::LOAD_CHECK_OFFLINE_CACHE;
 
   newChannel->SetLoadGroup(mLoadGroup); 
   newChannel->SetNotificationCallbacks(mCallbacks);
   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);
   if (!httpChannel)
     return NS_OK; // no other options to set
 
   if (preserveMethod) {
     nsCOMPtr<nsIUploadChannel> uploadChannel =
       do_QueryInterface(httpChannel);
     nsCOMPtr<nsIUploadChannel2> uploadChannel2 =