gecko-dev/widget/nsIClipboard.idl
Greg Stoll 6b9e711a99 Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-13 11:26:48 +00:00

216 lines
8.1 KiB
Plaintext

/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 "nsISupports.idl"
#include "nsITransferable.idl"
#include "nsIClipboardOwner.idl"
interface nsIArray;
webidl WindowContext;
[scriptable, builtinclass, uuid(801e2318-c8fa-11ed-afa1-0242ac120002)]
interface nsIAsyncSetClipboardData : nsISupports {
/**
* Provide the data for the set request.
*
* @param aTransferable
* The transferable contains the data to be written.
* @param aOwner [optional]
* The owner of the transferable.
*/
void setData(in nsITransferable aTransferable, [optional] in nsIClipboardOwner aOwner);
/**
* Abort the request to set data.
*
* @param aReason
* The reason for the abort, can not be NS_OK.
*/
void abort(in nsresult aReason);
};
[scriptable, function, uuid(78f7c18e-c8fa-11ed-afa1-0242ac120002)]
interface nsIAsyncClipboardRequestCallback : nsISupports
{
/**
* Indicates that the clipboard request has either succeeded, been canceled or
* rejected.
*
* @param aResult
* The result of the request. NS_OK if successful, or another value
* that indicates the reason for failure or cancellation.
*/
void onComplete(in nsresult aResult);
};
[scriptable, builtinclass, uuid(c18ea2f7-6b6f-4a38-9ab3-a8781fdfcc39)]
interface nsIAsyncGetClipboardData : nsISupports {
/**
* Determines whether this request is still valid (e.g., the clipboard content
* associated with this request is not stale).
*/
readonly attribute boolean valid;
/**
* The available flavors in the clipboard.
*/
readonly attribute Array<ACString> flavorList;
/**
* Filters the flavors that `aTransferable` can import (see
* `nsITransferable::flavorsTransferableCanImport`). Every specified flavors
* must exist in `flavorList`, or the request will be rejected. If the request
* remains valid, it retrieves the data for the first flavor. The data is then
* set for `aTransferable`.
*
* @param aTransferable
* The transferable which contains the flavors to be read.
* @param aCallback
* The nsIAsyncClipboardRequestCallback to be invoked once the get
* request is either successfully completed or rejected.
* @result NS_OK if no errors
*/
void getData(in nsITransferable aTransferable,
in nsIAsyncClipboardRequestCallback aCallback);
};
[scriptable, uuid(ce23c1c4-58fd-4c33-8579-fa0796d9652c)]
interface nsIAsyncClipboardGetCallback : nsISupports
{
/**
* Indicates that the clipboard get request has succeeded.
*/
void onSuccess(in nsIAsyncGetClipboardData aAsyncGetClipboardData);
/**
* Indicates that the clipboard get request has rejected.
*
* @param aResult
* The reason for the rejection, can not be NS_OK.
*/
void onError(in nsresult aResult);
};
[scriptable, builtinclass, uuid(ceaa0047-647f-4b8e-ad1c-aff9fa62aa51)]
interface nsIClipboard : nsISupports
{
const long kSelectionClipboard = 0;
const long kGlobalClipboard = 1;
const long kFindClipboard = 2;
// Used to cache current selection on (nsClipboard) for macOS service menu.
const long kSelectionCache = 3;
%{ C++
static const uint32_t kClipboardTypeCount = kSelectionCache + 1;
%}
/**
* Given a transferable, set the data on the native clipboard
*
* @param aTransferable The transferable
* @param anOwner The owner of the transferable
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @result NS_Ok if no errors
*/
void setData ( in nsITransferable aTransferable, in nsIClipboardOwner anOwner,
in long aWhichClipboard ) ;
/**
* Requests setting data to the native clipboard. The acutal set occur
* when the data is provided by calling nsIAsyncSetClipboardData::setData().
* The result will be notified by nsIClipboardCallback. A new set request
* will cancel any prior pending requests, if any exist.
*
* @param aWhichClipboard
* Specifies the clipboard to which this operation applies.
* @param aCallback [optional]
* The callback object that will be notified upon completion.
* @return nsIAsyncSetClipboardData
* The write request object. The actual write will occur when the
* data is provided by calling nsIAsyncSetClipboardData::setData().
*/
nsIAsyncSetClipboardData asyncSetData(in long aWhichClipboard,
[optional] in nsIAsyncClipboardRequestCallback aCallback);
/**
* Filters the flavors aTransferable can import (see
* `nsITransferable::flavorsTransferableCanImport`) and gets the data for the
* first flavor. That data is set for aTransferable.
*
* @param aTransferable The transferable
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @param aRequestingWindowContext [optional]
* The window context window that is requesting the clipboard, which is
* used for content analysis. Passing null means that the content is
* exempt from content analysis. (for example, scripted clipboard read by
* system code) This parameter should not be null when calling this from a
* content process.
* @result NS_OK if no errors
*/
void getData ( in nsITransferable aTransferable, in long aWhichClipboard, [optional] in WindowContext aRequestingWindowContext) ;
/**
* Requests getting data asynchronously from the native clipboard. This does
* not actually retrieve the data, but returns a nsIAsyncGetClipboardData
* contains current avaiable data formats. If the native clipboard is
* updated, either by us or other application, the existing
* nsIAsyncGetClipboardData becomes invalid.
*
* @param aFlavorList
* Specific data formats ('flavors') that can be retrieved from the
* clipboard.
* @param aWhichClipboard
* Specifies the clipboard to which this operation applies.
* @param aCallback
* The callback object that will be notified upon completion.
* @result NS_OK if no errors
*/
void asyncGetData(in Array<ACString> aFlavorList,
in long aWhichClipboard,
in WindowContext aRequestingWindowContext,
in nsIPrincipal aRequestingPrincipal,
in nsIAsyncClipboardGetCallback aCallback);
/**
* This empties the clipboard and notifies the clipboard owner.
* This empties the "logical" clipboard. It does not clear the native clipboard.
*
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @result NS_OK if successful.
*/
void emptyClipboard ( in long aWhichClipboard ) ;
/**
* This provides a way to give correct UI feedback about, for instance, a paste
* should be allowed. It does _NOT_ actually retreive the data and should be a very
* inexpensive call. All it does is check if there is data on the clipboard matching
* any of the flavors in the given list.
*
* @param aFlavorList An array of ASCII strings.
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @outResult - if data is present matching one of
* @result NS_OK if successful.
*/
boolean hasDataMatchingFlavors ( in Array<ACString> aFlavorList,
in long aWhichClipboard ) ;
/**
* Allows clients to determine if the implementation supports the concept of a
* separate clipboard.
*
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @outResult true if the implementaion supports specific clipboard type.
* @result NS_OK if successful.
*/
[infallible]
boolean isClipboardTypeSupported(in long aWhichClipboard);
};