Bug 1816917 - Re-enable video conversion, and text addition on desktop. r=perftest...
[gecko.git] / widget / nsITransferable.idl
blobe761d59231419b401ea0943ed2e438a00f61bf88
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 kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
27 #define kHTMLMime "text/html"
28 #define kAOLMailMime "AOLMAIL"
29 #define kPNGImageMime "image/png"
30 #define kJPEGImageMime "image/jpeg"
31 #define kJPGImageMime "image/jpg"
32 #define kGIFImageMime "image/gif"
33 #define kFileMime "application/x-moz-file"
35 #define kURLMime "text/x-moz-url" // data contains url\ntitle
36 #define kURLDataMime "text/x-moz-url-data" // data contains url only
37 #define kURLDescriptionMime "text/x-moz-url-desc" // data contains description
38 #define kURLPrivateMime "text/x-moz-url-priv" // same as kURLDataMime but for private uses
39 #define kNativeImageMime "application/x-moz-nativeimage"
40 #define kNativeHTMLMime "application/x-moz-nativehtml"
42 // These are used to indicate the context for a fragment of HTML source, such
43 // that some parent structure and style can be preserved. kHTMLContext
44 // contains the serialized ancestor elements, whereas kHTMLInfo are numbers
45 // identifying where in the context the fragment was from.
46 #define kHTMLContext "text/_moz_htmlcontext"
47 #define kHTMLInfo "text/_moz_htmlinfo"
49 // Holds the MIME type from the image request. This is used to ensure the
50 // local application handler for the request's MIME type accepts images with
51 // the given filename extension (from kFilePromiseDestFilename). When the
52 // image is dragged out, we replace the extension with a compatible extension.
53 #define kImageRequestMime "text/x-moz-requestmime"
55 // the source URL for a file promise
56 #define kFilePromiseURLMime "application/x-moz-file-promise-url"
57 // the destination filename for a file promise
58 #define kFilePromiseDestFilename "application/x-moz-file-promise-dest-filename"
59 // a dataless flavor used to interact with the OS during file drags
60 #define kFilePromiseMime "application/x-moz-file-promise"
61 // a synthetic flavor, put into the transferable once we know the destination directory of a file drag
62 #define kFilePromiseDirectoryMime "application/x-moz-file-promise-dir"
64 #define kCustomTypesMime "application/x-moz-custom-clipdata"
66 #define kPDFJSMime "application/pdfjs"
71 /**
72 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
73 * supplying the data lazily.
75 * To use it, call setTransferData, passing the flavor string and
76 * a nsIFlavorDataProvider QI'd to nsISupports.
78 * When someone calls getTransferData later, if the data size is
79 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
80 * and its getFlavorData called.
83 interface nsITransferable;
84 interface nsILoadContext;
86 [scriptable, uuid(7E225E5F-711C-11D7-9FAE-000393636592)]
87 interface nsIFlavorDataProvider : nsISupports
90 /**
91 * Retrieve the data from this data provider.
93 * @param aTransferable (in parameter) the transferable we're being called for.
94 * @param aFlavor (in parameter) the flavor of data to retrieve
95 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
97 void getFlavorData(in nsITransferable aTransferable, in string aFlavor, out nsISupports aData);
101 [scriptable, builtinclass, uuid(97e0c418-1c1e-4106-bad1-9fcb11dff2fe)]
102 interface nsITransferable : nsISupports
105 * Initializes a transferable object. This should be called on all
106 * transferable objects. Failure to do so will result in fatal assertions in
107 * debug builds.
109 * The load context is used to track whether the transferable is storing privacy-
110 * sensitive information.
112 * To get the appropriate load context in Javascript callers, one needs to get
113 * to the document that the transferable corresponds to, and then get the load
114 * context from the document like this:
116 * var loadContext = doc.defaultView.docShell
117 * .QueryInterface(Ci.nsILoadContext);
119 * In C++ callers, if you have the corresponding document, you can just call
120 * Document::GetLoadContext to get to the load context object.
122 * @param aContext the load context associated with the transferable object.
123 * This can be set to null if a load context is not available.
125 void init(in nsILoadContext aContext);
128 * Computes a list of flavors that the transferable can export, either
129 * through intrinsic knowledge or output data converters.
131 Array<ACString> flavorsTransferableCanExport();
134 * Given a flavor retrieve the data.
136 * @param aFlavor (in parameter) the flavor of data to retrieve
137 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
139 [must_use] void getTransferData(in string aFlavor, out nsISupports aData);
142 * Returns the first flavor which has data.
144 * @param aFlavor (out parameter) the flavor of data that was retrieved
145 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
147 void getAnyTransferData(out ACString aFlavor, out nsISupports aData);
149 ///////////////////////////////
150 // Setter part of interface
151 ///////////////////////////////
154 * Computes a list of flavors that the transferable can
155 * accept into it, either through intrinsic knowledge or input data converters.
158 Array<ACString> flavorsTransferableCanImport();
161 * Sets the data in the transferable with the specified flavor. The transferable
162 * will maintain its own copy the data, so it is not necessary to do that beforehand.
164 * @param aFlavor the flavor of data that is being set
165 * @param aData the data, either some variant of class in nsISupportsPrimitives.idl,
166 * an nsIFile, or an nsIFlavorDataProvider (see above)
168 void setTransferData(in string aFlavor, in nsISupports aData);
171 * Add the data flavor, indicating that this transferable
172 * can receive this type of flavor
174 * @param aDataFlavor a new data flavor to handle
176 void addDataFlavor ( in string aDataFlavor ) ;
179 * Removes the data flavor matching the given one (string compare) and the data
180 * that goes along with it.
182 * @param aDataFlavor a data flavor to remove
184 void removeDataFlavor ( in string aDataFlavor ) ;
186 attribute nsIFormatConverter converter;
189 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
190 * be avoided as much as possible because the value set may not reflect the status
191 * of the context in which the transferable was created.
193 [notxpcom, nostdcall] attribute boolean isPrivateData;
196 * The principal of the source dom node this transferable was
197 * created from and the contentPolicyType for the transferable.
198 * Note, currently only used on Windows for network principal and
199 * contentPolicyType information in clipboard and drag operations.
201 [notxpcom, nostdcall] attribute nsIPrincipal requestingPrincipal;
202 [notxpcom, nostdcall] attribute nsContentPolicyType contentPolicyType;
205 * The cookieJarSettings of the source dom node this transferable was created
206 * from.
208 [notxpcom, nostdcall] attribute nsICookieJarSettings cookieJarSettings;