michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsISupportsArray.idl" michael@0: #include "nsIFormatConverter.idl" michael@0: michael@0: michael@0: %{ C++ michael@0: michael@0: // these probably shouldn't live here, but in some central repository shared michael@0: // by the entire app. michael@0: #define kTextMime "text/plain" michael@0: #define kUnicodeMime "text/unicode" michael@0: #define kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps. michael@0: #define kHTMLMime "text/html" michael@0: #define kAOLMailMime "AOLMAIL" michael@0: #define kPNGImageMime "image/png" michael@0: #define kJPEGImageMime "image/jpeg" michael@0: #define kJPGImageMime "image/jpg" michael@0: #define kGIFImageMime "image/gif" michael@0: #define kFileMime "application/x-moz-file" michael@0: michael@0: #define kURLMime "text/x-moz-url" // data contains url\ntitle michael@0: #define kURLDataMime "text/x-moz-url-data" // data contains url only michael@0: #define kURLDescriptionMime "text/x-moz-url-desc" // data contains description michael@0: #define kURLPrivateMime "text/x-moz-url-priv" // same as kURLDataMime but for private uses michael@0: #define kNativeImageMime "application/x-moz-nativeimage" michael@0: #define kNativeHTMLMime "application/x-moz-nativehtml" michael@0: michael@0: // These are used to indicate the context for a fragment of HTML source, such michael@0: // that some parent structure and style can be preserved. kHTMLContext michael@0: // contains the serialized ancestor elements, whereas kHTMLInfo are numbers michael@0: // identifying where in the context the fragment was from. michael@0: #define kHTMLContext "text/_moz_htmlcontext" michael@0: #define kHTMLInfo "text/_moz_htmlinfo" michael@0: michael@0: // the source URL for a file promise michael@0: #define kFilePromiseURLMime "application/x-moz-file-promise-url" michael@0: // the destination filename for a file promise michael@0: #define kFilePromiseDestFilename "application/x-moz-file-promise-dest-filename" michael@0: // a dataless flavor used to interact with the OS during file drags michael@0: #define kFilePromiseMime "application/x-moz-file-promise" michael@0: // a synthetic flavor, put into the transferable once we know the destination directory of a file drag michael@0: #define kFilePromiseDirectoryMime "application/x-moz-file-promise-dir" michael@0: michael@0: %} michael@0: michael@0: michael@0: /** michael@0: * nsIFlavorDataProvider allows a flavor to 'promise' data later, michael@0: * supplying the data lazily. michael@0: * michael@0: * To use it, call setTransferData, passing the flavor string, michael@0: * a nsIFlavorDataProvider QI'd to nsISupports, and a data size of 0. michael@0: * michael@0: * When someone calls getTransferData later, if the data size is michael@0: * stored as 0, the nsISupports will be QI'd to nsIFlavorDataProvider, michael@0: * and its getFlavorData called. michael@0: * michael@0: */ michael@0: interface nsITransferable; michael@0: interface nsILoadContext; michael@0: michael@0: [scriptable, uuid(7E225E5F-711C-11D7-9FAE-000393636592)] michael@0: interface nsIFlavorDataProvider : nsISupports michael@0: { michael@0: michael@0: /** michael@0: * Retrieve the data from this data provider. michael@0: * michael@0: * @param aTransferable (in parameter) the transferable we're being called for. michael@0: * @param aFlavor (in parameter) the flavor of data to retrieve michael@0: * @param aData the data. Some variant of class in nsISupportsPrimitives.idl michael@0: * @param aDataLen the length of the data michael@0: */ michael@0: void getFlavorData(in nsITransferable aTransferable, in string aFlavor, out nsISupports aData, out unsigned long aDataLen); michael@0: }; michael@0: michael@0: michael@0: [scriptable, uuid(5a611a60-e5b5-11e1-aff1-0800200c9a66)] michael@0: interface nsITransferable : nsISupports michael@0: { michael@0: const long kFlavorHasDataProvider = 0; michael@0: michael@0: /** michael@0: * Initializes a transferable object. This should be called on all michael@0: * transferable objects. Failure to do so will result in fatal assertions in michael@0: * debug builds. michael@0: * michael@0: * The load context is used to track whether the transferable is storing privacy- michael@0: * sensitive information. For example, we try to delete data that you copy michael@0: * to the clipboard when you close a Private Browsing window. michael@0: * michael@0: * To get the appropriate load context in Javascript callers, one needs to get michael@0: * to the document that the transferable corresponds to, and then get the load michael@0: * context from the document like this: michael@0: * michael@0: * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) michael@0: * .getInterface(Ci.nsIWebNavigation) michael@0: * .QueryInterface(Ci.nsILoadContext); michael@0: * michael@0: * In C++ callers, if you have the corresponding document, you can just call michael@0: * nsIDocument::GetLoadContext to get to the load context object. michael@0: * michael@0: * @param aContext the load context associated with the transferable object. michael@0: * This can be set to null if a load context is not available. michael@0: */ michael@0: void init(in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Computes a list of flavors (mime types as nsISupportsCString) that the transferable michael@0: * can export, either through intrinsic knowledge or output data converters. michael@0: * michael@0: * @param aDataFlavorList fills list with supported flavors. This is a copy of michael@0: * the internal list, so it may be edited w/out affecting the transferable. michael@0: */ michael@0: nsISupportsArray flavorsTransferableCanExport ( ) ; michael@0: michael@0: /** michael@0: * Given a flavor retrieve the data. michael@0: * michael@0: * @param aFlavor (in parameter) the flavor of data to retrieve michael@0: * @param aData the data. Some variant of class in nsISupportsPrimitives.idl michael@0: * @param aDataLen the length of the data michael@0: */ michael@0: void getTransferData ( in string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ; michael@0: michael@0: /** michael@0: * Returns the best flavor in the transferable, given those that have michael@0: * been added to it with |AddFlavor()| michael@0: * michael@0: * @param aFlavor (out parameter) the flavor of data that was retrieved michael@0: * @param aData the data. Some variant of class in nsISupportsPrimitives.idl michael@0: * @param aDataLen the length of the data michael@0: */ michael@0: void getAnyTransferData ( out string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ; michael@0: michael@0: /** michael@0: * Returns true if the data is large. michael@0: */ michael@0: boolean isLargeDataSet ( ) ; michael@0: michael@0: michael@0: /////////////////////////////// michael@0: // Setter part of interface michael@0: /////////////////////////////// michael@0: michael@0: /** michael@0: * Computes a list of flavors (mime types as nsISupportsCString) that the transferable can michael@0: * accept into it, either through intrinsic knowledge or input data converters. michael@0: * michael@0: * @param outFlavorList fills list with supported flavors. This is a copy of michael@0: * the internal list, so it may be edited w/out affecting the transferable. michael@0: */ michael@0: nsISupportsArray flavorsTransferableCanImport ( ) ; michael@0: michael@0: /** michael@0: * Sets the data in the transferable with the specified flavor. The transferable michael@0: * will maintain its own copy the data, so it is not necessary to do that beforehand. michael@0: * michael@0: * @param aFlavor the flavor of data that is being set michael@0: * @param aData the data, either some variant of class in nsISupportsPrimitives.idl, michael@0: * an nsIFile, or an nsIFlavorDataProvider (see above) michael@0: * @param aDataLen the length of the data, or 0 if passing a nsIFlavorDataProvider michael@0: */ michael@0: void setTransferData ( in string aFlavor, in nsISupports aData, in unsigned long aDataLen ) ; michael@0: michael@0: /** michael@0: * Add the data flavor, indicating that this transferable michael@0: * can receive this type of flavor michael@0: * michael@0: * @param aDataFlavor a new data flavor to handle michael@0: */ michael@0: void addDataFlavor ( in string aDataFlavor ) ; michael@0: michael@0: /** michael@0: * Removes the data flavor matching the given one (string compare) and the data michael@0: * that goes along with it. michael@0: * michael@0: * @param aDataFlavor a data flavor to remove michael@0: */ michael@0: void removeDataFlavor ( in string aDataFlavor ) ; michael@0: michael@0: attribute nsIFormatConverter converter; michael@0: michael@0: /** michael@0: * Use of the SetIsPrivateData() method generated by isPrivateData attribute should michael@0: * be avoided as much as possible because the value set may not reflect the status michael@0: * of the context in which the transferable was created. michael@0: */ michael@0: [noscript] attribute boolean isPrivateData; michael@0: michael@0: }; michael@0: