Bug 1206146 - Use channel->AsyncOpen2() in embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp (r=sicking)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Sat, 19 Sep 2015 20:24:39 -0700
changeset 296058 0783f2174228ea14bcfcaaed3fbff28b4fb56014
parent 296057 f7106fa308e5e621d08020b211509b9ef9b1e33e
child 296059 d03c69e05eed0f72517dec6cf8213c6610c7a34f
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1206146
milestone43.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 1206146 - Use channel->AsyncOpen2() in embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp (r=sicking)
embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
toolkit/components/downloads/nsDownloadManager.cpp
--- a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -568,17 +568,17 @@ nsWebBrowserPersist::StartUpload(nsIInpu
     CreateChannelFromURI(aDestinationURI, getter_AddRefs(destChannel));
     nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(destChannel));
     NS_ENSURE_TRUE(uploadChannel, NS_ERROR_FAILURE);
 
     // Set the upload stream
     // NOTE: ALL data must be available in "inputstream"
     nsresult rv = uploadChannel->SetUploadStream(aInputStream, aContentType, -1);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
-    rv = destChannel->AsyncOpen(this, nullptr);
+    rv = destChannel->AsyncOpen2(this);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
     // add this to the upload list
     nsCOMPtr<nsISupports> keyPtr = do_QueryInterface(destChannel);
     mUploadList.Put(keyPtr, new UploadData(aDestinationURI));
 
     return NS_OK;
 }
@@ -1302,17 +1302,17 @@ nsresult nsWebBrowserPersist::SaveURIInt
         }
     }
 
     // Open a channel to the URI
     nsCOMPtr<nsIChannel> inputChannel;
     rv = NS_NewChannel(getter_AddRefs(inputChannel),
                        aURI,
                        nsContentUtils::GetSystemPrincipal(),
-                       nsILoadInfo::SEC_NORMAL,
+                       nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                        nsIContentPolicy::TYPE_OTHER,
                        nullptr,  // aLoadGroup
                        static_cast<nsIInterfaceRequestor*>(this),
                        loadFlags);
 
     nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(inputChannel);
     if (pbChannel)
     {
@@ -1421,30 +1421,44 @@ nsresult nsWebBrowserPersist::SaveChanne
 
     // The default behaviour of SaveChannelInternal is to download the source
     // into a storage stream and upload that to the target. MakeOutputStream
     // special-cases a file target and creates a file output stream directly.
     // We want to special-case a file source and create a file input stream,
     // but we don't need to do this in the case of a file target.
     nsCOMPtr<nsIFileChannel> fc(do_QueryInterface(aChannel));
     nsCOMPtr<nsIFileURL> fu(do_QueryInterface(aFile));
+
+    nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
     if (fc && !fu) {
         nsCOMPtr<nsIInputStream> fileInputStream, bufferedInputStream;
-        nsresult rv = aChannel->Open(getter_AddRefs(fileInputStream));
+        nsresult rv;
+        if (loadInfo && loadInfo->GetSecurityMode()) {
+          rv = aChannel->Open2(getter_AddRefs(fileInputStream));
+        }
+        else {
+          rv = aChannel->Open(getter_AddRefs(fileInputStream));
+        }
         NS_ENSURE_SUCCESS(rv, rv);
         rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedInputStream),
                                        fileInputStream, BUFFERED_OUTPUT_SIZE);
         NS_ENSURE_SUCCESS(rv, rv);
         nsAutoCString contentType;
         aChannel->GetContentType(contentType);
         return StartUpload(bufferedInputStream, aFile, contentType);
     }
 
     // Read from the input channel
-    nsresult rv = aChannel->AsyncOpen(this, nullptr);
+    nsresult rv;
+    if (loadInfo && loadInfo->GetSecurityMode()) {
+        rv = aChannel->AsyncOpen2(this);
+    }
+    else {
+        rv = aChannel->AsyncOpen(this, nullptr);
+    }
     if (rv == NS_ERROR_NO_CONTENT)
     {
         // Assume this is a protocol such as mailto: which does not feed out
         // data and just ignore it.
         return NS_SUCCESS_DONT_FIXUP;
     }
 
     if (NS_FAILED(rv))
@@ -2766,17 +2780,17 @@ nsresult
 nsWebBrowserPersist::CreateChannelFromURI(nsIURI *aURI, nsIChannel **aChannel)
 {
     nsresult rv = NS_OK;
     *aChannel = nullptr;
 
     rv = NS_NewChannel(aChannel,
                        aURI,
                        nsContentUtils::GetSystemPrincipal(),
-                       nsILoadInfo::SEC_NORMAL,
+                       nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                        nsIContentPolicy::TYPE_OTHER);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_ARG_POINTER(*aChannel);
 
     rv = (*aChannel)->SetNotificationCallbacks(static_cast<nsIInterfaceRequestor*>(this));
     NS_ENSURE_SUCCESS(rv, rv);
     return NS_OK;
 }
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -3553,17 +3553,17 @@ nsDownload::Resume()
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create a new channel for the source URI
   nsCOMPtr<nsIChannel> channel;
   nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(wbp));
   rv = NS_NewChannel(getter_AddRefs(channel),
                      mSource,
                      nsContentUtils::GetSystemPrincipal(),
-                     nsILoadInfo::SEC_NORMAL,
+                     nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                      nsIContentPolicy::TYPE_OTHER,
                      nullptr,  // aLoadGroup
                      ir);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(channel);
   if (pbChannel) {