nsITransferable

Methods

init(aContext)

Initializes a transferable object. This should be called on all
transferable objects. Failure to do so will result in fatal assertions in
debug builds.

The load context is used to track whether the transferable is storing privacy-
sensitive information. For example, we try to delete data that you copy
to the clipboard when you close a Private Browsing window.

To get the appropriate load context in Javascript callers, one needs to get
to the document that the transferable corresponds to, and then get the load
context from the document like this:

var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);

In C++ callers, if you have the corresponding document, you can just call
nsIDocument::GetLoadContext to get to the load context object.

Parameters

aContext the load context associated with the transferable object. This can be set to null if a load context is not available.

flavorsTransferableCanExport()

Computes a list of flavors (mime types as nsISupportsCString) that the transferable
can export, either through intrinsic knowledge or output data converters.

Parameters

aDataFlavorList fills list with supported flavors. This is a copy of the internal list, so it may be edited w/out affecting the transferable.

getTransferData(aFlavor, aData, aDataLen)

Given a flavor retrieve the data.

Parameters

aFlavor (in parameter) the flavor of data to retrieve
aData the data. Some variant of class in nsISupportsPrimitives.idl
aDataLen the length of the data

getAnyTransferData(aFlavor, aData, aDataLen)

Returns the best flavor in the transferable, given those that have
been added to it with |AddFlavor()|

Parameters

aFlavor (out parameter) the flavor of data that was retrieved
aData the data. Some variant of class in nsISupportsPrimitives.idl
aDataLen the length of the data

isLargeDataSet()

Returns true if the data is large.

flavorsTransferableCanImport()

Computes a list of flavors (mime types as nsISupportsCString) that the transferable can
accept into it, either through intrinsic knowledge or input data converters.

Parameters

outFlavorList fills list with supported flavors. This is a copy of the internal list, so it may be edited w/out affecting the transferable.

setTransferData(aFlavor, aData, aDataLen)

Sets the data in the transferable with the specified flavor. The transferable
will maintain its own copy the data, so it is not necessary to do that beforehand.

Parameters

aFlavor the flavor of data that is being set
aData the data, either some variant of class in nsISupportsPrimitives.idl, an nsIFile, or an nsIFlavorDataProvider (see above)
aDataLen the length of the data, or 0 if passing a nsIFlavorDataProvider

addDataFlavor(aDataFlavor)

Add the data flavor, indicating that this transferable
can receive this type of flavor

Parameters

aDataFlavor a new data flavor to handle

removeDataFlavor(aDataFlavor)

Removes the data flavor matching the given one (string compare) and the data
that goes along with it.

Parameters

aDataFlavor a data flavor to remove

Attributes

converter

isPrivateData

Use of the SetIsPrivateData() method generated by isPrivateData attribute should
be avoided as much as possible because the value set may not reflect the status
of the context in which the transferable was created.

requestingNode

The source dom node this transferable was created from.
Note, currently only in use on Windows for network principal
information in drag operations.

Constants

kFlavorHasDataProvider