mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-29 17:40:42 +00:00
Bug 918090 - Let NeckoParent get the app:// uri when remoting file opening. r=jduell
This commit is contained in:
parent
e55134bbc7
commit
a70d18a2ff
@ -349,7 +349,7 @@ nsJARChannel::LookupFile()
|
||||
rv = mJarBaseURI->GetScheme(scheme);
|
||||
if (NS_SUCCEEDED(rv) && scheme.EqualsLiteral("remoteopenfile")) {
|
||||
nsRefPtr<RemoteOpenFileChild> remoteFile = new RemoteOpenFileChild();
|
||||
rv = remoteFile->Init(mJarBaseURI);
|
||||
rv = remoteFile->Init(mJarBaseURI, mAppURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mJarFile = remoteFile;
|
||||
|
||||
|
@ -189,7 +189,7 @@ NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child)
|
||||
}
|
||||
|
||||
PRemoteOpenFileChild*
|
||||
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&)
|
||||
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&, const OptionalURIParams&)
|
||||
{
|
||||
// We don't allocate here: instead we always use IPDL constructor that takes
|
||||
// an existing RemoteOpenFileChild
|
||||
|
@ -47,7 +47,8 @@ protected:
|
||||
const uint16_t& aBacklog,
|
||||
const nsString& aBinaryType);
|
||||
virtual bool DeallocPTCPServerSocketChild(PTCPServerSocketChild*);
|
||||
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&);
|
||||
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&,
|
||||
const OptionalURIParams&);
|
||||
virtual bool DeallocPRemoteOpenFileChild(PRemoteOpenFileChild*);
|
||||
};
|
||||
|
||||
|
@ -348,7 +348,8 @@ NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor)
|
||||
}
|
||||
|
||||
PRemoteOpenFileParent*
|
||||
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
|
||||
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
|
||||
const OptionalURIParams& aAppURI)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
|
||||
@ -447,8 +448,8 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
|
||||
printf_stderr("NeckoParent::AllocPRemoteOpenFile: "
|
||||
"FATAL error: app without webapps-manage permission is "
|
||||
"requesting file '%s' but is only allowed to open its "
|
||||
"own application.zip: KILLING CHILD PROCESS\n",
|
||||
requestedPath.get());
|
||||
"own application.zip at %s: KILLING CHILD PROCESS\n",
|
||||
requestedPath.get(), mustMatch.get());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -460,7 +461,8 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
|
||||
|
||||
bool
|
||||
NeckoParent::RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
|
||||
const URIParams& aFileURI)
|
||||
const URIParams& aFileURI,
|
||||
const OptionalURIParams& aAppURI)
|
||||
{
|
||||
return static_cast<RemoteOpenFileParent*>(aActor)->OpenSendCloseDelete();
|
||||
}
|
||||
|
@ -88,10 +88,12 @@ protected:
|
||||
virtual bool DeallocPWebSocketParent(PWebSocketParent*);
|
||||
virtual PTCPSocketParent* AllocPTCPSocketParent();
|
||||
|
||||
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI)
|
||||
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI,
|
||||
const OptionalURIParams& aAppURI)
|
||||
MOZ_OVERRIDE;
|
||||
virtual bool RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
|
||||
const URIParams& aFileURI)
|
||||
const URIParams& aFileURI,
|
||||
const OptionalURIParams& aAppURI)
|
||||
MOZ_OVERRIDE;
|
||||
virtual bool DeallocPRemoteOpenFileParent(PRemoteOpenFileParent* aActor)
|
||||
MOZ_OVERRIDE;
|
||||
|
@ -54,7 +54,7 @@ parent:
|
||||
|
||||
PWebSocket(PBrowser browser, SerializedLoadContext loadContext);
|
||||
PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType);
|
||||
PRemoteOpenFile(URIParams fileuri);
|
||||
PRemoteOpenFile(URIParams fileuri, OptionalURIParams appuri);
|
||||
|
||||
HTMLDNSPrefetch(nsString hostname, uint16_t flags);
|
||||
CancelHTMLDNSPrefetch(nsString hostname, uint16_t flags, nsresult reason);
|
||||
|
@ -75,6 +75,9 @@ RemoteOpenFileChild::RemoteOpenFileChild(const RemoteOpenFileChild& other)
|
||||
{
|
||||
// Note: don't clone mListener or we'll have a refcount leak.
|
||||
other.mURI->Clone(getter_AddRefs(mURI));
|
||||
if (other.mAppURI) {
|
||||
other.mAppURI->Clone(getter_AddRefs(mAppURI));
|
||||
}
|
||||
other.mFile->Clone(getter_AddRefs(mFile));
|
||||
}
|
||||
|
||||
@ -93,12 +96,16 @@ RemoteOpenFileChild::~RemoteOpenFileChild()
|
||||
}
|
||||
|
||||
nsresult
|
||||
RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri)
|
||||
RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri)
|
||||
{
|
||||
if (!aRemoteOpenUri) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aAppUri) {
|
||||
aAppUri->Clone(getter_AddRefs(mAppURI));
|
||||
}
|
||||
|
||||
nsAutoCString scheme;
|
||||
nsresult rv = aRemoteOpenUri->GetScheme(scheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -183,8 +190,10 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
|
||||
|
||||
URIParams uri;
|
||||
SerializeURI(mURI, uri);
|
||||
OptionalURIParams appUri;
|
||||
SerializeURI(mAppURI, appUri);
|
||||
|
||||
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri);
|
||||
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, appUri);
|
||||
|
||||
// The chrome process now has a logical ref to us until it calls Send__delete.
|
||||
AddIPDLReference();
|
||||
|
@ -63,8 +63,9 @@ public:
|
||||
NS_DECL_NSIFILE
|
||||
NS_DECL_NSIHASHABLE
|
||||
|
||||
// URI must be scheme 'remoteopenfile://': otherwise looks like a file:// uri.
|
||||
nsresult Init(nsIURI* aRemoteOpenUri);
|
||||
// aRemoteOpenUri must be scheme 'remoteopenfile://': otherwise looks like
|
||||
// a file:// uri.
|
||||
nsresult Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri);
|
||||
|
||||
// Send message to parent to tell it to open file handle for file.
|
||||
// TabChild is required, for IPC security.
|
||||
@ -100,6 +101,7 @@ protected:
|
||||
// regular nsIFile object, that we forward most calls to.
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mAppURI;
|
||||
nsCOMPtr<nsIRemoteOpenFileListener> mListener;
|
||||
nsRefPtr<TabChild> mTabChild;
|
||||
PRFileDesc* mNSPRFileDesc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user