forked from mirrors/gecko-dev
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async clipboard API reads the clipboard data asynchronously. When reading, async clipboard API first check the available types, and then retrieve the actual data for that type. This process has a potential race condition: the clipboard content might change between the time between the time we check the types and when we retrieve the data. Although we currently fetch the actual data immediately after checking available types (in line with the spec), this minimizes the chance of encountering this race condition. However, if we would like to support retrieving the data only when `getType()` is invoked (bug 1691825), this potential race condition could become a significant issue. Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress the paste context menu when the clipboard data originates from a same-origin page. This also requires a better way to track read requests, clipboard content and invalidate the request when the system's clipboard content is changed. After some refacting around nsBaseClipboard, all platform now use sequence number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated with a sequence number and deemed invalid if the associated sequence number isn't matched the latest system value. With these new API, it also becomes possible to write some tests. Depends on D191409 Differential Revision: https://phabricator.services.mozilla.com/D182108
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
/* -*- 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 "mozilla/GfxMessageUtils.h";
|
|
include "mozilla/dom/PermissionMessageUtils.h";
|
|
|
|
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;
|
|
};
|
|
|
|
union IPCTransferableDataOrError {
|
|
IPCTransferableData;
|
|
nsresult;
|
|
};
|
|
|
|
struct IPCTransferable
|
|
{
|
|
IPCTransferableData data;
|
|
bool isPrivateData;
|
|
nullable nsIPrincipal requestingPrincipal;
|
|
CookieJarSettingsArgs? cookieJarSettings;
|
|
nsContentPolicyType contentPolicyType;
|
|
nullable nsIReferrerInfo referrerInfo;
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|