Bug 1832701 - Part 2: Add IPCTransferable for clipboard write parameters; r=nika
Move IPCTransferable* into a separated file to avoid circular dependency and use `hg cp` in order to keep the history. Differential Revision: https://phabricator.services.mozilla.com/D178070
This commit is contained in:
@@ -7944,6 +7944,28 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsContentUtils::IPCTransferableToTransferable(
|
||||||
|
const IPCTransferable& aIPCTransferable, bool aAddDataFlavor,
|
||||||
|
nsITransferable* aTransferable, const bool aFilterUnknownFlavors) {
|
||||||
|
nsresult rv =
|
||||||
|
IPCTransferableDataToTransferable(aIPCTransferable.data(), aAddDataFlavor,
|
||||||
|
aTransferable, aFilterUnknownFlavors);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
aTransferable->SetIsPrivateData(aIPCTransferable.isPrivateData());
|
||||||
|
aTransferable->SetRequestingPrincipal(aIPCTransferable.requestingPrincipal());
|
||||||
|
if (aIPCTransferable.cookieJarSettings().isSome()) {
|
||||||
|
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
||||||
|
net::CookieJarSettings::Deserialize(
|
||||||
|
aIPCTransferable.cookieJarSettings().ref(),
|
||||||
|
getter_AddRefs(cookieJarSettings));
|
||||||
|
aTransferable->SetCookieJarSettings(cookieJarSettings);
|
||||||
|
}
|
||||||
|
aTransferable->SetContentPolicyType(aIPCTransferable.contentPolicyType());
|
||||||
|
aTransferable->SetReferrerInfo(aIPCTransferable.referrerInfo());
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult nsContentUtils::IPCTransferableDataItemToVariant(
|
nsresult nsContentUtils::IPCTransferableDataItemToVariant(
|
||||||
const IPCTransferableDataItem& aItem, nsIWritableVariant* aVariant) {
|
const IPCTransferableDataItem& aItem, nsIWritableVariant* aVariant) {
|
||||||
MOZ_ASSERT(aVariant);
|
MOZ_ASSERT(aVariant);
|
||||||
@@ -8279,6 +8301,30 @@ void nsContentUtils::TransferableToIPCTransferableData(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsContentUtils::TransferableToIPCTransferable(
|
||||||
|
nsITransferable* aTransferable, IPCTransferable* aIPCTransferable,
|
||||||
|
bool aInSyncMessage, mozilla::dom::ContentParent* aParent) {
|
||||||
|
IPCTransferableData ipcTransferableData;
|
||||||
|
TransferableToIPCTransferableData(aTransferable, &ipcTransferableData,
|
||||||
|
aInSyncMessage, aParent);
|
||||||
|
|
||||||
|
Maybe<net::CookieJarSettingsArgs> cookieJarSettingsArgs;
|
||||||
|
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
|
||||||
|
aTransferable->GetCookieJarSettings()) {
|
||||||
|
net::CookieJarSettingsArgs args;
|
||||||
|
net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
|
||||||
|
cookieJarSettingsArgs = Some(std::move(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
aIPCTransferable->data() = std::move(ipcTransferableData);
|
||||||
|
aIPCTransferable->isPrivateData() = aTransferable->GetIsPrivateData();
|
||||||
|
aIPCTransferable->requestingPrincipal() =
|
||||||
|
aTransferable->GetRequestingPrincipal();
|
||||||
|
aIPCTransferable->cookieJarSettings() = std::move(cookieJarSettingsArgs);
|
||||||
|
aIPCTransferable->contentPolicyType() = aTransferable->GetContentPolicyType();
|
||||||
|
aIPCTransferable->referrerInfo() = aTransferable->GetReferrerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
Maybe<BigBuffer> nsContentUtils::GetSurfaceData(DataSourceSurface& aSurface,
|
Maybe<BigBuffer> nsContentUtils::GetSurfaceData(DataSourceSurface& aSurface,
|
||||||
size_t* aLength,
|
size_t* aLength,
|
||||||
int32_t* aStride) {
|
int32_t* aStride) {
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class Element;
|
|||||||
class Event;
|
class Event;
|
||||||
class EventTarget;
|
class EventTarget;
|
||||||
class HTMLInputElement;
|
class HTMLInputElement;
|
||||||
|
class IPCTransferable;
|
||||||
class IPCTransferableData;
|
class IPCTransferableData;
|
||||||
class IPCTransferableDataImageContainer;
|
class IPCTransferableDataImageContainer;
|
||||||
class IPCTransferableDataItem;
|
class IPCTransferableDataItem;
|
||||||
@@ -2872,6 +2873,11 @@ class nsContentUtils {
|
|||||||
const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor,
|
const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor,
|
||||||
nsITransferable* aTransferable, const bool aFilterUnknownFlavors);
|
nsITransferable* aTransferable, const bool aFilterUnknownFlavors);
|
||||||
|
|
||||||
|
static nsresult IPCTransferableToTransferable(
|
||||||
|
const mozilla::dom::IPCTransferable& aIPCTransferable,
|
||||||
|
bool aAddDataFlavor, nsITransferable* aTransferable,
|
||||||
|
const bool aFilterUnknownFlavors);
|
||||||
|
|
||||||
static nsresult IPCTransferableDataItemToVariant(
|
static nsresult IPCTransferableDataItemToVariant(
|
||||||
const mozilla::dom::IPCTransferableDataItem& aItem,
|
const mozilla::dom::IPCTransferableDataItem& aItem,
|
||||||
nsIWritableVariant* aVariant);
|
nsIWritableVariant* aVariant);
|
||||||
@@ -2886,6 +2892,11 @@ class nsContentUtils {
|
|||||||
mozilla::dom::IPCTransferableData* aTransferableData, bool aInSyncMessage,
|
mozilla::dom::IPCTransferableData* aTransferableData, bool aInSyncMessage,
|
||||||
mozilla::dom::ContentParent* aParent);
|
mozilla::dom::ContentParent* aParent);
|
||||||
|
|
||||||
|
static void TransferableToIPCTransferable(
|
||||||
|
nsITransferable* aTransferable,
|
||||||
|
mozilla::dom::IPCTransferable* aIPCTransferable, bool aInSyncMessage,
|
||||||
|
mozilla::dom::ContentParent* aParent);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the pixel data from the given source surface and return it as a
|
* Get the pixel data from the given source surface and return it as a
|
||||||
* BigBuffer. The length and stride will be assigned from the surface.
|
* BigBuffer. The length and stride will be assigned from the surface.
|
||||||
|
|||||||
@@ -3467,16 +3467,13 @@ void ContentParent::OnVarChanged(const GfxVarUpdate& aVar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
|
mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
|
||||||
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData,
|
const IPCTransferable& aTransferable, const int32_t& aWhichClipboard) {
|
||||||
nsIPrincipal* aRequestingPrincipal,
|
|
||||||
mozilla::Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
|
|
||||||
const nsContentPolicyType& aContentPolicyType,
|
|
||||||
nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard) {
|
|
||||||
// aRequestingPrincipal is allowed to be nullptr here.
|
// aRequestingPrincipal is allowed to be nullptr here.
|
||||||
|
|
||||||
if (!ValidatePrincipal(aRequestingPrincipal,
|
if (!ValidatePrincipal(aTransferable.requestingPrincipal(),
|
||||||
{ValidatePrincipalOptions::AllowNullPtr})) {
|
{ValidatePrincipalOptions::AllowNullPtr})) {
|
||||||
LogAndAssertFailedPrincipalValidationInfo(aRequestingPrincipal, __func__);
|
LogAndAssertFailedPrincipalValidationInfo(
|
||||||
|
aTransferable.requestingPrincipal(), __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
@@ -3487,18 +3484,9 @@ mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
|
|||||||
do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||||
trans->Init(nullptr);
|
trans->Init(nullptr);
|
||||||
trans->SetReferrerInfo(aReferrerInfo);
|
|
||||||
|
|
||||||
if (aCookieJarSettingsArgs.isSome()) {
|
rv = nsContentUtils::IPCTransferableToTransferable(
|
||||||
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
aTransferable, true /* aAddDataFlavor */, trans,
|
||||||
net::CookieJarSettings::Deserialize(aCookieJarSettingsArgs.ref(),
|
|
||||||
getter_AddRefs(cookieJarSettings));
|
|
||||||
trans->SetCookieJarSettings(cookieJarSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = nsContentUtils::IPCTransferableDataToTransferable(
|
|
||||||
aTransferableData, aIsPrivateData, aRequestingPrincipal,
|
|
||||||
aContentPolicyType, true /* aAddDataFlavor */, trans,
|
|
||||||
true /* aFilterUnknownFlavors */);
|
true /* aFilterUnknownFlavors */);
|
||||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||||
|
|
||||||
|
|||||||
@@ -994,12 +994,8 @@ class ContentParent final : public PContentParent,
|
|||||||
|
|
||||||
mozilla::ipc::IPCResult RecvGetGfxVars(nsTArray<GfxVarUpdate>* aVars);
|
mozilla::ipc::IPCResult RecvGetGfxVars(nsTArray<GfxVarUpdate>* aVars);
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvSetClipboard(
|
mozilla::ipc::IPCResult RecvSetClipboard(const IPCTransferable& aTransferable,
|
||||||
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData,
|
const int32_t& aWhichClipboard);
|
||||||
nsIPrincipal* aRequestingPrincipal,
|
|
||||||
mozilla::Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
|
|
||||||
const nsContentPolicyType& aContentPolicyType,
|
|
||||||
nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvGetClipboard(
|
mozilla::ipc::IPCResult RecvGetClipboard(
|
||||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||||
|
|||||||
@@ -100,62 +100,6 @@ struct MessageData {
|
|||||||
MessageDataType data;
|
MessageDataType data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IPCTransferableDataString
|
|
||||||
{
|
|
||||||
BigBuffer data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableDataCString
|
|
||||||
{
|
|
||||||
BigBuffer data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableDataInputStream
|
|
||||||
{
|
|
||||||
// NOTE: Editor currently relies on these input streams being synchronous, so
|
|
||||||
// we can't safely serialize them using IPCStream (see bug 1778565). Instead,
|
|
||||||
// they're serialized as a `BigBuffer`, and converted to a nsStringInputStream
|
|
||||||
// on the receiving side. If we are able to use async streams reliably in the
|
|
||||||
// future, we could consider switching the code which adds `nsIInputStream`s
|
|
||||||
// to the transferable to use `BlobImpl` instead, for more consistency between
|
|
||||||
// image formats.
|
|
||||||
BigBuffer data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableDataImageContainer
|
|
||||||
{
|
|
||||||
BigBuffer data;
|
|
||||||
uint32_t width;
|
|
||||||
uint32_t height;
|
|
||||||
uint32_t stride;
|
|
||||||
SurfaceFormat format;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableDataBlob
|
|
||||||
{
|
|
||||||
IPCBlob blob;
|
|
||||||
};
|
|
||||||
|
|
||||||
union IPCTransferableDataType
|
|
||||||
{
|
|
||||||
IPCTransferableDataString;
|
|
||||||
IPCTransferableDataCString;
|
|
||||||
IPCTransferableDataInputStream;
|
|
||||||
IPCTransferableDataImageContainer;
|
|
||||||
IPCTransferableDataBlob;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableDataItem
|
|
||||||
{
|
|
||||||
nsCString flavor;
|
|
||||||
IPCTransferableDataType data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCTransferableData
|
|
||||||
{
|
|
||||||
IPCTransferableDataItem[] items;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScreenDetails {
|
struct ScreenDetails {
|
||||||
LayoutDeviceIntRect rect;
|
LayoutDeviceIntRect rect;
|
||||||
DesktopIntRect rectDisplayPix;
|
DesktopIntRect rectDisplayPix;
|
||||||
|
|||||||
85
dom/ipc/IPCTransferable.ipdlh
Normal file
85
dom/ipc/IPCTransferable.ipdlh
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
|
||||||
|
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
include IPCBlob;
|
||||||
|
include NeckoChannelParams;
|
||||||
|
|
||||||
|
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
|
||||||
|
[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";
|
||||||
|
[RefCounted] using class nsIReferrerInfo from "nsIReferrerInfo.h";
|
||||||
|
[MoveOnly] using class mozilla::ipc::BigBuffer from "mozilla/ipc/BigBuffer.h";
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
struct IPCTransferableDataString
|
||||||
|
{
|
||||||
|
BigBuffer data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableDataCString
|
||||||
|
{
|
||||||
|
BigBuffer data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableDataInputStream
|
||||||
|
{
|
||||||
|
// NOTE: Editor currently relies on these input streams being synchronous, so
|
||||||
|
// we can't safely serialize them using IPCStream (see bug 1778565). Instead,
|
||||||
|
// they're serialized as a `BigBuffer`, and converted to a nsStringInputStream
|
||||||
|
// on the receiving side. If we are able to use async streams reliably in the
|
||||||
|
// future, we could consider switching the code which adds `nsIInputStream`s
|
||||||
|
// to the transferable to use `BlobImpl` instead, for more consistency between
|
||||||
|
// image formats.
|
||||||
|
BigBuffer data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableDataImageContainer
|
||||||
|
{
|
||||||
|
BigBuffer data;
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
uint32_t stride;
|
||||||
|
SurfaceFormat format;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableDataBlob
|
||||||
|
{
|
||||||
|
IPCBlob blob;
|
||||||
|
};
|
||||||
|
|
||||||
|
union IPCTransferableDataType
|
||||||
|
{
|
||||||
|
IPCTransferableDataString;
|
||||||
|
IPCTransferableDataCString;
|
||||||
|
IPCTransferableDataInputStream;
|
||||||
|
IPCTransferableDataImageContainer;
|
||||||
|
IPCTransferableDataBlob;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableDataItem
|
||||||
|
{
|
||||||
|
nsCString flavor;
|
||||||
|
IPCTransferableDataType data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferableData
|
||||||
|
{
|
||||||
|
IPCTransferableDataItem[] items;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IPCTransferable
|
||||||
|
{
|
||||||
|
IPCTransferableData data;
|
||||||
|
bool isPrivateData;
|
||||||
|
nullable nsIPrincipal requestingPrincipal;
|
||||||
|
CookieJarSettingsArgs? cookieJarSettings;
|
||||||
|
nsContentPolicyType contentPolicyType;
|
||||||
|
nullable nsIReferrerInfo referrerInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
@@ -23,6 +23,7 @@ include NeckoChannelParams;
|
|||||||
include WindowGlobalTypes;
|
include WindowGlobalTypes;
|
||||||
include IPCBlob;
|
include IPCBlob;
|
||||||
include IPCStream;
|
include IPCStream;
|
||||||
|
include IPCTransferable;
|
||||||
include URIParams;
|
include URIParams;
|
||||||
include PPrintingTypes;
|
include PPrintingTypes;
|
||||||
include PTabContext;
|
include PTabContext;
|
||||||
@@ -864,6 +865,7 @@ child:
|
|||||||
* Call PasteTransferable via a controller on the content process
|
* Call PasteTransferable via a controller on the content process
|
||||||
* to handle the command content event, "pasteTransferable".
|
* to handle the command content event, "pasteTransferable".
|
||||||
*/
|
*/
|
||||||
|
// XXX Do we really need data other than IPCTransferableData? See bug 1833172.
|
||||||
async PasteTransferable(IPCTransferableData aTransferableData,
|
async PasteTransferable(IPCTransferableData aTransferableData,
|
||||||
bool aIsPrivateData,
|
bool aIsPrivateData,
|
||||||
nullable nsIPrincipal aRequestingPrincipal,
|
nullable nsIPrincipal aRequestingPrincipal,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ include DOMTypes;
|
|||||||
include WindowGlobalTypes;
|
include WindowGlobalTypes;
|
||||||
include IPCBlob;
|
include IPCBlob;
|
||||||
include IPCStream;
|
include IPCStream;
|
||||||
|
include IPCTransferable;
|
||||||
include PPrintingTypes;
|
include PPrintingTypes;
|
||||||
include PTabContext;
|
include PTabContext;
|
||||||
include ProtocolTypes;
|
include ProtocolTypes;
|
||||||
@@ -1217,12 +1218,7 @@ parent:
|
|||||||
bool fromChromeContext, ClonedMessageData stack);
|
bool fromChromeContext, ClonedMessageData stack);
|
||||||
|
|
||||||
// Places the items within dataTransfer on the clipboard.
|
// Places the items within dataTransfer on the clipboard.
|
||||||
async SetClipboard(IPCTransferableData aTransferableData,
|
async SetClipboard(IPCTransferable aTransferable,
|
||||||
bool aIsPrivateData,
|
|
||||||
nullable nsIPrincipal aRequestingPrincipal,
|
|
||||||
CookieJarSettingsArgs? cookieJarSettings,
|
|
||||||
nsContentPolicyType aContentPolicyType,
|
|
||||||
nullable nsIReferrerInfo aReferrerInfo,
|
|
||||||
int32_t aWhichClipboard);
|
int32_t aWhichClipboard);
|
||||||
|
|
||||||
// Given a list of supported types, returns the clipboard data for the
|
// Given a list of supported types, returns the clipboard data for the
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ PREPROCESSED_IPDL_SOURCES += [
|
|||||||
|
|
||||||
IPDL_SOURCES += [
|
IPDL_SOURCES += [
|
||||||
"DOMTypes.ipdlh",
|
"DOMTypes.ipdlh",
|
||||||
|
"IPCTransferable.ipdlh",
|
||||||
"MemoryReportTypes.ipdlh",
|
"MemoryReportTypes.ipdlh",
|
||||||
"PColorPicker.ipdl",
|
"PColorPicker.ipdl",
|
||||||
"PContentPermission.ipdlh",
|
"PContentPermission.ipdlh",
|
||||||
|
|||||||
@@ -32,20 +32,10 @@ ClipboardWriteRequestChild::SetData(nsITransferable* aTransferable,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mIsValid = false;
|
mIsValid = false;
|
||||||
IPCTransferableData ipcTransferableData;
|
IPCTransferable ipcTransferable;
|
||||||
nsContentUtils::TransferableToIPCTransferableData(
|
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable,
|
||||||
aTransferable, &ipcTransferableData, false, nullptr);
|
false, nullptr);
|
||||||
Maybe<net::CookieJarSettingsArgs> cookieJarSettingsArgs;
|
SendSetData(std::move(ipcTransferable));
|
||||||
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
|
|
||||||
aTransferable->GetCookieJarSettings()) {
|
|
||||||
net::CookieJarSettingsArgs args;
|
|
||||||
net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
|
|
||||||
cookieJarSettingsArgs = Some(std::move(args));
|
|
||||||
}
|
|
||||||
SendSetData(std::move(ipcTransferableData), aTransferable->GetIsPrivateData(),
|
|
||||||
aTransferable->GetRequestingPrincipal(), cookieJarSettingsArgs,
|
|
||||||
aTransferable->GetContentPolicyType(),
|
|
||||||
aTransferable->GetReferrerInfo());
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,16 +55,12 @@ NS_IMETHODIMP ClipboardWriteRequestParent::OnComplete(nsresult aResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPCResult ClipboardWriteRequestParent::RecvSetData(
|
IPCResult ClipboardWriteRequestParent::RecvSetData(
|
||||||
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData,
|
const IPCTransferable& aTransferable) {
|
||||||
nsIPrincipal* aRequestingPrincipal,
|
|
||||||
Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
|
|
||||||
const nsContentPolicyType& aContentPolicyType,
|
|
||||||
nsIReferrerInfo* aReferrerInfo) {
|
|
||||||
if (!mManager->ValidatePrincipal(
|
if (!mManager->ValidatePrincipal(
|
||||||
aRequestingPrincipal,
|
aTransferable.requestingPrincipal(),
|
||||||
{ContentParent::ValidatePrincipalOptions::AllowNullPtr})) {
|
{ContentParent::ValidatePrincipalOptions::AllowNullPtr})) {
|
||||||
ContentParent::LogAndAssertFailedPrincipalValidationInfo(
|
ContentParent::LogAndAssertFailedPrincipalValidationInfo(
|
||||||
aRequestingPrincipal, __func__);
|
aTransferable.requestingPrincipal(), __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mAsyncSetClipboardData) {
|
if (!mAsyncSetClipboardData) {
|
||||||
@@ -80,16 +76,8 @@ IPCResult ClipboardWriteRequestParent::RecvSetData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
trans->Init(nullptr);
|
trans->Init(nullptr);
|
||||||
trans->SetReferrerInfo(aReferrerInfo);
|
rv = nsContentUtils::IPCTransferableToTransferable(
|
||||||
if (aCookieJarSettingsArgs.isSome()) {
|
aTransferable, true /* aAddDataFlavor */, trans,
|
||||||
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
|
||||||
net::CookieJarSettings::Deserialize(aCookieJarSettingsArgs.ref(),
|
|
||||||
getter_AddRefs(cookieJarSettings));
|
|
||||||
trans->SetCookieJarSettings(cookieJarSettings);
|
|
||||||
}
|
|
||||||
rv = nsContentUtils::IPCTransferableDataToTransferable(
|
|
||||||
aTransferableData, aIsPrivateData, aRequestingPrincipal,
|
|
||||||
aContentPolicyType, true /* aAddDataFlavor */, trans,
|
|
||||||
true /* aFilterUnknownFlavors */);
|
true /* aFilterUnknownFlavors */);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mAsyncSetClipboardData->Abort(rv);
|
mAsyncSetClipboardData->Abort(rv);
|
||||||
|
|||||||
@@ -29,12 +29,7 @@ class ClipboardWriteRequestParent final
|
|||||||
|
|
||||||
nsresult Init(const int32_t& aClipboardType);
|
nsresult Init(const int32_t& aClipboardType);
|
||||||
|
|
||||||
IPCResult RecvSetData(const IPCTransferableData& aTransferableData,
|
IPCResult RecvSetData(const IPCTransferable& aTransferable);
|
||||||
const bool& aIsPrivateData,
|
|
||||||
nsIPrincipal* aRequestingPrincipal,
|
|
||||||
Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
|
|
||||||
const nsContentPolicyType& aContentPolicyType,
|
|
||||||
nsIReferrerInfo* aReferrerInfo);
|
|
||||||
IPCResult Recv__delete__(nsresult aReason);
|
IPCResult Recv__delete__(nsresult aReason);
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aReason) override final;
|
void ActorDestroy(ActorDestroyReason aReason) override final;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
include protocol PContent;
|
include protocol PContent;
|
||||||
|
|
||||||
include DOMTypes;
|
include DOMTypes;
|
||||||
|
include IPCTransferable;
|
||||||
include NeckoChannelParams;
|
include NeckoChannelParams;
|
||||||
|
|
||||||
using nsContentPolicyType from "nsIContentPolicy.h";
|
using nsContentPolicyType from "nsIContentPolicy.h";
|
||||||
@@ -15,12 +16,7 @@ protocol PClipboardWriteRequest {
|
|||||||
manager PContent;
|
manager PContent;
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
async SetData(IPCTransferableData aTransferableData,
|
async SetData(IPCTransferable aTransferable);
|
||||||
bool aIsPrivateData,
|
|
||||||
nullable nsIPrincipal aRequestingPrincipal,
|
|
||||||
CookieJarSettingsArgs? cookieJarSettings,
|
|
||||||
nsContentPolicyType aContentPolicyType,
|
|
||||||
nullable nsIReferrerInfo aReferrerInfo);
|
|
||||||
|
|
||||||
both:
|
both:
|
||||||
async __delete__(nsresult aResult);
|
async __delete__(nsresult aResult);
|
||||||
|
|||||||
@@ -35,27 +35,10 @@ nsClipboardProxy::SetData(nsITransferable* aTransferable,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ContentChild* child = ContentChild::GetSingleton();
|
ContentChild* child = ContentChild::GetSingleton();
|
||||||
|
IPCTransferable ipcTransferable;
|
||||||
IPCTransferableData ipcTransferableData;
|
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable,
|
||||||
nsContentUtils::TransferableToIPCTransferableData(
|
false, nullptr);
|
||||||
aTransferable, &ipcTransferableData, false, nullptr);
|
child->SendSetClipboard(std::move(ipcTransferable), aWhichClipboard);
|
||||||
|
|
||||||
Maybe<mozilla::net::CookieJarSettingsArgs> cookieJarSettingsArgs;
|
|
||||||
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
|
|
||||||
aTransferable->GetCookieJarSettings()) {
|
|
||||||
mozilla::net::CookieJarSettingsArgs args;
|
|
||||||
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
|
|
||||||
cookieJarSettingsArgs = Some(args);
|
|
||||||
}
|
|
||||||
bool isPrivateData = aTransferable->GetIsPrivateData();
|
|
||||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
|
||||||
aTransferable->GetRequestingPrincipal();
|
|
||||||
nsContentPolicyType contentPolicyType = aTransferable->GetContentPolicyType();
|
|
||||||
nsCOMPtr<nsIReferrerInfo> referrerInfo = aTransferable->GetReferrerInfo();
|
|
||||||
child->SendSetClipboard(std::move(ipcTransferableData), isPrivateData,
|
|
||||||
requestingPrincipal, cookieJarSettingsArgs,
|
|
||||||
contentPolicyType, referrerInfo, aWhichClipboard);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user