Bug 1756130 [wpt PR 32898] - [CSP] Enhance unsafe-eval test to check both realms...
[gecko.git] / widget / nsITransferable.idl
blob71f611cb227a524506a7df4b5047d1b048bfdcde
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;
15 %{ C++
17 // Internal formats must have their second part starting with 'x-moz-',
18 // for example text/x-moz-internaltype. These cannot be assigned by
19 // unprivileged content but all other types can.
20 #define kInternal_Mimetype_Prefix u"/x-moz-"_ns
22 // these probably shouldn't live here, but in some central repository shared
23 // by the entire app.
24 #define kTextMime "text/plain"
25 #define kRTFMime "text/rtf"
26 #define kUnicodeMime "text/unicode"
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"
70 /**
71 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
72 * supplying the data lazily.
74 * To use it, call setTransferData, passing the flavor string and
75 * a nsIFlavorDataProvider QI'd to nsISupports.
77 * When someone calls getTransferData later, if the data size is
78 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
79 * and its getFlavorData called.
82 interface nsITransferable;
83 interface nsILoadContext;
85 [scriptable, uuid(7E225E5F-711C-11D7-9FAE-000393636592)]
86 interface nsIFlavorDataProvider : nsISupports
89 /**
90 * Retrieve the data from this data provider.
92 * @param aTransferable (in parameter) the transferable we're being called for.
93 * @param aFlavor (in parameter) the flavor of data to retrieve
94 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
96 void getFlavorData(in nsITransferable aTransferable, in string aFlavor, out nsISupports aData);
100 [scriptable, builtinclass, uuid(97e0c418-1c1e-4106-bad1-9fcb11dff2fe)]
101 interface nsITransferable : nsISupports
104 * Initializes a transferable object. This should be called on all
105 * transferable objects. Failure to do so will result in fatal assertions in
106 * debug builds.
108 * The load context is used to track whether the transferable is storing privacy-
109 * sensitive information.
111 * To get the appropriate load context in Javascript callers, one needs to get
112 * to the document that the transferable corresponds to, and then get the load
113 * context from the document like this:
115 * var loadContext = doc.defaultView.docShell
116 * .QueryInterface(Ci.nsILoadContext);
118 * In C++ callers, if you have the corresponding document, you can just call
119 * Document::GetLoadContext to get to the load context object.
121 * @param aContext the load context associated with the transferable object.
122 * This can be set to null if a load context is not available.
124 void init(in nsILoadContext aContext);
127 * Computes a list of flavors that the transferable can export, either
128 * through intrinsic knowledge or output data converters.
130 Array<ACString> flavorsTransferableCanExport();
133 * Given a flavor retrieve the data.
135 * @param aFlavor (in parameter) the flavor of data to retrieve
136 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
138 [must_use] void getTransferData(in string aFlavor, out nsISupports aData);
141 * Returns the first flavor which has data.
143 * @param aFlavor (out parameter) the flavor of data that was retrieved
144 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
146 void getAnyTransferData(out ACString aFlavor, out nsISupports aData);
148 ///////////////////////////////
149 // Setter part of interface
150 ///////////////////////////////
153 * Computes a list of flavors that the transferable can
154 * accept into it, either through intrinsic knowledge or input data converters.
157 Array<ACString> flavorsTransferableCanImport();
160 * Sets the data in the transferable with the specified flavor. The transferable
161 * will maintain its own copy the data, so it is not necessary to do that beforehand.
163 * @param aFlavor the flavor of data that is being set
164 * @param aData the data, either some variant of class in nsISupportsPrimitives.idl,
165 * an nsIFile, or an nsIFlavorDataProvider (see above)
167 void setTransferData(in string aFlavor, in nsISupports aData);
170 * Add the data flavor, indicating that this transferable
171 * can receive this type of flavor
173 * @param aDataFlavor a new data flavor to handle
175 void addDataFlavor ( in string aDataFlavor ) ;
178 * Removes the data flavor matching the given one (string compare) and the data
179 * that goes along with it.
181 * @param aDataFlavor a data flavor to remove
183 void removeDataFlavor ( in string aDataFlavor ) ;
185 attribute nsIFormatConverter converter;
188 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
189 * be avoided as much as possible because the value set may not reflect the status
190 * of the context in which the transferable was created.
192 [notxpcom, nostdcall] attribute boolean isPrivateData;
195 * The principal of the source dom node this transferable was
196 * created from and the contentPolicyType for the transferable.
197 * Note, currently only used on Windows for network principal and
198 * contentPolicyType information in clipboard and drag operations.
200 [notxpcom, nostdcall] attribute nsIPrincipal requestingPrincipal;
201 [notxpcom, nostdcall] attribute nsContentPolicyType contentPolicyType;
204 * The cookieJarSettings of the source dom node this transferable was created
205 * from.
207 [notxpcom, nostdcall] attribute nsICookieJarSettings cookieJarSettings;