Bug 1376496 - Part 5 - Don't send child nsILoadInfo's to the parent for requests. r=ckerschb

MozReview-Commit-ID: G8fCPL7aLT0

--HG--
extra : rebase_source : 3c49008eaedf65befffc2f0327529817d9879cd5
This commit is contained in:
Haik Aftandilian 2017-07-20 11:49:29 -07:00
Родитель 546c76f86e
Коммит 9ab2f249f0
5 изменённых файлов: 16 добавлений и 46 удалений

Просмотреть файл

@ -962,7 +962,6 @@ NeckoParent::RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWind
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
NeckoParent::RecvGetExtensionStream(const URIParams& aURI, NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
const LoadInfoArgs& aLoadInfo,
GetExtensionStreamResolver&& aResolve) GetExtensionStreamResolver&& aResolve)
{ {
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI); nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
@ -970,13 +969,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
return IPC_FAIL_NO_REASON(this); return IPC_FAIL_NO_REASON(this);
} }
nsCOMPtr<nsILoadInfo> deserializedLoadInfo;
nsresult rv;
rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo));
if (NS_FAILED(rv)) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton()); RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
MOZ_ASSERT(ph); MOZ_ASSERT(ph);
@ -991,9 +983,7 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
AutoIPCStream autoStream; AutoIPCStream autoStream;
nsCOMPtr<nsIInputStream> inputStream; nsCOMPtr<nsIInputStream> inputStream;
bool terminateSender = true; bool terminateSender = true;
auto inputStreamOrReason = ph->NewStream(deserializedURI, auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender);
deserializedLoadInfo,
&terminateSender);
if (inputStreamOrReason.isOk()) { if (inputStreamOrReason.isOk()) {
inputStream = inputStreamOrReason.unwrap(); inputStream = inputStreamOrReason.unwrap();
ContentParent* contentParent = static_cast<ContentParent*>(Manager()); ContentParent* contentParent = static_cast<ContentParent*>(Manager());
@ -1014,7 +1004,6 @@ NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
NeckoParent::RecvGetExtensionFD(const URIParams& aURI, NeckoParent::RecvGetExtensionFD(const URIParams& aURI,
const OptionalLoadInfoArgs& aLoadInfo,
GetExtensionFDResolver&& aResolve) GetExtensionFDResolver&& aResolve)
{ {
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI); nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
@ -1022,13 +1011,6 @@ NeckoParent::RecvGetExtensionFD(const URIParams& aURI,
return IPC_FAIL_NO_REASON(this); return IPC_FAIL_NO_REASON(this);
} }
nsCOMPtr<nsILoadInfo> deserializedLoadInfo;
nsresult rv;
rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(deserializedLoadInfo));
if (NS_FAILED(rv)) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton()); RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
MOZ_ASSERT(ph); 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 // an extension is allowed to access via moz-extension URI's should be
// accepted. // accepted.
bool terminateSender = true; bool terminateSender = true;
auto result = ph->NewFD(deserializedURI, deserializedLoadInfo, auto result = ph->NewFD(deserializedURI, &terminateSender, aResolve);
&terminateSender, aResolve);
if (result.isErr() && terminateSender) { if (result.isErr() && terminateSender) {
return IPC_FAIL_NO_REASON(this); return IPC_FAIL_NO_REASON(this);

Просмотреть файл

@ -240,12 +240,10 @@ protected:
/* WebExtensions */ /* WebExtensions */
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvGetExtensionStream(const URIParams& aURI, RecvGetExtensionStream(const URIParams& aURI,
const LoadInfoArgs& aLoadInfo,
GetExtensionStreamResolver&& aResolve) override; GetExtensionStreamResolver&& aResolve) override;
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvGetExtensionFD(const URIParams& aURI, RecvGetExtensionFD(const URIParams& aURI,
const OptionalLoadInfoArgs& aLoadInfo,
GetExtensionFDResolver&& aResolve) override; GetExtensionFDResolver&& aResolve) override;
}; };

Просмотреть файл

@ -131,10 +131,8 @@ parent:
/** /**
* WebExtension-specific remote resource loading * WebExtension-specific remote resource loading
*/ */
async GetExtensionStream(URIParams uri, LoadInfoArgs loadInfo) returns async GetExtensionStream(URIParams uri) returns (OptionalIPCStream stream);
(OptionalIPCStream stream); async GetExtensionFD(URIParams uri) returns (FileDescriptor fd);
async GetExtensionFD(URIParams uri, OptionalLoadInfoArgs loadInfo) returns
(FileDescriptor fd);
child: child:
/* /*

Просмотреть файл

@ -20,6 +20,7 @@
#include "LoadInfo.h" #include "LoadInfo.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsContentUtils.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsIFileChannel.h" #include "nsIFileChannel.h"
#include "nsIFileStreams.h" #include "nsIFileStreams.h"
@ -253,14 +254,10 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener,
mozilla::ipc::URIParams uri; mozilla::ipc::URIParams uri;
SerializeURI(mURI, uri); SerializeURI(mURI, uri);
// Serialize the LoadInfo to send to parent
OptionalLoadInfoArgs loadInfo;
NS_TRY(mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfo));
RefPtr<ExtensionStreamGetter> self = this; RefPtr<ExtensionStreamGetter> self = this;
if (mIsJarChannel) { if (mIsJarChannel) {
// Request an FD for this moz-extension URI // Request an FD for this moz-extension URI
gNeckoChild->SendGetExtensionFD(uri, loadInfo)->Then( gNeckoChild->SendGetExtensionFD(uri)->Then(
mMainThreadEventTarget, mMainThreadEventTarget,
__func__, __func__,
[self] (const FileDescriptor& fd) { [self] (const FileDescriptor& fd) {
@ -274,7 +271,7 @@ ExtensionStreamGetter::GetAsync(nsIStreamListener* aListener,
} }
// Request an input stream for this moz-extension URI // Request an input stream for this moz-extension URI
gNeckoChild->SendGetExtensionStream(uri, loadInfo)->Then( gNeckoChild->SendGetExtensionStream(uri)->Then(
mMainThreadEventTarget, mMainThreadEventTarget,
__func__, __func__,
[self] (const OptionalIPCStream& stream) { [self] (const OptionalIPCStream& stream) {
@ -555,13 +552,10 @@ ExtensionProtocolHandler::DevRepoContains(nsIFile* aRequestedFile,
#endif /* !defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) */ #endif /* !defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) */
Result<nsCOMPtr<nsIInputStream>, nsresult> Result<nsCOMPtr<nsIInputStream>, nsresult>
ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, ExtensionProtocolHandler::NewStream(nsIURI* aChildURI, bool* aTerminateSender)
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender)
{ {
MOZ_ASSERT(!IsNeckoChild()); MOZ_ASSERT(!IsNeckoChild());
NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG); 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); NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG);
*aTerminateSender = true; *aTerminateSender = true;
@ -614,10 +608,15 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI,
* channel is a file channel. * 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<nsIChannel> channel; nsCOMPtr<nsIChannel> channel;
NS_TRY(NS_NewChannelInternal(getter_AddRefs(channel), NS_TRY(NS_NewChannel(getter_AddRefs(channel),
aChildURI, aChildURI,
aChildLoadInfo)); 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 should be a file channel. It should never be a JAR
// channel because we only request remote streams for unpacked // channel because we only request remote streams for unpacked
@ -671,13 +670,11 @@ ExtensionProtocolHandler::NewStream(nsIURI* aChildURI,
Result<Ok, nsresult> Result<Ok, nsresult>
ExtensionProtocolHandler::NewFD(nsIURI* aChildURI, ExtensionProtocolHandler::NewFD(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender, bool* aTerminateSender,
NeckoParent::GetExtensionFDResolver& aResolve) NeckoParent::GetExtensionFDResolver& aResolve)
{ {
MOZ_ASSERT(!IsNeckoChild()); MOZ_ASSERT(!IsNeckoChild());
NS_TRY(aChildURI ? NS_OK : NS_ERROR_INVALID_ARG); 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); NS_TRY(aTerminateSender ? NS_OK : NS_ERROR_INVALID_ARG);
*aTerminateSender = true; *aTerminateSender = true;

Просмотреть файл

@ -32,7 +32,6 @@ public:
* *
* @param aChildURI a moz-extension URI sent from the child that refers * @param aChildURI a moz-extension URI sent from the child that refers
* to a web accessible resource file in an enabled unpacked extension * 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 * @param aTerminateSender out param set to true when the params are invalid
* and indicate the child should be terminated. If |aChildURI| is * and indicate the child should be terminated. If |aChildURI| is
* not a moz-extension URI, the child is in an invalid state and * not a moz-extension URI, the child is in an invalid state and
@ -46,7 +45,6 @@ public:
* set to true. * set to true.
*/ */
Result<nsCOMPtr<nsIInputStream>, nsresult> NewStream(nsIURI* aChildURI, Result<nsCOMPtr<nsIInputStream>, nsresult> NewStream(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender); bool* aTerminateSender);
/** /**
@ -55,7 +53,6 @@ public:
* *
* @param aChildURI a moz-extension URI sent from the child that refers * @param aChildURI a moz-extension URI sent from the child that refers
* to a web accessible resource file in an enabled unpacked extension * 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 * @param aTerminateSender out param set to true when the params are invalid
* and indicate the child should be terminated. If |aChildURI| is * and indicate the child should be terminated. If |aChildURI| is
* not a moz-extension URI, the child is in an invalid state and * not a moz-extension URI, the child is in an invalid state and
@ -71,7 +68,6 @@ public:
* set to true. * set to true.
*/ */
Result<Ok, nsresult> NewFD(nsIURI* aChildURI, Result<Ok, nsresult> NewFD(nsIURI* aChildURI,
nsILoadInfo* aChildLoadInfo,
bool* aTerminateSender, bool* aTerminateSender,
NeckoParent::GetExtensionFDResolver& aResolve); NeckoParent::GetExtensionFDResolver& aResolve);