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
"nsIArray.idl"
8 #include
"nsISupports.idl"
9 #include
"nsIFormatConverter.idl"
10 #include
"nsIContentPolicy.idl"
12 interface nsIPrincipal
;
16 // these probably shouldn't live here, but in some central repository shared
18 #define kTextMime
"text/plain"
19 #define kRTFMime
"text/rtf"
20 #define kUnicodeMime
"text/unicode"
21 #define kMozTextInternal
"text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
22 #define kHTMLMime
"text/html"
23 #define kAOLMailMime
"AOLMAIL"
24 #define kPNGImageMime
"image/png"
25 #define kJPEGImageMime
"image/jpeg"
26 #define kJPGImageMime
"image/jpg"
27 #define kGIFImageMime
"image/gif"
28 #define kFileMime
"application/x-moz-file"
30 #define kURLMime
"text/x-moz-url" // data contains url\ntitle
31 #define kURLDataMime
"text/x-moz-url-data" // data contains url only
32 #define kURLDescriptionMime
"text/x-moz-url-desc" // data contains description
33 #define kURLPrivateMime
"text/x-moz-url-priv" // same as kURLDataMime but for private uses
34 #define kNativeImageMime
"application/x-moz-nativeimage"
35 #define kNativeHTMLMime
"application/x-moz-nativehtml"
37 // These are used to indicate the context for a fragment of HTML source, such
38 // that some parent structure and style can be preserved. kHTMLContext
39 // contains the serialized ancestor elements, whereas kHTMLInfo are numbers
40 // identifying where in the context the fragment was from.
41 #define kHTMLContext
"text/_moz_htmlcontext"
42 #define kHTMLInfo
"text/_moz_htmlinfo"
44 // Holds the MIME type from the image request. This is used to ensure the
45 // local application handler for the request's MIME type accepts images with
46 // the given filename extension (from kFilePromiseDestFilename). When the
47 // image is dragged out, we replace the extension with a compatible extension.
48 #define kImageRequestMime
"text/_moz_requestmime"
50 // the source URL for a file promise
51 #define kFilePromiseURLMime
"application/x-moz-file-promise-url"
52 // the destination filename for a file promise
53 #define kFilePromiseDestFilename
"application/x-moz-file-promise-dest-filename"
54 // a dataless flavor used to interact with the OS during file drags
55 #define kFilePromiseMime
"application/x-moz-file-promise"
56 // a synthetic flavor, put into the transferable once we know the destination directory of a file drag
57 #define kFilePromiseDirectoryMime
"application/x-moz-file-promise-dir"
59 #define kCustomTypesMime
"application/x-moz-custom-clipdata"
65 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
66 * supplying the data lazily.
68 * To use it, call setTransferData, passing the flavor string,
69 * a nsIFlavorDataProvider QI'd to nsISupports, and a data size of 0.
71 * When someone calls getTransferData later, if the data size is
72 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
73 * and its getFlavorData called.
76 interface nsITransferable
;
77 interface nsILoadContext
;
79 [scriptable
, uuid(7E225E5F
-711C
-11D7
-9FAE
-000393636592)]
80 interface nsIFlavorDataProvider
: nsISupports
84 * Retrieve the data from this data provider.
86 * @param aTransferable (in parameter) the transferable we're being called for.
87 * @param aFlavor (in parameter) the flavor of data to retrieve
88 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
89 * @param aDataLen the length of the data
91 void getFlavorData
(in nsITransferable aTransferable
, in string aFlavor
, out nsISupports aData
, out unsigned long aDataLen
);
95 [scriptable
, uuid(97e0c418
-1c1e
-4106
-bad1
-9fcb11dff2fe
)]
96 interface nsITransferable
: nsISupports
98 const long kFlavorHasDataProvider
= 0;
101 * Initializes a transferable object. This should be called on all
102 * transferable objects. Failure to do so will result in fatal assertions in
105 * The load context is used to track whether the transferable is storing privacy-
106 * sensitive information. For example, we try to delete data that you copy
107 * to the clipboard when you close a Private Browsing window.
109 * To get the appropriate load context in Javascript callers, one needs to get
110 * to the document that the transferable corresponds to, and then get the load
111 * context from the document like this:
113 * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
114 * .getInterface(Ci.nsIWebNavigation)
115 * .QueryInterface(Ci.nsILoadContext);
117 * In C++ callers, if you have the corresponding document, you can just call
118 * nsIDocument::GetLoadContext to get to the load context object.
120 * @param aContext the load context associated with the transferable object.
121 * This can be set to null if a load context is not available.
123 void init
(in nsILoadContext aContext
);
126 * Computes a list of flavors (mime types as nsISupportsCString) that the transferable
127 * can export, either through intrinsic knowledge or output data converters.
129 * @param aDataFlavorList fills list with supported flavors. This is a copy of
130 * the internal list, so it may be edited w/out affecting the transferable.
132 nsIArray flavorsTransferableCanExport
( ) ;
135 * Given a flavor retrieve the data.
137 * @param aFlavor (in parameter) the flavor of data to retrieve
138 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
139 * @param aDataLen the length of the data
141 void getTransferData
( in string aFlavor
, out nsISupports aData
, out unsigned long aDataLen
) ;
144 * Returns the best flavor in the transferable, given those that have
145 * been added to it with |AddFlavor()|
147 * @param aFlavor (out parameter) the flavor of data that was retrieved
148 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
149 * @param aDataLen the length of the data
151 void getAnyTransferData
( out ACString aFlavor
, out nsISupports aData
,
152 out unsigned long aDataLen
) ;
155 * Returns true if the data is large.
157 boolean isLargeDataSet
( ) ;
160 ///////////////////////////////
161 // Setter part of interface
162 ///////////////////////////////
165 * Computes a list of flavors (mime types as nsISupportsCString) that the transferable can
166 * accept into it, either through intrinsic knowledge or input data converters.
168 * @param outFlavorList fills list with supported flavors. This is a copy of
169 * the internal list, so it may be edited w/out affecting the transferable.
171 nsIArray flavorsTransferableCanImport
( ) ;
174 * Sets the data in the transferable with the specified flavor. The transferable
175 * will maintain its own copy the data, so it is not necessary to do that beforehand.
177 * @param aFlavor the flavor of data that is being set
178 * @param aData the data, either some variant of class in nsISupportsPrimitives.idl,
179 * an nsIFile, or an nsIFlavorDataProvider (see above)
180 * @param aDataLen the length of the data, or 0 if passing a nsIFlavorDataProvider
182 void setTransferData
( in string aFlavor
, in nsISupports aData
, in unsigned long aDataLen
) ;
185 * Add the data flavor, indicating that this transferable
186 * can receive this type of flavor
188 * @param aDataFlavor a new data flavor to handle
190 void addDataFlavor
( in string aDataFlavor
) ;
193 * Removes the data flavor matching the given one (string compare) and the data
194 * that goes along with it.
196 * @param aDataFlavor a data flavor to remove
198 void removeDataFlavor
( in string aDataFlavor
) ;
200 attribute nsIFormatConverter converter
;
203 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
204 * be avoided as much as possible because the value set may not reflect the status
205 * of the context in which the transferable was created.
207 [noscript
] attribute
boolean isPrivateData
;
210 * The principal of the source dom node this transferable was
211 * created from and the contentPolicyType for the transferable.
212 * Note, currently only used on Windows for network principal and
213 * contentPolicyType information in clipboard and drag operations.
215 [noscript
] attribute nsIPrincipal requestingPrincipal
;
216 [noscript
] attribute nsContentPolicyType contentPolicyType
;