From 05ad5a1c2880cc249f8282768e27c787d88222a9 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Mon, 18 Feb 2019 18:11:22 +0100 Subject: [PATCH] Bug 1528814: Serialize Loadinfo for PExternalHelperApp. r=mayhemer --- dom/ipc/ContentChild.cpp | 5 +++-- dom/ipc/ContentChild.h | 5 +++-- dom/ipc/ContentParent.cpp | 7 ++++--- dom/ipc/ContentParent.h | 6 ++++-- dom/ipc/PContent.ipdl | 1 + uriloader/exthandler/ExternalHelperAppParent.cpp | 10 +++++++--- uriloader/exthandler/ExternalHelperAppParent.h | 15 +++++++++------ .../exthandler/nsExternalHelperAppService.cpp | 10 ++++++++-- 8 files changed, 39 insertions(+), 20 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 5d33ff6e8ec1..776371e44d02 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1969,8 +1969,9 @@ bool ContentChild::DeallocPPSMContentDownloaderChild( } PExternalHelperAppChild* ContentChild::AllocPExternalHelperAppChild( - const OptionalURIParams& uri, const nsCString& aMimeContentType, - const nsCString& aContentDisposition, + const OptionalURIParams& uri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const nsCString& aMimeContentType, const nsCString& aContentDisposition, const uint32_t& aContentDispositionHint, const nsString& aContentDispositionFilename, const bool& aForceSave, const int64_t& aContentLength, const bool& aWasFileChannel, diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index e9db73911bc4..6f69327031ac 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -281,8 +281,9 @@ class ContentChild final : public PContentChild, PPSMContentDownloaderChild* aDownloader); PExternalHelperAppChild* AllocPExternalHelperAppChild( - const OptionalURIParams& uri, const nsCString& aMimeContentType, - const nsCString& aContentDisposition, + const OptionalURIParams& uri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const nsCString& aMimeContentType, const nsCString& aContentDisposition, const uint32_t& aContentDispositionHint, const nsString& aContentDispositionFilename, const bool& aForceSave, const int64_t& aContentLength, const bool& aWasFileChannel, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 527a2c08e798..fbd19ce91dc1 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -3596,14 +3596,15 @@ bool ContentParent::DeallocPPSMContentDownloaderParent( } PExternalHelperAppParent* ContentParent::AllocPExternalHelperAppParent( - const OptionalURIParams& uri, const nsCString& aMimeContentType, - const nsCString& aContentDisposition, + const OptionalURIParams& uri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const nsCString& aMimeContentType, const nsCString& aContentDisposition, const uint32_t& aContentDispositionHint, const nsString& aContentDispositionFilename, const bool& aForceSave, const int64_t& aContentLength, const bool& aWasFileChannel, const OptionalURIParams& aReferrer, PBrowserParent* aBrowser) { ExternalHelperAppParent* parent = new ExternalHelperAppParent( - uri, aContentLength, aWasFileChannel, aContentDisposition, + uri, aLoadInfoArgs, aContentLength, aWasFileChannel, aContentDisposition, aContentDispositionHint, aContentDispositionFilename); parent->AddRef(); parent->Init(this, aMimeContentType, aForceSave, aReferrer, aBrowser); diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 1d2e239e1c09..c3b69a43ec45 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -11,6 +11,7 @@ #include "mozilla/dom/nsIContentParent.h" #include "mozilla/gfx/gfxVarReceiver.h" #include "mozilla/gfx/GPUProcessListener.h" +#include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/Attributes.h" #include "mozilla/FileUtils.h" @@ -897,8 +898,9 @@ class ContentParent final : public PContentParent, PPSMContentDownloaderParent* aDownloader); PExternalHelperAppParent* AllocPExternalHelperAppParent( - const OptionalURIParams& aUri, const nsCString& aMimeContentType, - const nsCString& aContentDisposition, + const OptionalURIParams& aUri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const nsCString& aMimeContentType, const nsCString& aContentDisposition, const uint32_t& aContentDispositionHint, const nsString& aContentDispositionFilename, const bool& aForceSave, const int64_t& aContentLength, const bool& aWasFileChannel, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 780389f0b6c4..8764359b1a9f 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -894,6 +894,7 @@ parent: async PPSMContentDownloader(uint32_t aCertType); async PExternalHelperApp(OptionalURIParams uri, + OptionalLoadInfoArgs loadInfoArgs, nsCString aMimeContentType, nsCString aContentDisposition, uint32_t aContentDispositionHint, diff --git a/uriloader/exthandler/ExternalHelperAppParent.cpp b/uriloader/exthandler/ExternalHelperAppParent.cpp index 83b8c58cc6a4..4d4452331866 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.cpp +++ b/uriloader/exthandler/ExternalHelperAppParent.cpp @@ -33,8 +33,10 @@ NS_IMPL_ISUPPORTS_INHERITED(ExternalHelperAppParent, nsHashPropertyBag, nsIStreamListener, nsIExternalHelperAppParent) ExternalHelperAppParent::ExternalHelperAppParent( - const OptionalURIParams& uri, const int64_t& aContentLength, - const bool& aWasFileChannel, const nsCString& aContentDispositionHeader, + const OptionalURIParams& uri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const int64_t& aContentLength, const bool& aWasFileChannel, + const nsCString& aContentDispositionHeader, const uint32_t& aContentDispositionHint, const nsString& aContentDispositionFilename) : mURI(DeserializeURI(uri)), @@ -59,6 +61,8 @@ ExternalHelperAppParent::ExternalHelperAppParent( mContentDisposition = aContentDispositionHint; mContentDispositionFilename = aContentDispositionFilename; } + mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs, + getter_AddRefs(mLoadInfo)); } already_AddRefed GetWindowFromTabParent( @@ -322,7 +326,7 @@ ExternalHelperAppParent::SetOwner(nsISupports* aOwner) { NS_IMETHODIMP ExternalHelperAppParent::GetLoadInfo(nsILoadInfo** aLoadInfo) { - *aLoadInfo = nullptr; + NS_IF_ADDREF(*aLoadInfo = mLoadInfo); return NS_OK; } diff --git a/uriloader/exthandler/ExternalHelperAppParent.h b/uriloader/exthandler/ExternalHelperAppParent.h index 41b631421fe0..b86ed6ef992b 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.h +++ b/uriloader/exthandler/ExternalHelperAppParent.h @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/PExternalHelperAppParent.h" +#include "mozilla/ipc/BackgroundUtils.h" #include "nsIChannel.h" #include "nsIMultiPartChannel.h" #include "nsIResumableChannel.h" @@ -83,12 +84,13 @@ class ExternalHelperAppParent bool WasFileChannel() override { return mWasFileChannel; } - ExternalHelperAppParent(const OptionalURIParams& uri, - const int64_t& contentLength, - const bool& wasFileChannel, - const nsCString& aContentDispositionHeader, - const uint32_t& aContentDispositionHint, - const nsString& aContentDispositionFilename); + ExternalHelperAppParent( + const OptionalURIParams& uri, + const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs, + const int64_t& contentLength, const bool& wasFileChannel, + const nsCString& aContentDispositionHeader, + const uint32_t& aContentDispositionHint, + const nsString& aContentDispositionFilename); void Init(ContentParent* parent, const nsCString& aMimeContentType, const bool& aForceSave, const OptionalURIParams& aReferrer, PBrowserParent* aBrowser); @@ -102,6 +104,7 @@ class ExternalHelperAppParent private: nsCOMPtr mListener; nsCOMPtr mURI; + nsCOMPtr mLoadInfo; bool mPending; #ifdef DEBUG bool mDiverted; diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 9d7735c2b4ce..ac9803092d91 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -616,6 +616,7 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( bool wasFileChannel = false; uint32_t contentDisposition = -1; nsAutoString fileName; + nsCOMPtr loadInfo; nsCOMPtr channel = do_QueryInterface(aRequest); if (channel) { @@ -624,6 +625,7 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( channel->GetContentDisposition(&contentDisposition); channel->GetContentDispositionFilename(fileName); channel->GetContentDispositionHeader(disp); + loadInfo = channel->GetLoadInfo(); nsCOMPtr fileChan(do_QueryInterface(aRequest)); wasFileChannel = fileChan != nullptr; @@ -636,14 +638,18 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( SerializeURI(uri, uriParams); SerializeURI(referrer, referrerParams); + mozilla::net::OptionalLoadInfoArgs loadInfoArgs; + MOZ_ALWAYS_SUCCEEDS(LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs)); + // Now we build a protocol for forwarding our data to the parent. The // protocol will act as a listener on the child-side and create a "real" // helperAppService listener on the parent-side, via another call to // DoContent. mozilla::dom::PExternalHelperAppChild* pc = child->SendPExternalHelperAppConstructor( - uriParams, nsCString(aMimeContentType), disp, contentDisposition, - fileName, aForceSave, contentLength, wasFileChannel, referrerParams, + uriParams, loadInfoArgs, nsCString(aMimeContentType), disp, + contentDisposition, fileName, aForceSave, contentLength, + wasFileChannel, referrerParams, mozilla::dom::TabChild::GetFrom(window)); ExternalHelperAppChild* childListener = static_cast(pc);