1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include
"nsISupports.idl"
8 #include
"nsISupportsArray.idl"
9 #include
"nsIFormatConverter.idl"
14 // these probably shouldn't live here, but in some central repository shared
16 #define kTextMime
"text/plain"
17 #define kUnicodeMime
"text/unicode"
18 #define kMozTextInternal
"text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
19 #define kHTMLMime
"text/html"
20 #define kAOLMailMime
"AOLMAIL"
21 #define kPNGImageMime
"image/png"
22 #define kJPEGImageMime
"image/jpeg"
23 #define kJPGImageMime
"image/jpg"
24 #define kGIFImageMime
"image/gif"
25 #define kFileMime
"application/x-moz-file"
27 #define kURLMime
"text/x-moz-url" // data contains url\ntitle
28 #define kURLDataMime
"text/x-moz-url-data" // data contains url only
29 #define kURLDescriptionMime
"text/x-moz-url-desc" // data contains description
30 #define kURLPrivateMime
"text/x-moz-url-priv" // same as kURLDataMime but for private uses
31 #define kNativeImageMime
"application/x-moz-nativeimage"
32 #define kNativeHTMLMime
"application/x-moz-nativehtml"
34 // These are used to indicate the context for a fragment of HTML source, such
35 // that some parent structure and style can be preserved. kHTMLContext
36 // contains the serialized ancestor elements, whereas kHTMLInfo are numbers
37 // identifying where in the context the fragment was from.
38 #define kHTMLContext
"text/_moz_htmlcontext"
39 #define kHTMLInfo
"text/_moz_htmlinfo"
41 // the source URL for a file promise
42 #define kFilePromiseURLMime
"application/x-moz-file-promise-url"
43 // the destination filename for a file promise
44 #define kFilePromiseDestFilename
"application/x-moz-file-promise-dest-filename"
45 // a dataless flavor used to interact with the OS during file drags
46 #define kFilePromiseMime
"application/x-moz-file-promise"
47 // a synthetic flavor, put into the transferable once we know the destination directory of a file drag
48 #define kFilePromiseDirectoryMime
"application/x-moz-file-promise-dir"
54 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
55 * supplying the data lazily.
57 * To use it, call setTransferData, passing the flavor string,
58 * a nsIFlavorDataProvider QI'd to nsISupports, and a data size of 0.
60 * When someone calls getTransferData later, if the data size is
61 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
62 * and its getFlavorData called.
65 interface nsITransferable
;
66 interface nsILoadContext
;
68 [scriptable
, uuid(7E225E5F
-711C
-11D7
-9FAE
-000393636592)]
69 interface nsIFlavorDataProvider
: nsISupports
73 * Retrieve the data from this data provider.
75 * @param aTransferable (in parameter) the transferable we're being called for.
76 * @param aFlavor (in parameter) the flavor of data to retrieve
77 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
78 * @param aDataLen the length of the data
80 void getFlavorData
(in nsITransferable aTransferable
, in string aFlavor
, out nsISupports aData
, out unsigned long aDataLen
);
84 [scriptable
, uuid(5a611a60
-e5b5
-11e1
-aff1
-0800200c9a66
)]
85 interface nsITransferable
: nsISupports
87 const long kFlavorHasDataProvider
= 0;
90 * Initializes a transferable object. This should be called on all
91 * transferable objects. Failure to do so will result in fatal assertions in
94 * The load context is used to track whether the transferable is storing privacy-
95 * sensitive information. For example, we try to delete data that you copy
96 * to the clipboard when you close a Private Browsing window.
98 * To get the appropriate load context in Javascript callers, one needs to get
99 * to the document that the transferable corresponds to, and then get the load
100 * context from the document like this:
102 * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
103 * .getInterface(Ci.nsIWebNavigation)
104 * .QueryInterface(Ci.nsILoadContext);
106 * In C++ callers, if you have the corresponding document, you can just call
107 * nsIDocument::GetLoadContext to get to the load context object.
109 * @param aContext the load context associated with the transferable object.
110 * This can be set to null if a load context is not available.
112 void init
(in nsILoadContext aContext
);
115 * Computes a list of flavors (mime types as nsISupportsCString) that the transferable
116 * can export, either through intrinsic knowledge or output data converters.
118 * @param aDataFlavorList fills list with supported flavors. This is a copy of
119 * the internal list, so it may be edited w/out affecting the transferable.
121 nsISupportsArray flavorsTransferableCanExport
( ) ;
124 * Given a flavor retrieve the data.
126 * @param aFlavor (in parameter) the flavor of data to retrieve
127 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
128 * @param aDataLen the length of the data
130 void getTransferData
( in string aFlavor
, out nsISupports aData
, out unsigned long aDataLen
) ;
133 * Returns the best flavor in the transferable, given those that have
134 * been added to it with |AddFlavor()|
136 * @param aFlavor (out parameter) the flavor of data that was retrieved
137 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
138 * @param aDataLen the length of the data
140 void getAnyTransferData
( out string aFlavor
, out nsISupports aData
, out unsigned long aDataLen
) ;
143 * Returns true if the data is large.
145 boolean isLargeDataSet
( ) ;
148 ///////////////////////////////
149 // Setter part of interface
150 ///////////////////////////////
153 * Computes a list of flavors (mime types as nsISupportsCString) that the transferable can
154 * accept into it, either through intrinsic knowledge or input data converters.
156 * @param outFlavorList fills list with supported flavors. This is a copy of
157 * the internal list, so it may be edited w/out affecting the transferable.
159 nsISupportsArray flavorsTransferableCanImport
( ) ;
162 * Sets the data in the transferable with the specified flavor. The transferable
163 * will maintain its own copy the data, so it is not necessary to do that beforehand.
165 * @param aFlavor the flavor of data that is being set
166 * @param aData the data, either some variant of class in nsISupportsPrimitives.idl,
167 * an nsIFile, or an nsIFlavorDataProvider (see above)
168 * @param aDataLen the length of the data, or 0 if passing a nsIFlavorDataProvider
170 void setTransferData
( in string aFlavor
, in nsISupports aData
, in unsigned long aDataLen
) ;
173 * Add the data flavor, indicating that this transferable
174 * can receive this type of flavor
176 * @param aDataFlavor a new data flavor to handle
178 void addDataFlavor
( in string aDataFlavor
) ;
181 * Removes the data flavor matching the given one (string compare) and the data
182 * that goes along with it.
184 * @param aDataFlavor a data flavor to remove
186 void removeDataFlavor
( in string aDataFlavor
) ;
188 attribute nsIFormatConverter converter
;
191 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
192 * be avoided as much as possible because the value set may not reflect the status
193 * of the context in which the transferable was created.
195 [noscript
] attribute
boolean isPrivateData
;