mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1131406 - Fix IPC serialization for nsHostObjectURI. r=billm
This commit is contained in:
parent
3ad1c2984e
commit
458e781121
@ -79,6 +79,7 @@ EXPORTS += [
|
||||
'nsGkAtomList.h',
|
||||
'nsGkAtoms.h',
|
||||
'nsHostObjectProtocolHandler.h',
|
||||
'nsHostObjectURI.h',
|
||||
'nsIAttribute.h',
|
||||
'nsIContent.h',
|
||||
'nsIContentInlines.h',
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -9,6 +10,9 @@
|
||||
#include "nsIObjectOutputStream.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
|
||||
|
||||
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
|
||||
@ -81,6 +85,56 @@ nsHostObjectURI::Write(nsIObjectOutputStream* aStream)
|
||||
true);
|
||||
}
|
||||
|
||||
// nsIIPCSerializableURI methods:
|
||||
void
|
||||
nsHostObjectURI::Serialize(mozilla::ipc::URIParams& aParams)
|
||||
{
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
HostObjectURIParams hostParams;
|
||||
URIParams simpleParams;
|
||||
|
||||
nsSimpleURI::Serialize(simpleParams);
|
||||
hostParams.simpleParams() = simpleParams;
|
||||
|
||||
if (mPrincipal) {
|
||||
PrincipalInfo info;
|
||||
nsresult rv = PrincipalToPrincipalInfo(mPrincipal, &info);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
hostParams.principal() = info;
|
||||
} else {
|
||||
hostParams.principal() = void_t();
|
||||
}
|
||||
|
||||
aParams = hostParams;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHostObjectURI::Deserialize(const mozilla::ipc::URIParams& aParams)
|
||||
{
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
if (aParams.type() != URIParams::THostObjectURIParams) {
|
||||
NS_ERROR("Received unknown parameters from the other process!");
|
||||
return false;
|
||||
}
|
||||
|
||||
const HostObjectURIParams& hostParams = aParams.get_HostObjectURIParams();
|
||||
|
||||
if (!nsSimpleURI::Deserialize(hostParams.simpleParams())) {
|
||||
return false;
|
||||
}
|
||||
if (hostParams.principal().type() == OptionalPrincipalInfo::Tvoid_t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mPrincipal = PrincipalInfoToPrincipal(hostParams.principal().get_PrincipalInfo());
|
||||
return mPrincipal != nullptr;
|
||||
}
|
||||
|
||||
// nsIURI methods:
|
||||
nsresult
|
||||
nsHostObjectURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsISerializable.h"
|
||||
#include "nsIURIWithPrincipal.h"
|
||||
#include "nsSimpleURI.h"
|
||||
#include "nsIIPCSerializableURI.h"
|
||||
|
||||
/**
|
||||
* These URIs refer to host objects: Blobs, with scheme "blob",
|
||||
@ -33,6 +34,7 @@ public:
|
||||
NS_DECL_NSIURIWITHPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
NS_DECL_NSIIPCSERIALIZABLEURI
|
||||
|
||||
// Override CloneInternal() and EqualsInternal()
|
||||
virtual nsresult CloneInternal(RefHandlingEnum aRefHandlingMode,
|
||||
|
@ -2,6 +2,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
@ -25,5 +27,11 @@ union PrincipalInfo
|
||||
NullPrincipalInfo;
|
||||
};
|
||||
|
||||
union OptionalPrincipalInfo
|
||||
{
|
||||
void_t;
|
||||
PrincipalInfo;
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
@ -69,6 +71,12 @@ struct NullPrincipalURIParams
|
||||
// Purposefully empty. Null principal URIs do not round-trip.
|
||||
};
|
||||
|
||||
struct HostObjectURIParams
|
||||
{
|
||||
SimpleURIParams simpleParams;
|
||||
OptionalPrincipalInfo principal;
|
||||
};
|
||||
|
||||
union URIParams
|
||||
{
|
||||
SimpleURIParams;
|
||||
@ -78,6 +86,7 @@ union URIParams
|
||||
NullPrincipalURIParams;
|
||||
JSURIParams;
|
||||
SimpleNestedURIParams;
|
||||
HostObjectURIParams;
|
||||
};
|
||||
|
||||
union OptionalURIParams
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsID.h"
|
||||
#include "nsJARURI.h"
|
||||
#include "nsIIconURI.h"
|
||||
#include "nsHostObjectURI.h"
|
||||
#include "nsNullPrincipalURI.h"
|
||||
#include "nsJSProtocolHandler.h"
|
||||
#include "nsNetCID.h"
|
||||
@ -105,6 +106,10 @@ DeserializeURI(const URIParams& aParams)
|
||||
serializable = new nsSimpleNestedURI();
|
||||
break;
|
||||
|
||||
case URIParams::THostObjectURIParams:
|
||||
serializable = new nsHostObjectURI();
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown params!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user