Add a `getDataIfSmallerThan()` API to `nsIClipboard`. This API allows data to be retrieved only if the size of clipboard's contents is smaller than the specified threshold. The parameters are `aTransferable`, `aWhichClipboard` and `aRequestingWindowContext`, similar to [nsIClipboard.getData()](https://searchfox.org/firefox-main/rev/7709f0a26aeb3c39a5fd86e794425530f0d0b528/widget/nsIClipboard.idl#165-181). In addition, it takes `aThreshold`, which defines the threshold value. (Currently, it only targets plain/text content and checks its character count.) The reason I want to add this is for use in the urlbar and places modules. For example, we currently want to change the context menu items based on the clipboard's content. However, when the content is very large, it takes a significant amount of time to retrieve and parse it. [1] Additionally, while there is a feature to suggest URLs when the clipboard contains a URL[2], we cannot enable this feature by default due to the same reason. To resolve them, adds the above API, we want to make very large content ignorable. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1874203 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1842230 Differential Revision: https://phabricator.services.mozilla.com/D280552
45 lines
1.9 KiB
Plaintext
45 lines
1.9 KiB
Plaintext
/* 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 IPCTransferable;
|
|
include protocol PContent;
|
|
|
|
include "mozilla/widget/WidgetMessageUtils.h";
|
|
|
|
using nsIClipboard::ClipboardType from "nsIClipboard.h";
|
|
|
|
namespace mozilla {
|
|
|
|
[ChildProc=Content]
|
|
sync protocol PClipboardContentAnalysis
|
|
{
|
|
parent:
|
|
// Given a list of supported types, returns the clipboard data for the
|
|
// first type that matches.
|
|
// aRequestingWindowContextId is the ID of the window that is requesting
|
|
// the clipboard, which is used for content analysis.
|
|
sync GetClipboard(nsCString[] aTypes, ClipboardType aWhichClipboard,
|
|
uint64_t aRequestingWindowContextId)
|
|
returns (IPCTransferableDataOrError transferableDataOrError);
|
|
|
|
// Given a list of supported types, returns the clipboard data for the
|
|
// first type that matches if the data byte size <= aThreshold.
|
|
// aRequestingWindowContext is the window that is requesting the clipboard,
|
|
// which is used for content analysis.
|
|
async GetClipboardDataIfSmallerThan(nsCString[] aTypes,
|
|
uint64_t aThreshold,
|
|
ClipboardType aWhichClipboard,
|
|
uint64_t aRequestingWindowContextId)
|
|
returns (IPCTransferableDataOrError transferableDataOrError);
|
|
|
|
// Requests getting data from clipboard.
|
|
// aRequestingWindowContextId is the ID of the window that is requesting
|
|
// the clipboard, which is used for content analysis.
|
|
sync GetAllClipboardDataSync(nsCString[] aTypes, ClipboardType aWhichClipboard,
|
|
uint64_t aRequestingWindowContextId)
|
|
returns (IPCTransferableDataOrError transferableDataOrError);
|
|
};
|
|
|
|
}
|