Skip to content

Commit a70d18a

Browse files
author
Fabrice Desré
committed
Bug 918090 - Let NeckoParent get the app:// uri when remoting file opening. r=jduell
1 parent e55134b commit a70d18a

File tree

8 files changed

+30
-14
lines changed

8 files changed

+30
-14
lines changed

modules/libjar/nsJARChannel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ nsJARChannel::LookupFile()
349349
rv = mJarBaseURI->GetScheme(scheme);
350350
if (NS_SUCCEEDED(rv) && scheme.EqualsLiteral("remoteopenfile")) {
351351
nsRefPtr<RemoteOpenFileChild> remoteFile = new RemoteOpenFileChild();
352-
rv = remoteFile->Init(mJarBaseURI);
352+
rv = remoteFile->Init(mJarBaseURI, mAppURI);
353353
NS_ENSURE_SUCCESS(rv, rv);
354354
mJarFile = remoteFile;
355355

netwerk/ipc/NeckoChild.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child)
189189
}
190190

191191
PRemoteOpenFileChild*
192-
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&)
192+
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&, const OptionalURIParams&)
193193
{
194194
// We don't allocate here: instead we always use IPDL constructor that takes
195195
// an existing RemoteOpenFileChild

netwerk/ipc/NeckoChild.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class NeckoChild :
4747
const uint16_t& aBacklog,
4848
const nsString& aBinaryType);
4949
virtual bool DeallocPTCPServerSocketChild(PTCPServerSocketChild*);
50-
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&);
50+
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&,
51+
const OptionalURIParams&);
5152
virtual bool DeallocPRemoteOpenFileChild(PRemoteOpenFileChild*);
5253
};
5354

netwerk/ipc/NeckoParent.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor)
348348
}
349349

350350
PRemoteOpenFileParent*
351-
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
351+
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
352+
const OptionalURIParams& aAppURI)
352353
{
353354
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
354355
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
@@ -447,8 +448,8 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
447448
printf_stderr("NeckoParent::AllocPRemoteOpenFile: "
448449
"FATAL error: app without webapps-manage permission is "
449450
"requesting file '%s' but is only allowed to open its "
450-
"own application.zip: KILLING CHILD PROCESS\n",
451-
requestedPath.get());
451+
"own application.zip at %s: KILLING CHILD PROCESS\n",
452+
requestedPath.get(), mustMatch.get());
452453
return nullptr;
453454
}
454455
}
@@ -460,7 +461,8 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
460461

461462
bool
462463
NeckoParent::RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
463-
const URIParams& aFileURI)
464+
const URIParams& aFileURI,
465+
const OptionalURIParams& aAppURI)
464466
{
465467
return static_cast<RemoteOpenFileParent*>(aActor)->OpenSendCloseDelete();
466468
}

netwerk/ipc/NeckoParent.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ class NeckoParent :
8888
virtual bool DeallocPWebSocketParent(PWebSocketParent*);
8989
virtual PTCPSocketParent* AllocPTCPSocketParent();
9090

91-
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI)
91+
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI,
92+
const OptionalURIParams& aAppURI)
9293
MOZ_OVERRIDE;
9394
virtual bool RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
94-
const URIParams& aFileURI)
95+
const URIParams& aFileURI,
96+
const OptionalURIParams& aAppURI)
9597
MOZ_OVERRIDE;
9698
virtual bool DeallocPRemoteOpenFileParent(PRemoteOpenFileParent* aActor)
9799
MOZ_OVERRIDE;

netwerk/ipc/PNecko.ipdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ parent:
5454

5555
PWebSocket(PBrowser browser, SerializedLoadContext loadContext);
5656
PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType);
57-
PRemoteOpenFile(URIParams fileuri);
57+
PRemoteOpenFile(URIParams fileuri, OptionalURIParams appuri);
5858

5959
HTMLDNSPrefetch(nsString hostname, uint16_t flags);
6060
CancelHTMLDNSPrefetch(nsString hostname, uint16_t flags, nsresult reason);

netwerk/ipc/RemoteOpenFileChild.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ RemoteOpenFileChild::RemoteOpenFileChild(const RemoteOpenFileChild& other)
7575
{
7676
// Note: don't clone mListener or we'll have a refcount leak.
7777
other.mURI->Clone(getter_AddRefs(mURI));
78+
if (other.mAppURI) {
79+
other.mAppURI->Clone(getter_AddRefs(mAppURI));
80+
}
7881
other.mFile->Clone(getter_AddRefs(mFile));
7982
}
8083

@@ -93,12 +96,16 @@ RemoteOpenFileChild::~RemoteOpenFileChild()
9396
}
9497

9598
nsresult
96-
RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri)
99+
RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri)
97100
{
98101
if (!aRemoteOpenUri) {
99102
return NS_ERROR_INVALID_ARG;
100103
}
101104

105+
if (aAppUri) {
106+
aAppUri->Clone(getter_AddRefs(mAppURI));
107+
}
108+
102109
nsAutoCString scheme;
103110
nsresult rv = aRemoteOpenUri->GetScheme(scheme);
104111
NS_ENSURE_SUCCESS(rv, rv);
@@ -183,8 +190,10 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
183190

184191
URIParams uri;
185192
SerializeURI(mURI, uri);
193+
OptionalURIParams appUri;
194+
SerializeURI(mAppURI, appUri);
186195

187-
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri);
196+
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, appUri);
188197

189198
// The chrome process now has a logical ref to us until it calls Send__delete.
190199
AddIPDLReference();

netwerk/ipc/RemoteOpenFileChild.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ class RemoteOpenFileChild MOZ_FINAL
6363
NS_DECL_NSIFILE
6464
NS_DECL_NSIHASHABLE
6565

66-
// URI must be scheme 'remoteopenfile://': otherwise looks like a file:// uri.
67-
nsresult Init(nsIURI* aRemoteOpenUri);
66+
// aRemoteOpenUri must be scheme 'remoteopenfile://': otherwise looks like
67+
// a file:// uri.
68+
nsresult Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri);
6869

6970
// Send message to parent to tell it to open file handle for file.
7071
// TabChild is required, for IPC security.
@@ -100,6 +101,7 @@ class RemoteOpenFileChild MOZ_FINAL
100101
// regular nsIFile object, that we forward most calls to.
101102
nsCOMPtr<nsIFile> mFile;
102103
nsCOMPtr<nsIURI> mURI;
104+
nsCOMPtr<nsIURI> mAppURI;
103105
nsCOMPtr<nsIRemoteOpenFileListener> mListener;
104106
nsRefPtr<TabChild> mTabChild;
105107
PRFileDesc* mNSPRFileDesc;

0 commit comments

Comments
 (0)