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 (2012-10-12)
changeset 110342 007e45a1f6c9b05b52ea3e937c1baa5dd64b88c7
parent 110341 e54a4777f65a41a9dac22a3091a6b90bba3aa1d2
child 110343 1cbaabb841d962f6a4c673fb5cd8b47f8add1c7c
push id16489
push usereakhgari@mozilla.com
push dateMon, 15 Oct 2012 22:29:27 +0000 (2012-10-15)
treeherdermozilla-inbound@007e45a1f6c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs800952
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 =