diff --git a/netwerk/base/nsSecCheckWrapChannel.cpp b/netwerk/base/nsSecCheckWrapChannel.cpp index 18e282eecf53..7063fab3746c 100644 --- a/netwerk/base/nsSecCheckWrapChannel.cpp +++ b/netwerk/base/nsSecCheckWrapChannel.cpp @@ -3,6 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "nsContentSecurityManager.h" #include "nsSecCheckWrapChannel.h" #include "nsHttpChannel.h" #include "nsCOMPtr.h" @@ -28,6 +29,8 @@ NS_INTERFACE_MAP_BEGIN(nsSecCheckWrapChannelBase) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIHttpChannel) NS_INTERFACE_MAP_ENTRY(nsIRequest) NS_INTERFACE_MAP_ENTRY(nsIChannel) + NS_INTERFACE_MAP_ENTRY(nsIUploadChannel) + NS_INTERFACE_MAP_ENTRY(nsIUploadChannel2) NS_INTERFACE_MAP_ENTRY(nsISecCheckWrapChannel) NS_INTERFACE_MAP_END @@ -40,6 +43,8 @@ nsSecCheckWrapChannelBase::nsSecCheckWrapChannelBase(nsIChannel* aChannel) , mHttpChannel(do_QueryInterface(aChannel)) , mHttpChannelInternal(do_QueryInterface(aChannel)) , mRequest(do_QueryInterface(aChannel)) + , mUploadChannel(do_QueryInterface(aChannel)) + , mUploadChannel2(do_QueryInterface(aChannel)) { MOZ_ASSERT(mChannel, "can not create a channel wrapper without a channel"); } @@ -102,3 +107,21 @@ nsSecCheckWrapChannel::SetLoadInfo(nsILoadInfo* aLoadInfo) mLoadInfo = aLoadInfo; return NS_OK; } + +NS_IMETHODIMP +nsSecCheckWrapChannel::AsyncOpen2(nsIStreamListener *aListener) +{ + nsCOMPtr listener = aListener; + nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener); + NS_ENSURE_SUCCESS(rv, rv); + return AsyncOpen(listener, nullptr); +} + +NS_IMETHODIMP +nsSecCheckWrapChannel::Open2(nsIInputStream** aStream) +{ + nsCOMPtr listener; + nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener); + NS_ENSURE_SUCCESS(rv, rv); + return Open(aStream); +} diff --git a/netwerk/base/nsSecCheckWrapChannel.h b/netwerk/base/nsSecCheckWrapChannel.h index 9ba164ca61ce..d29aef190146 100644 --- a/netwerk/base/nsSecCheckWrapChannel.h +++ b/netwerk/base/nsSecCheckWrapChannel.h @@ -8,6 +8,8 @@ #include "nsIHttpChannel.h" #include "nsIHttpChannelInternal.h" +#include "nsIUploadChannel.h" +#include "nsIUploadChannel2.h" #include "nsISecCheckWrapChannel.h" #include "nsIWyciwygChannel.h" #include "mozilla/LoadInfo.h" @@ -34,6 +36,8 @@ * * nsIChannel * * nsIHttpChannel * * nsIHttpChannelInternal + * * nsIUploadChannel + * * nsIUploadChannel2 * * In case any addon needs to query the inner channel this class * provides a readonly function to query the wrapped channel. @@ -43,12 +47,16 @@ class nsSecCheckWrapChannelBase : public nsIHttpChannel , public nsIHttpChannelInternal , public nsISecCheckWrapChannel + , public nsIUploadChannel + , public nsIUploadChannel2 { public: NS_FORWARD_NSIHTTPCHANNEL(mHttpChannel->) NS_FORWARD_NSIHTTPCHANNELINTERNAL(mHttpChannelInternal->) NS_FORWARD_NSICHANNEL(mChannel->) NS_FORWARD_NSIREQUEST(mRequest->) + NS_FORWARD_NSIUPLOADCHANNEL(mUploadChannel->) + NS_FORWARD_NSIUPLOADCHANNEL2(mUploadChannel2->) NS_DECL_NSISECCHECKWRAPCHANNEL NS_DECL_ISUPPORTS @@ -62,11 +70,13 @@ protected: nsCOMPtr mHttpChannel; nsCOMPtr mHttpChannelInternal; nsCOMPtr mRequest; + nsCOMPtr mUploadChannel; + nsCOMPtr mUploadChannel2; }; -/* We define a separate class here to make it clear that we're - * overriding Get/SetLoadInfo, rather that using the forwarded - * implementations provided by NS_FORWARD_NSICHANNEL" +/* We define a separate class here to make it clear that we're overriding + * Get/SetLoadInfo as well as AsyncOpen2() and Open2(), rather that using + * the forwarded implementations provided by NS_FORWARD_NSICHANNEL" */ class nsSecCheckWrapChannel : public nsSecCheckWrapChannelBase { @@ -74,6 +84,9 @@ public: NS_IMETHOD GetLoadInfo(nsILoadInfo **aLoadInfo); NS_IMETHOD SetLoadInfo(nsILoadInfo *aLoadInfo); + NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener); + NS_IMETHOD Open2(nsIInputStream** aStream); + nsSecCheckWrapChannel(nsIChannel* aChannel, nsILoadInfo* aLoadInfo); protected: