Bug 1700051: part 28) Refactor `WordSplitState<T>::GetDOMWordSeparatorOffset` to...
[gecko.git] / widget / nsITransferable.idl
blob5a429b8cb7c350697395bb2a75c45f71024460c1
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 // these probably shouldn't live here, but in some central repository shared
18 // by the entire app.
19 #define kTextMime "text/plain"
20 #define kRTFMime "text/rtf"
21 #define kUnicodeMime "text/unicode"
22 #define kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
23 #define kHTMLMime "text/html"
24 #define kAOLMailMime "AOLMAIL"
25 #define kPNGImageMime "image/png"
26 #define kJPEGImageMime "image/jpeg"
27 #define kJPGImageMime "image/jpg"
28 #define kGIFImageMime "image/gif"
29 #define kFileMime "application/x-moz-file"
31 #define kURLMime "text/x-moz-url" // data contains url\ntitle
32 #define kURLDataMime "text/x-moz-url-data" // data contains url only
33 #define kURLDescriptionMime "text/x-moz-url-desc" // data contains description
34 #define kURLPrivateMime "text/x-moz-url-priv" // same as kURLDataMime but for private uses
35 #define kNativeImageMime "application/x-moz-nativeimage"
36 #define kNativeHTMLMime "application/x-moz-nativehtml"
38 // These are used to indicate the context for a fragment of HTML source, such
39 // that some parent structure and style can be preserved. kHTMLContext
40 // contains the serialized ancestor elements, whereas kHTMLInfo are numbers
41 // identifying where in the context the fragment was from.
42 #define kHTMLContext "text/_moz_htmlcontext"
43 #define kHTMLInfo "text/_moz_htmlinfo"
45 // Holds the MIME type from the image request. This is used to ensure the
46 // local application handler for the request's MIME type accepts images with
47 // the given filename extension (from kFilePromiseDestFilename). When the
48 // image is dragged out, we replace the extension with a compatible extension.
49 #define kImageRequestMime "text/_moz_requestmime"
51 // the source URL for a file promise
52 #define kFilePromiseURLMime "application/x-moz-file-promise-url"
53 // the destination filename for a file promise
54 #define kFilePromiseDestFilename "application/x-moz-file-promise-dest-filename"
55 // a dataless flavor used to interact with the OS during file drags
56 #define kFilePromiseMime "application/x-moz-file-promise"
57 // a synthetic flavor, put into the transferable once we know the destination directory of a file drag
58 #define kFilePromiseDirectoryMime "application/x-moz-file-promise-dir"
60 #define kCustomTypesMime "application/x-moz-custom-clipdata"
65 /**
66 * nsIFlavorDataProvider allows a flavor to 'promise' data later,
67 * supplying the data lazily.
69 * To use it, call setTransferData, passing the flavor string and
70 * a nsIFlavorDataProvider QI'd to nsISupports.
72 * When someone calls getTransferData later, if the data size is
73 * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider,
74 * and its getFlavorData called.
77 interface nsITransferable;
78 interface nsILoadContext;
80 [scriptable, uuid(7E225E5F-711C-11D7-9FAE-000393636592)]
81 interface nsIFlavorDataProvider : nsISupports
84 /**
85 * Retrieve the data from this data provider.
87 * @param aTransferable (in parameter) the transferable we're being called for.
88 * @param aFlavor (in parameter) the flavor of data to retrieve
89 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
91 void getFlavorData(in nsITransferable aTransferable, in string aFlavor, out nsISupports aData);
95 [scriptable, builtinclass, uuid(97e0c418-1c1e-4106-bad1-9fcb11dff2fe)]
96 interface nsITransferable : nsISupports
98 /**
99 * Initializes a transferable object. This should be called on all
100 * transferable objects. Failure to do so will result in fatal assertions in
101 * debug builds.
103 * The load context is used to track whether the transferable is storing privacy-
104 * sensitive information.
106 * To get the appropriate load context in Javascript callers, one needs to get
107 * to the document that the transferable corresponds to, and then get the load
108 * context from the document like this:
110 * var loadContext = doc.defaultView.docShell
111 * .QueryInterface(Ci.nsILoadContext);
113 * In C++ callers, if you have the corresponding document, you can just call
114 * Document::GetLoadContext to get to the load context object.
116 * @param aContext the load context associated with the transferable object.
117 * This can be set to null if a load context is not available.
119 void init(in nsILoadContext aContext);
122 * Computes a list of flavors that the transferable can export, either
123 * through intrinsic knowledge or output data converters.
125 Array<ACString> flavorsTransferableCanExport();
128 * Given a flavor retrieve the data.
130 * @param aFlavor (in parameter) the flavor of data to retrieve
131 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
133 [must_use] void getTransferData(in string aFlavor, out nsISupports aData);
136 * Returns the first flavor which has data.
138 * @param aFlavor (out parameter) the flavor of data that was retrieved
139 * @param aData the data. Some variant of class in nsISupportsPrimitives.idl
141 void getAnyTransferData(out ACString aFlavor, out nsISupports aData);
143 ///////////////////////////////
144 // Setter part of interface
145 ///////////////////////////////
148 * Computes a list of flavors that the transferable can
149 * accept into it, either through intrinsic knowledge or input data converters.
152 Array<ACString> flavorsTransferableCanImport();
155 * Sets the data in the transferable with the specified flavor. The transferable
156 * will maintain its own copy the data, so it is not necessary to do that beforehand.
158 * @param aFlavor the flavor of data that is being set
159 * @param aData the data, either some variant of class in nsISupportsPrimitives.idl,
160 * an nsIFile, or an nsIFlavorDataProvider (see above)
162 void setTransferData(in string aFlavor, in nsISupports aData);
165 * Add the data flavor, indicating that this transferable
166 * can receive this type of flavor
168 * @param aDataFlavor a new data flavor to handle
170 void addDataFlavor ( in string aDataFlavor ) ;
173 * Removes the data flavor matching the given one (string compare) and the data
174 * that goes along with it.
176 * @param aDataFlavor a data flavor to remove
178 void removeDataFlavor ( in string aDataFlavor ) ;
180 attribute nsIFormatConverter converter;
183 * Use of the SetIsPrivateData() method generated by isPrivateData attribute should
184 * be avoided as much as possible because the value set may not reflect the status
185 * of the context in which the transferable was created.
187 [notxpcom, nostdcall] attribute boolean isPrivateData;
190 * The principal of the source dom node this transferable was
191 * created from and the contentPolicyType for the transferable.
192 * Note, currently only used on Windows for network principal and
193 * contentPolicyType information in clipboard and drag operations.
195 [notxpcom, nostdcall] attribute nsIPrincipal requestingPrincipal;
196 [notxpcom, nostdcall] attribute nsContentPolicyType contentPolicyType;
199 * The cookieJarSettings of the source dom node this transferable was created
200 * from.
202 [notxpcom, nostdcall] attribute nsICookieJarSettings cookieJarSettings;