Bug 791378 - nsPluginHost::NewPluginURLStream needs to take the privacy information into account when creating a channel on behalf of a plugin; r=bzbarsky
☠☠ backed out by a9c81707652a ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Sep 2012 14:30:25 -0400
changeset 107644 ebd274828b7fb2ce3ffc72043094a295500f0e2f
parent 107643 adab1fdcfe0a2f336e393883c883b1a2573563e9
child 107645 3073e4bb03ffdee7a987714ca3da4ef768f19912
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersbzbarsky
bugs791378
milestone18.0a1
Bug 791378 - nsPluginHost::NewPluginURLStream needs to take the privacy information into account when creating a channel on behalf of a plugin; r=bzbarsky
dom/plugins/base/nsPluginHost.cpp
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -116,16 +116,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Telemetry.h"
 #include "nsIImageLoadingContent.h"
 #include "mozilla/Preferences.h"
 #include "nsVersionComparator.h"
+#include "nsIPrivateBrowsingChannel.h"
 
 #if defined(XP_WIN)
 #include "nsIWindowMediator.h"
 #include "nsIBaseWindow.h"
 #include "windows.h"
 #include "winbase.h"
 #endif
 
@@ -3168,16 +3169,28 @@ nsresult nsPluginHost::NewPluginURLStrea
       uploadChannel->SetUploadStream(aPostStream, EmptyCString(), -1);
     }
 
     if (aHeadersData) {
       rv = AddHeadersToChannel(aHeadersData, aHeadersDataLen, httpChannel);
       NS_ENSURE_SUCCESS(rv,rv);
     }
   }
+
+  // Override the privacy state of the channel based on that of the document
+  if (doc) {
+    nsILoadContext* loadContext = doc->GetLoadContext();
+    if (loadContext) {
+      nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(channel);
+      if (pbChannel) {
+        pbChannel->SetPrivate(loadContext->UsePrivateBrowsing());
+      }
+    }
+  }
+
   rv = channel->AsyncOpen(listenerPeer, nullptr);
   if (NS_SUCCEEDED(rv))
     listenerPeer->TrackRequest(channel);
   return rv;
 }
 
 // Called by GetURL and PostURL
 nsresult