diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 734db2120c3c..b49f0f211768 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -52,6 +52,7 @@ struct HttpChannelOpenArgs bool allowSpdy; OptionalFileDescriptorSet fds; PrincipalInfo requestingPrincipalInfo; + PrincipalInfo triggeringPrincipalInfo; uint32_t securityFlags; uint32_t contentPolicyType; }; @@ -78,6 +79,7 @@ struct FTPChannelOpenArgs nsCString entityID; OptionalInputStreamParams uploadStream; PrincipalInfo requestingPrincipalInfo; + PrincipalInfo triggeringPrincipalInfo; uint32_t securityFlags; uint32_t contentPolicyType; }; diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp index 6a205bda0547..b4ef232f53f0 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -149,12 +149,18 @@ void propagateLoadInfo(nsILoadInfo *aLoadInfo, FTPChannelOpenArgs& openArgs) { - mozilla::ipc::PrincipalInfo principalInfo; + mozilla::ipc::PrincipalInfo requestingPrincipalInfo; + mozilla::ipc::PrincipalInfo triggeringPrincipalInfo; if (aLoadInfo) { mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(), - &principalInfo); - openArgs.requestingPrincipalInfo() = principalInfo; + &requestingPrincipalInfo); + openArgs.requestingPrincipalInfo() = requestingPrincipalInfo; + + mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(), + &triggeringPrincipalInfo); + openArgs.triggeringPrincipalInfo() = triggeringPrincipalInfo; + openArgs.securityFlags() = aLoadInfo->GetSecurityFlags(); openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType(); return; @@ -162,8 +168,9 @@ propagateLoadInfo(nsILoadInfo *aLoadInfo, // use default values if no loadInfo is provided mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(), - &principalInfo); - openArgs.requestingPrincipalInfo() = principalInfo; + &requestingPrincipalInfo); + openArgs.requestingPrincipalInfo() = requestingPrincipalInfo; + openArgs.triggeringPrincipalInfo() = requestingPrincipalInfo; openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL; openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER; } diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index b6bddc81b0b1..c367b56dd087 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -87,8 +87,8 @@ FTPChannelParent::Init(const FTPChannelCreationArgs& aArgs) { const FTPChannelOpenArgs& a = aArgs.get_FTPChannelOpenArgs(); return DoAsyncOpen(a.uri(), a.startPos(), a.entityID(), a.uploadStream(), - a.requestingPrincipalInfo(), a.securityFlags(), - a.contentPolicyType()); + a.requestingPrincipalInfo(), a.triggeringPrincipalInfo(), + a.securityFlags(), a.contentPolicyType()); } case FTPChannelCreationArgs::TFTPChannelConnectArgs: { @@ -107,6 +107,7 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI, const nsCString& aEntityID, const OptionalInputStreamParams& aUploadStream, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType) { @@ -142,17 +143,24 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI, if (NS_FAILED(rv)) { return SendFailedAsyncOpen(rv); } + nsCOMPtr triggeringPrincipal = + mozilla::ipc::PrincipalInfoToPrincipal(aTriggeringPrincipalInfo, &rv); + if (NS_FAILED(rv)) { + return SendFailedAsyncOpen(rv); + } + nsCOMPtr chan; - rv = NS_NewChannel(getter_AddRefs(chan), - uri, - requestingPrincipal, - aSecurityFlags, - aContentPolicyType, - nullptr, // aLoadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, - ios); + rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(chan), + uri, + requestingPrincipal, + triggeringPrincipal, + aSecurityFlags, + aContentPolicyType, + nullptr, // aLoadGroup + nullptr, // aCallbacks + nsIRequest::LOAD_NORMAL, + ios); if (NS_FAILED(rv)) return SendFailedAsyncOpen(rv); diff --git a/netwerk/protocol/ftp/FTPChannelParent.h b/netwerk/protocol/ftp/FTPChannelParent.h index fc6471fb8b23..da537f111fdc 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.h +++ b/netwerk/protocol/ftp/FTPChannelParent.h @@ -66,6 +66,7 @@ protected: const nsCString& aEntityID, const OptionalInputStreamParams& aUploadStream, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType); diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 06ca24fe4754..5d65dce1c49d 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -1244,12 +1244,18 @@ void propagateLoadInfo(nsILoadInfo *aLoadInfo, HttpChannelOpenArgs& openArgs) { - mozilla::ipc::PrincipalInfo principalInfo; + mozilla::ipc::PrincipalInfo requestingPrincipalInfo; + mozilla::ipc::PrincipalInfo triggeringPrincipalInfo; if (aLoadInfo) { mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(), - &principalInfo); - openArgs.requestingPrincipalInfo() = principalInfo; + &requestingPrincipalInfo); + openArgs.requestingPrincipalInfo() = requestingPrincipalInfo; + + mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(), + &triggeringPrincipalInfo); + openArgs.triggeringPrincipalInfo() = triggeringPrincipalInfo; + openArgs.securityFlags() = aLoadInfo->GetSecurityFlags(); openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType(); return; @@ -1257,8 +1263,9 @@ propagateLoadInfo(nsILoadInfo *aLoadInfo, // use default values if no loadInfo is provided mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(), - &principalInfo); - openArgs.requestingPrincipalInfo() = principalInfo; + &requestingPrincipalInfo); + openArgs.requestingPrincipalInfo() = requestingPrincipalInfo; + openArgs.triggeringPrincipalInfo() = requestingPrincipalInfo; openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL; openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER; } diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index b3155a5b0713..8391d9674ac2 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -105,8 +105,8 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs) a.thirdPartyFlags(), a.resumeAt(), a.startPos(), a.entityID(), a.chooseApplicationCache(), a.appCacheClientID(), a.allowSpdy(), a.fds(), - a.requestingPrincipalInfo(), a.securityFlags(), - a.contentPolicyType()); + a.requestingPrincipalInfo(), a.triggeringPrincipalInfo(), + a.securityFlags(), a.contentPolicyType()); } case HttpChannelCreationArgs::THttpChannelConnectArgs: { @@ -192,6 +192,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI, const bool& allowSpdy, const OptionalFileDescriptorSet& aFds, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType) { @@ -223,6 +224,11 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI, if (NS_FAILED(rv)) { return SendFailedAsyncOpen(rv); } + nsCOMPtr triggeringPrincipal = + mozilla::ipc::PrincipalInfoToPrincipal(aTriggeringPrincipalInfo, &rv); + if (NS_FAILED(rv)) { + return SendFailedAsyncOpen(rv); + } bool appOffline = false; uint32_t appId = GetAppId(); @@ -239,15 +245,16 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI, } nsCOMPtr channel; - rv = NS_NewChannel(getter_AddRefs(channel), - uri, - requestingPrincipal, - aSecurityFlags, - aContentPolicyType, - nullptr, // loadGroup - nullptr, // aCallbacks - loadFlags, - ios); + rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), + uri, + requestingPrincipal, + triggeringPrincipal, + aSecurityFlags, + aContentPolicyType, + nullptr, // loadGroup + nullptr, // aCallbacks + loadFlags, + ios); if (NS_FAILED(rv)) return SendFailedAsyncOpen(rv); diff --git a/netwerk/protocol/http/HttpChannelParent.h b/netwerk/protocol/http/HttpChannelParent.h index a0bf5130ff58..8954a63f0024 100644 --- a/netwerk/protocol/http/HttpChannelParent.h +++ b/netwerk/protocol/http/HttpChannelParent.h @@ -110,6 +110,7 @@ protected: const bool& allowSpdy, const OptionalFileDescriptorSet& aFds, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType); diff --git a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl index d3a815f2c485..092ed1e80499 100644 --- a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl +++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl @@ -23,6 +23,7 @@ parent: Init(URIParams uri, PrincipalInfo requestingPrincipalInfo, + PrincipalInfo triggeringPrincipalInfo, uint32_t securityFlags, uint32_t contentPolicyType); AsyncOpen(URIParams originalURI, diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp index 29234633be5a..a6f70081f0f2 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp @@ -93,25 +93,31 @@ WyciwygChannelChild::Init(nsIURI* uri) SerializeURI(uri, serializedUri); // propagate loadInfo - mozilla::ipc::PrincipalInfo principalInfo; + mozilla::ipc::PrincipalInfo requestingPrincipalInfo; + mozilla::ipc::PrincipalInfo triggeringPrincipalInfo; uint32_t securityFlags; uint32_t policyType; if (mLoadInfo) { mozilla::ipc::PrincipalToPrincipalInfo(mLoadInfo->LoadingPrincipal(), - &principalInfo); + &requestingPrincipalInfo); + mozilla::ipc::PrincipalToPrincipalInfo(mLoadInfo->TriggeringPrincipal(), + &triggeringPrincipalInfo); securityFlags = mLoadInfo->GetSecurityFlags(); policyType = mLoadInfo->GetContentPolicyType(); } else { // use default values if no loadInfo is provided mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(), - &principalInfo); + &requestingPrincipalInfo); + mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(), + &triggeringPrincipalInfo); securityFlags = nsILoadInfo::SEC_NORMAL; policyType = nsIContentPolicy::TYPE_OTHER; } SendInit(serializedUri, - principalInfo, + requestingPrincipalInfo, + triggeringPrincipalInfo, securityFlags, policyType); return NS_OK; diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index 1857d87e78de..9f0b4f6bc2eb 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -62,6 +62,7 @@ NS_IMPL_ISUPPORTS(WyciwygChannelParent, bool WyciwygChannelParent::RecvInit(const URIParams& aURI, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType) { @@ -86,16 +87,23 @@ WyciwygChannelParent::RecvInit(const URIParams& aURI, return SendCancelEarly(rv); } + nsCOMPtr triggeringPrincipal = + mozilla::ipc::PrincipalInfoToPrincipal(aTriggeringPrincipalInfo, &rv); + if (NS_FAILED(rv)) { + return SendCancelEarly(rv); + } + nsCOMPtr chan; - rv = NS_NewChannel(getter_AddRefs(chan), - uri, - requestingPrincipal, - aSecurityFlags, - aContentPolicyType, - nullptr, // loadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, - ios); + rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(chan), + uri, + requestingPrincipal, + triggeringPrincipal, + aSecurityFlags, + aContentPolicyType, + nullptr, // loadGroup + nullptr, // aCallbacks + nsIRequest::LOAD_NORMAL, + ios); if (NS_FAILED(rv)) return SendCancelEarly(rv); diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h index cf5060f3b118..be662d9abcb1 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h @@ -37,6 +37,7 @@ protected: virtual bool RecvInit(const URIParams& uri, const ipc::PrincipalInfo& aRequestingPrincipalInfo, + const ipc::PrincipalInfo& aTriggeringPrincipalInfo, const uint32_t& aSecurityFlags, const uint32_t& aContentPolicyType) MOZ_OVERRIDE; virtual bool RecvAsyncOpen(const URIParams& original,