Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | #include "nsISupportsArray.idl" |
michael@0 | 9 | #include "nsIFormatConverter.idl" |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | %{ C++ |
michael@0 | 13 | |
michael@0 | 14 | // these probably shouldn't live here, but in some central repository shared |
michael@0 | 15 | // by the entire app. |
michael@0 | 16 | #define kTextMime "text/plain" |
michael@0 | 17 | #define kUnicodeMime "text/unicode" |
michael@0 | 18 | #define kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps. |
michael@0 | 19 | #define kHTMLMime "text/html" |
michael@0 | 20 | #define kAOLMailMime "AOLMAIL" |
michael@0 | 21 | #define kPNGImageMime "image/png" |
michael@0 | 22 | #define kJPEGImageMime "image/jpeg" |
michael@0 | 23 | #define kJPGImageMime "image/jpg" |
michael@0 | 24 | #define kGIFImageMime "image/gif" |
michael@0 | 25 | #define kFileMime "application/x-moz-file" |
michael@0 | 26 | |
michael@0 | 27 | #define kURLMime "text/x-moz-url" // data contains url\ntitle |
michael@0 | 28 | #define kURLDataMime "text/x-moz-url-data" // data contains url only |
michael@0 | 29 | #define kURLDescriptionMime "text/x-moz-url-desc" // data contains description |
michael@0 | 30 | #define kURLPrivateMime "text/x-moz-url-priv" // same as kURLDataMime but for private uses |
michael@0 | 31 | #define kNativeImageMime "application/x-moz-nativeimage" |
michael@0 | 32 | #define kNativeHTMLMime "application/x-moz-nativehtml" |
michael@0 | 33 | |
michael@0 | 34 | // These are used to indicate the context for a fragment of HTML source, such |
michael@0 | 35 | // that some parent structure and style can be preserved. kHTMLContext |
michael@0 | 36 | // contains the serialized ancestor elements, whereas kHTMLInfo are numbers |
michael@0 | 37 | // identifying where in the context the fragment was from. |
michael@0 | 38 | #define kHTMLContext "text/_moz_htmlcontext" |
michael@0 | 39 | #define kHTMLInfo "text/_moz_htmlinfo" |
michael@0 | 40 | |
michael@0 | 41 | // the source URL for a file promise |
michael@0 | 42 | #define kFilePromiseURLMime "application/x-moz-file-promise-url" |
michael@0 | 43 | // the destination filename for a file promise |
michael@0 | 44 | #define kFilePromiseDestFilename "application/x-moz-file-promise-dest-filename" |
michael@0 | 45 | // a dataless flavor used to interact with the OS during file drags |
michael@0 | 46 | #define kFilePromiseMime "application/x-moz-file-promise" |
michael@0 | 47 | // a synthetic flavor, put into the transferable once we know the destination directory of a file drag |
michael@0 | 48 | #define kFilePromiseDirectoryMime "application/x-moz-file-promise-dir" |
michael@0 | 49 | |
michael@0 | 50 | %} |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * nsIFlavorDataProvider allows a flavor to 'promise' data later, |
michael@0 | 55 | * supplying the data lazily. |
michael@0 | 56 | * |
michael@0 | 57 | * To use it, call setTransferData, passing the flavor string, |
michael@0 | 58 | * a nsIFlavorDataProvider QI'd to nsISupports, and a data size of 0. |
michael@0 | 59 | * |
michael@0 | 60 | * When someone calls getTransferData later, if the data size is |
michael@0 | 61 | * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider, |
michael@0 | 62 | * and its getFlavorData called. |
michael@0 | 63 | * |
michael@0 | 64 | */ |
michael@0 | 65 | interface nsITransferable; |
michael@0 | 66 | interface nsILoadContext; |
michael@0 | 67 | |
michael@0 | 68 | [scriptable, uuid(7E225E5F-711C-11D7-9FAE-000393636592)] |
michael@0 | 69 | interface nsIFlavorDataProvider : nsISupports |
michael@0 | 70 | { |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Retrieve the data from this data provider. |
michael@0 | 74 | * |
michael@0 | 75 | * @param aTransferable (in parameter) the transferable we're being called for. |
michael@0 | 76 | * @param aFlavor (in parameter) the flavor of data to retrieve |
michael@0 | 77 | * @param aData the data. Some variant of class in nsISupportsPrimitives.idl |
michael@0 | 78 | * @param aDataLen the length of the data |
michael@0 | 79 | */ |
michael@0 | 80 | void getFlavorData(in nsITransferable aTransferable, in string aFlavor, out nsISupports aData, out unsigned long aDataLen); |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | [scriptable, uuid(5a611a60-e5b5-11e1-aff1-0800200c9a66)] |
michael@0 | 85 | interface nsITransferable : nsISupports |
michael@0 | 86 | { |
michael@0 | 87 | const long kFlavorHasDataProvider = 0; |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Initializes a transferable object. This should be called on all |
michael@0 | 91 | * transferable objects. Failure to do so will result in fatal assertions in |
michael@0 | 92 | * debug builds. |
michael@0 | 93 | * |
michael@0 | 94 | * The load context is used to track whether the transferable is storing privacy- |
michael@0 | 95 | * sensitive information. For example, we try to delete data that you copy |
michael@0 | 96 | * to the clipboard when you close a Private Browsing window. |
michael@0 | 97 | * |
michael@0 | 98 | * To get the appropriate load context in Javascript callers, one needs to get |
michael@0 | 99 | * to the document that the transferable corresponds to, and then get the load |
michael@0 | 100 | * context from the document like this: |
michael@0 | 101 | * |
michael@0 | 102 | * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 103 | * .getInterface(Ci.nsIWebNavigation) |
michael@0 | 104 | * .QueryInterface(Ci.nsILoadContext); |
michael@0 | 105 | * |
michael@0 | 106 | * In C++ callers, if you have the corresponding document, you can just call |
michael@0 | 107 | * nsIDocument::GetLoadContext to get to the load context object. |
michael@0 | 108 | * |
michael@0 | 109 | * @param aContext the load context associated with the transferable object. |
michael@0 | 110 | * This can be set to null if a load context is not available. |
michael@0 | 111 | */ |
michael@0 | 112 | void init(in nsILoadContext aContext); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Computes a list of flavors (mime types as nsISupportsCString) that the transferable |
michael@0 | 116 | * can export, either through intrinsic knowledge or output data converters. |
michael@0 | 117 | * |
michael@0 | 118 | * @param aDataFlavorList fills list with supported flavors. This is a copy of |
michael@0 | 119 | * the internal list, so it may be edited w/out affecting the transferable. |
michael@0 | 120 | */ |
michael@0 | 121 | nsISupportsArray flavorsTransferableCanExport ( ) ; |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * Given a flavor retrieve the data. |
michael@0 | 125 | * |
michael@0 | 126 | * @param aFlavor (in parameter) the flavor of data to retrieve |
michael@0 | 127 | * @param aData the data. Some variant of class in nsISupportsPrimitives.idl |
michael@0 | 128 | * @param aDataLen the length of the data |
michael@0 | 129 | */ |
michael@0 | 130 | void getTransferData ( in string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ; |
michael@0 | 131 | |
michael@0 | 132 | /** |
michael@0 | 133 | * Returns the best flavor in the transferable, given those that have |
michael@0 | 134 | * been added to it with |AddFlavor()| |
michael@0 | 135 | * |
michael@0 | 136 | * @param aFlavor (out parameter) the flavor of data that was retrieved |
michael@0 | 137 | * @param aData the data. Some variant of class in nsISupportsPrimitives.idl |
michael@0 | 138 | * @param aDataLen the length of the data |
michael@0 | 139 | */ |
michael@0 | 140 | void getAnyTransferData ( out string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ; |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * Returns true if the data is large. |
michael@0 | 144 | */ |
michael@0 | 145 | boolean isLargeDataSet ( ) ; |
michael@0 | 146 | |
michael@0 | 147 | |
michael@0 | 148 | /////////////////////////////// |
michael@0 | 149 | // Setter part of interface |
michael@0 | 150 | /////////////////////////////// |
michael@0 | 151 | |
michael@0 | 152 | /** |
michael@0 | 153 | * Computes a list of flavors (mime types as nsISupportsCString) that the transferable can |
michael@0 | 154 | * accept into it, either through intrinsic knowledge or input data converters. |
michael@0 | 155 | * |
michael@0 | 156 | * @param outFlavorList fills list with supported flavors. This is a copy of |
michael@0 | 157 | * the internal list, so it may be edited w/out affecting the transferable. |
michael@0 | 158 | */ |
michael@0 | 159 | nsISupportsArray flavorsTransferableCanImport ( ) ; |
michael@0 | 160 | |
michael@0 | 161 | /** |
michael@0 | 162 | * Sets the data in the transferable with the specified flavor. The transferable |
michael@0 | 163 | * will maintain its own copy the data, so it is not necessary to do that beforehand. |
michael@0 | 164 | * |
michael@0 | 165 | * @param aFlavor the flavor of data that is being set |
michael@0 | 166 | * @param aData the data, either some variant of class in nsISupportsPrimitives.idl, |
michael@0 | 167 | * an nsIFile, or an nsIFlavorDataProvider (see above) |
michael@0 | 168 | * @param aDataLen the length of the data, or 0 if passing a nsIFlavorDataProvider |
michael@0 | 169 | */ |
michael@0 | 170 | void setTransferData ( in string aFlavor, in nsISupports aData, in unsigned long aDataLen ) ; |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * Add the data flavor, indicating that this transferable |
michael@0 | 174 | * can receive this type of flavor |
michael@0 | 175 | * |
michael@0 | 176 | * @param aDataFlavor a new data flavor to handle |
michael@0 | 177 | */ |
michael@0 | 178 | void addDataFlavor ( in string aDataFlavor ) ; |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Removes the data flavor matching the given one (string compare) and the data |
michael@0 | 182 | * that goes along with it. |
michael@0 | 183 | * |
michael@0 | 184 | * @param aDataFlavor a data flavor to remove |
michael@0 | 185 | */ |
michael@0 | 186 | void removeDataFlavor ( in string aDataFlavor ) ; |
michael@0 | 187 | |
michael@0 | 188 | attribute nsIFormatConverter converter; |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Use of the SetIsPrivateData() method generated by isPrivateData attribute should |
michael@0 | 192 | * be avoided as much as possible because the value set may not reflect the status |
michael@0 | 193 | * of the context in which the transferable was created. |
michael@0 | 194 | */ |
michael@0 | 195 | [noscript] attribute boolean isPrivateData; |
michael@0 | 196 | |
michael@0 | 197 | }; |
michael@0 | 198 |