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 nsICookieJarSettings
;
13 interface nsIPrincipal
;
14 interface nsIReferrerInfo
;
18 // Internal formats must have their second part starting with 'x-moz-',
19 // for example text/x-moz-internaltype. These cannot be assigned by
20 // unprivileged content but all other types can.
21 #define kInternal_Mimetype_Prefix u
"/x-moz-"_ns
23 // these probably shouldn't live here, but in some central repository shared
25 #define kTextMime
"text/plain"
26 #define kRTFMime
"text/rtf"
27 #define kMozTextInternal
"text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
28 #define kHTMLMime
"text/html"
29 #define kAOLMailMime
"AOLMAIL"
30 #define kPNGImageMime
"image/png"
31 #define kJPEGImageMime
"image/jpeg"
32 #define kJPGImageMime
"image/jpg"
33 #define kGIFImageMime
"image/gif"
34 #define kFileMime
"application/x-moz-file"
36 #define kURLMime
"text/x-moz-url" // data contains url\ntitle
37 #define kURLDataMime
"text/x-moz-url-data" // data contains url only
38 #define kURLDescriptionMime
"text/x-moz-url-desc" // data contains description
39 #define kURLPrivateMime
"text/x-moz-url-priv" // same as kURLDataMime but for private uses
40 #define kNativeImageMime
"application/x-moz-nativeimage"
41 #define kNativeHTMLMime
"application/x-moz-nativehtml"
43 // These are used to indicate the context for a fragment of HTML source, such
44 // that some parent structure and style can be preserved. kHTMLContext
45 // contains the serialized ancestor elements, whereas kHTMLInfo are numbers
46 // identifying where in the context the fragment was from.
47 #define kHTMLContext
"text/_moz_htmlcontext"
48 #define kHTMLInfo
"text/_moz_htmlinfo"
50 // Holds the MIME type from the image request. This is used to ensure the
51 // local application handler for the request's MIME type accepts images with
52 // the given filename extension (from kFilePromiseDestFilename). When the
53 // image is dragged out, we replace the extension with a compatible extension.
54 #define kImageRequestMime
"text/x-moz-requestmime"
56 // the source URL for a file promise
57 #define kFilePromiseURLMime
"application/x-moz-file-promise-url"
58 // the destination filename for a file promise
59 #define kFilePromiseDestFilename
"application/x-moz-file-promise-dest-filename"
60 // a dataless flavor used to interact with the OS during file drags
61 #define kFilePromiseMime
"application/x-moz-file-promise"
62 // a synthetic flavor, put into the transferable once we know the destination directory of a file drag
63 #define kFilePromiseDirectoryMime
"application/x-moz-file-promise-dir"
65 #define kCustomTypesMime
"application/x-moz-custom-clipdata"
67 #define kPDFJSMime
"application/pdfjs"
73 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
74 * supplying the data lazily.
76 * To use it, call setTransferData, passing the flavor string and
77 * a nsIFlavorDataProvider QI'd to nsISupports.
79 * When someone calls getTransferData later, if the data size is
80 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
81 * and its getFlavorData called.
84 interface nsITransferable
;
85 interface nsILoadContext
;
87 [scriptable
, uuid(7E225E5F
-711C
-11D7
-9FAE
-000393636592)]
88 interface nsIFlavorDataProvider
: nsISupports
92 * Retrieve the data from this data provider.
94 * @param aTransferable (in parameter) the transferable we're being called for.
95 * @param aFlavor (in parameter) the flavor of data to retrieve
96 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
98 void getFlavorData
(in nsITransferable aTransferable
, in string aFlavor
, out nsISupports aData
);
102 [scriptable
, builtinclass
, uuid(97e0c418
-1c1e
-4106
-bad1
-9fcb11dff2fe
)]
103 interface nsITransferable
: nsISupports
106 * Initializes a transferable object. This should be called on all
107 * transferable objects. Failure to do so will result in fatal assertions in
110 * The load context is used to track whether the transferable is storing privacy-
111 * sensitive information.
113 * To get the appropriate load context in Javascript callers, one needs to get
114 * to the document that the transferable corresponds to, and then get the load
115 * context from the document like this:
117 * var loadContext = doc.defaultView.docShell
118 * .QueryInterface(Ci.nsILoadContext);
120 * In C++ callers, if you have the corresponding document, you can just call
121 * Document::GetLoadContext to get to the load context object.
123 * @param aContext the load context associated with the transferable object.
124 * This can be set to null if a load context is not available.
126 void init
(in nsILoadContext aContext
);
129 * Computes a list of flavors that the transferable can export, either
130 * through intrinsic knowledge or output data converters.
132 Array
<ACString
> 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
140 [must_use
] void getTransferData
(in string aFlavor
, out nsISupports aData
);
143 * Returns the first flavor which has data.
145 * @param aFlavor (out parameter) the flavor of data that was retrieved
146 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
148 void getAnyTransferData
(out ACString aFlavor
, out nsISupports aData
);
150 ///////////////////////////////
151 // Setter part of interface
152 ///////////////////////////////
155 * Computes a list of flavors that the transferable can
156 * accept into it, either through intrinsic knowledge or input data converters.
159 Array
<ACString
> 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)
169 void setTransferData
(in string aFlavor
, in nsISupports aData
);
172 * Add the data flavor, indicating that this transferable
173 * can receive this type of flavor
175 * @param aDataFlavor a new data flavor to handle
177 void addDataFlavor
( in string aDataFlavor
) ;
180 * Removes the data flavor matching the given one (string compare) and the data
181 * that goes along with it.
183 * @param aDataFlavor a data flavor to remove
185 void removeDataFlavor
( in string aDataFlavor
) ;
187 attribute nsIFormatConverter converter
;
190 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
191 * be avoided as much as possible because the value set may not reflect the status
192 * of the context in which the transferable was created.
194 [notxpcom
, nostdcall
] attribute
boolean isPrivateData
;
197 * The principal associated with this transferable. This could be either the
198 * node principal of the source DOM node from which this transferable was
199 * created, or the principal of the global from which this transferable was
201 * XXXedgar: Rename it to something more generic, bug 1867636.
203 [notxpcom
, nostdcall
] attribute nsIPrincipal requestingPrincipal
;
206 * the contentPolicyType for this transferable.
208 [notxpcom
, nostdcall
] attribute nsContentPolicyType contentPolicyType
;
211 * The cookieJarSettings of the source dom node this transferable was created
214 [notxpcom
, nostdcall
] attribute nsICookieJarSettings cookieJarSettings
;
217 * Used for initializing the referrer when downloading a file promise.
219 [notxpcom
, nostdcall
] attribute nsIReferrerInfo referrerInfo
;