diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index de12d0a3678b..a2b043d9b819 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -962,7 +962,6 @@ NeckoParent::RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWind mozilla::ipc::IPCResult NeckoParent::RecvGetExtensionStream(const URIParams& aURI, - const LoadInfoArgs& aLoadInfo, GetExtensionStreamResolver&& aResolve) { nsCOMPtr deserializedURI = DeserializeURI(aURI); @@ -970,13 +969,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI, return IPC_FAIL_NO_REASON(this); } - nsCOMPtr deserializedLoadInfo; - nsresult rv; - rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo)); - if (NS_FAILED(rv)) { - return IPC_FAIL_NO_REASON(this); - } - RefPtr ph(ExtensionProtocolHandler::GetSingleton()); MOZ_ASSERT(ph); @@ -991,9 +983,7 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI, AutoIPCStream autoStream; nsCOMPtr inputStream; bool terminateSender = true; - auto inputStreamOrReason = ph->NewStream(deserializedURI, - deserializedLoadInfo, - &terminateSender); + auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender); if (inputStreamOrReason.isOk()) { inputStream = inputStreamOrReason.unwrap(); ContentParent* contentParent = static_cast(Manager()); @@ -1014,7 +1004,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI, mozilla::ipc::IPCResult NeckoParent::RecvGetExtensionFD(const URIParams& aURI, - const OptionalLoadInfoArgs& aLoadInfo, GetExtensionFDResolver&& aResolve) { nsCOMPtr deserializedURI = DeserializeURI(aURI); @@ -1022,13 +1011,6 @@ NeckoParent::RecvGetExtensionFD(const URIParams& aURI, return IPC_FAIL_NO_REASON(this); } - nsCOMPtr deserializedLoadInfo; - nsresult rv; - rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo)); - if (NS_FAILED(rv)) { - return IPC_FAIL_NO_REASON(this); - } - RefPtr ph(ExtensionProtocolHandler::GetSingleton()); MOZ_ASSERT(ph); @@ -1041,8 +1023,7 @@ NeckoParent::RecvGetExtensionFD(const URIParams& aURI, // an extension is allowed to access via moz-extension URI's should be // accepted. bool terminateSender = true; - auto result = ph->NewFD(deserializedURI, deserializedLoadInfo, - &terminateSender, aResolve); + auto result = ph->NewFD(deserializedURI, &terminateSender, aResolve); if (result.isErr() && terminateSender) { return IPC_FAIL_NO_REASON(this); diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 8897085dd335..5f089b978de6 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -240,12 +240,10 @@ protected: /* WebExtensions */ virtual mozilla::ipc::IPCResult RecvGetExtensionStream(const URIParams& aURI, - const LoadInfoArgs& aLoadInfo, GetExtensionStreamResolver&& aResolve) override; virtual mozilla::ipc::IPCResult RecvGetExtensionFD(const URIParams& aURI, - const OptionalLoadInfoArgs& aLoadInfo, GetExtensionFDResolver&& aResolve) override; }; diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl index beed972b5f5c..55756a2ec5be 100644 --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -131,10 +131,8 @@ parent: /** * WebExtension-specific remote resource loading */ - async GetExtensionStream(URIParams uri, LoadInfoArgs loadInfo) returns - (OptionalIPCStream stream); - async GetExtensionFD(URIParams uri, OptionalLoadInfoArgs loadInfo) returns - (FileDescriptor fd); + async GetExtensionStream(URIParams uri) returns (OptionalIPCStream stream); + async GetExtensionFD(URIParams uri) returns (FileDescriptor fd); child: /* diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp index 42a92af7e214..964bec3c6f3c 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -20,6 +20,7 @@ #include "LoadInfo.h" #include "nsContentUtils.h" #include "nsServiceManagerUtils.h" +#include "nsContentUtils.h" #include "nsIFile.h" #include "nsIFileChannel.h" #include "nsIFileStreams.h" @@ -253,14 +254,10 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener, mozilla::ipc::URIParams uri; SerializeURI(mURI, uri); - // Serialize the LoadInfo to send to parent - OptionalLoadInfoArgs loadInfo; - NS_TRY(mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfo)); - RefPtr self = this; if (mIsJarChannel) { // Request an FD for this moz-extension URI - gNeckoChild->SendGetExtensionFD(uri, loadInfo)->Then( + gNeckoChild->SendGetExtensionFD(uri)->Then( mMainThreadEventTarget, __func__, [self] (const FileDescriptor& fd) { @@ -274,7 +271,7 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener, } // Request an input stream for this moz-extension URI - gNeckoChild->SendGetExtensionStream(uri, loadInfo)->Then( + gNeckoChild->SendGetExtensionStream(uri)->Then( mMainThreadEventTarget, __func__, [self] (const OptionalIPCStream& stream) { @@ -555,13 +552,10 @@ ExtensionProtocolHandler::DevRepoContains(nsIFile* aRequestedFile, #endif /* !defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) */ Result, nsresult> -ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, - nsILoadInfo* aChildLoadInfo, - bool* aTerminateSender) +ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, bool* aTerminateSender) { MOZ_ASSERT(!IsNeckoChild()); NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG); - NS_TRY(aChildLoadInfo ? NS_OK : NS_ERROR_INVALID_ARG); NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG); *aTerminateSender = true; @@ -614,10 +608,15 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, * channel is a file channel. */ + // We use the system principal to get a file channel for the request, + // but only after we've checked (above) that the child URI is of + // moz-extension scheme and that the URI host maps to a directory. nsCOMPtr channel; - NS_TRY(NS_NewChannelInternal(getter_AddRefs(channel), - aChildURI, - aChildLoadInfo)); + NS_TRY(NS_NewChannel(getter_AddRefs(channel), + aChildURI, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, + nsIContentPolicy::TYPE_OTHER)); // Channel should be a file channel. It should never be a JAR // channel because we only request remote streams for unpacked @@ -671,13 +670,11 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, Result ExtensionProtocolHandler::NewFD(nsIURI* aChildURI, - nsILoadInfo* aChildLoadInfo, bool* aTerminateSender, NeckoParent::GetExtensionFDResolver& aResolve) { MOZ_ASSERT(!IsNeckoChild()); NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG); - NS_TRY(aChildLoadInfo ? NS_OK : NS_ERROR_INVALID_ARG); NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG); *aTerminateSender = true; diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.h b/netwerk/protocol/res/ExtensionProtocolHandler.h index bb4efc304759..01cb695ea14b 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.h +++ b/netwerk/protocol/res/ExtensionProtocolHandler.h @@ -32,7 +32,6 @@ public: * * @param aChildURI a moz-extension URI sent from the child that refers * to a web accessible resource file in an enabled unpacked extension - * @param aChildLoadInfo the loadinfo for the request sent from the child * @param aTerminateSender out param set to true when the params are invalid * and indicate the child should be terminated. If |aChildURI| is * not a moz-extension URI, the child is in an invalid state and @@ -46,7 +45,6 @@ public: * set to true. */ Result, nsresult> NewStream(nsIURI* aChildURI, - nsILoadInfo* aChildLoadInfo, bool* aTerminateSender); /** @@ -55,7 +53,6 @@ public: * * @param aChildURI a moz-extension URI sent from the child that refers * to a web accessible resource file in an enabled unpacked extension - * @param aChildLoadInfo the loadinfo for the request sent from the child * @param aTerminateSender out param set to true when the params are invalid * and indicate the child should be terminated. If |aChildURI| is * not a moz-extension URI, the child is in an invalid state and @@ -71,7 +68,6 @@ public: * set to true. */ Result NewFD(nsIURI* aChildURI, - nsILoadInfo* aChildLoadInfo, bool* aTerminateSender, NeckoParent::GetExtensionFDResolver& aResolve);