nsIWebBrowserPersist.idl (11605B)
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 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/. */ 6 7 #include "nsICancelable.idl" 8 #include "nsIContentPolicy.idl" 9 10 interface nsIURI; 11 interface nsIInputStream; 12 interface nsIWebProgressListener; 13 interface nsIFile; 14 interface nsIChannel; 15 interface nsILoadContext; 16 interface nsIPrincipal; 17 interface nsIReferrerInfo; 18 interface nsICookieJarSettings; 19 20 /** 21 * Interface for persisting DOM documents and URIs to local or remote storage. 22 */ 23 [scriptable, uuid(8cd752a4-60b1-42c3-a819-65c7a1138a28)] 24 interface nsIWebBrowserPersist : nsICancelable 25 { 26 /** No special persistence behaviour. */ 27 const unsigned long PERSIST_FLAGS_NONE = 0; 28 /** Use cached data if present (skipping validation), else load from network */ 29 const unsigned long PERSIST_FLAGS_FROM_CACHE = 1; 30 /** Bypass the cached data. */ 31 const unsigned long PERSIST_FLAGS_BYPASS_CACHE = 2; 32 /** Ignore any redirected data (usually adverts). */ 33 const unsigned long PERSIST_FLAGS_IGNORE_REDIRECTED_DATA = 4; 34 /** Ignore IFRAME content (usually adverts). */ 35 const unsigned long PERSIST_FLAGS_IGNORE_IFRAMES = 8; 36 /** Do not run the incoming data through a content converter e.g. to decompress it */ 37 const unsigned long PERSIST_FLAGS_NO_CONVERSION = 16; 38 /** Replace existing files on the disk (use with due diligence!) */ 39 const unsigned long PERSIST_FLAGS_REPLACE_EXISTING_FILES = 32; 40 /** Don't modify or add base tags */ 41 const unsigned long PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS = 64; 42 /** Make changes to original dom rather than cloning nodes */ 43 const unsigned long PERSIST_FLAGS_FIXUP_ORIGINAL_DOM = 128; 44 /** Fix links relative to destination location (not origin) */ 45 const unsigned long PERSIST_FLAGS_FIXUP_LINKS_TO_DESTINATION = 256; 46 /** Don't make any adjustments to links */ 47 const unsigned long PERSIST_FLAGS_DONT_FIXUP_LINKS = 512; 48 /** Force serialization of output (one file at a time; not concurrent) */ 49 const unsigned long PERSIST_FLAGS_SERIALIZE_OUTPUT = 1024; 50 /** Don't make any adjustments to filenames */ 51 const unsigned long PERSIST_FLAGS_DONT_CHANGE_FILENAMES = 2048; 52 /** Fail on broken inline links */ 53 const unsigned long PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS = 4096; 54 /** 55 * Automatically cleanup after a failed or cancelled operation, deleting all 56 * created files and directories. This flag does nothing for failed upload 57 * operations to remote servers. 58 */ 59 const unsigned long PERSIST_FLAGS_CLEANUP_ON_FAILURE = 8192; 60 /** 61 * Let the WebBrowserPersist decide whether the incoming data is encoded 62 * and whether it needs to go through a content converter e.g. to 63 * decompress it. 64 */ 65 const unsigned long PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION = 16384; 66 /** 67 * Append the downloaded data to the target file. 68 * This can only be used when persisting to a local file. 69 */ 70 const unsigned long PERSIST_FLAGS_APPEND_TO_FILE = 32768; 71 /** Unconditionally disable HTTPS-Only and HTTPS-First upgrades */ 72 const unsigned long PERSIST_FLAGS_DISABLE_HTTPS_ONLY = 65536; 73 74 /** 75 * Flags governing how data is fetched and saved from the network. 76 * It is best to set this value explicitly unless you are prepared 77 * to accept the default values. 78 */ 79 attribute unsigned long persistFlags; 80 81 /** Persister is ready to save data */ 82 const unsigned long PERSIST_STATE_READY = 1; 83 /** Persister is saving data */ 84 const unsigned long PERSIST_STATE_SAVING = 2; 85 /** Persister has finished saving data */ 86 const unsigned long PERSIST_STATE_FINISHED = 3; 87 88 /** 89 * Current state of the persister object. 90 */ 91 readonly attribute unsigned long currentState; 92 93 /** 94 * Value indicating the success or failure of the persist 95 * operation. 96 * 97 * @throws NS_BINDING_ABORTED Operation cancelled. 98 * @throws NS_ERROR_FAILURE Non-specific failure. 99 */ 100 readonly attribute nsresult result; 101 102 /** 103 * Callback listener for progress notifications. The object that the 104 * embbedder supplies may also implement nsIInterfaceRequestor and be 105 * prepared to return nsIAuthPrompt or other interfaces that may be required 106 * to download data. 107 * 108 * @see nsIAuthPrompt 109 * @see nsIInterfaceRequestor 110 */ 111 attribute nsIWebProgressListener progressListener; 112 113 /** 114 * Save the specified URI to file. 115 * 116 * @param aURI URI to save to file. Some implementations of this interface 117 * may also support <CODE>nullptr</CODE> to imply the currently 118 * loaded URI. 119 * @param aTriggeringPrincipal 120 * The triggering principal for the URI we're saving. 121 * @param aCacheKey The necko cache key integer. 122 * @param aReferrerInfo The referrer info for compute and send referrer via 123 * HTTP Referer header. 124 * @param aCookieJarSettings The cookieJarSettings for the HTTP channel which 125 * is saving the URI. 126 * @param aPostData Post data to pass with an HTTP request or 127 * <CODE>nullptr</CODE>. 128 * @param aExtraHeaders Additional headers to supply with an HTTP request 129 * or <CODE>nullptr</CODE>. 130 * @param aFile Target file. This may be a nsIFile object or an 131 * nsIURI object with a file scheme or a scheme that 132 * supports uploading (e.g. ftp). 133 * @param aContentPolicyType The type of content we're saving. 134 * @param aIsPrivate Treat the save operation as private (ie. with 135 * regards to networking operations and persistence 136 * of intermediate data, etc.) 137 * 138 * @see nsIFile 139 * @see nsIURI 140 * @see nsIInputStream 141 * 142 * @throws NS_ERROR_INVALID_ARG One or more arguments was invalid. 143 */ 144 void saveURI(in nsIURI aURI, 145 in nsIPrincipal aTriggeringPrincipal, in unsigned long aCacheKey, 146 in nsIReferrerInfo aReferrerInfo, 147 in nsICookieJarSettings aCookieJarSettings, 148 in nsIInputStream aPostData, 149 in string aExtraHeaders, in nsISupports aFile, 150 in nsContentPolicyType aContentPolicyType, 151 in boolean aIsPrivate); 152 153 /** 154 * Save a channel to a file. It must not be opened yet. 155 * @see saveURI 156 */ 157 void saveChannel(in nsIChannel aChannel, in nsISupports aFile); 158 159 /** Output only the current selection as opposed to the whole document. */ 160 const unsigned long ENCODE_FLAGS_SELECTION_ONLY = 1; 161 /** 162 * For plaintext output. Convert html to plaintext that looks like the html. 163 * Implies wrap (except inside <pre>), since html wraps. 164 * HTML output: always do prettyprinting, ignoring existing formatting. 165 */ 166 const unsigned long ENCODE_FLAGS_FORMATTED = 2; 167 /** 168 * Output without formatting or wrapping the content. This flag 169 * may be used to preserve the original formatting as much as possible. 170 */ 171 const unsigned long ENCODE_FLAGS_RAW = 4; 172 /** Output only the body section, no HTML tags. */ 173 const unsigned long ENCODE_FLAGS_BODY_ONLY = 8; 174 /** Wrap even if when not doing formatted output (e.g. for text fields). */ 175 const unsigned long ENCODE_FLAGS_PREFORMATTED = 16; 176 /** Wrap documents at the specified column. */ 177 const unsigned long ENCODE_FLAGS_WRAP = 32; 178 /** 179 * For plaintext output. Output for format flowed (RFC 2646). This is used 180 * when converting to text for mail sending. This differs just slightly 181 * but in an important way from normal formatted, and that is that 182 * lines are space stuffed. This can't (correctly) be done later. 183 */ 184 const unsigned long ENCODE_FLAGS_FORMAT_FLOWED = 64; 185 /** Convert links to absolute links where possible. */ 186 const unsigned long ENCODE_FLAGS_ABSOLUTE_LINKS = 128; 187 188 /** 189 * Output with carriage return line breaks. May also be combined with 190 * ENCODE_FLAGS_LF_LINEBREAKS and if neither is specified, the platform 191 * default format is used. 192 */ 193 const unsigned long ENCODE_FLAGS_CR_LINEBREAKS = 512; 194 /** 195 * Output with linefeed line breaks. May also be combined with 196 * ENCODE_FLAGS_CR_LINEBREAKS and if neither is specified, the platform 197 * default format is used. 198 */ 199 const unsigned long ENCODE_FLAGS_LF_LINEBREAKS = 1024; 200 /** For plaintext output. Output the content of noscript elements. */ 201 const unsigned long ENCODE_FLAGS_NOSCRIPT_CONTENT = 2048; 202 /** For plaintext output. Output the content of noframes elements. */ 203 const unsigned long ENCODE_FLAGS_NOFRAMES_CONTENT = 4096; 204 205 /** 206 * Encode basic entities, e.g. output instead of character code 0xa0. 207 * The basic set is just & < > " for interoperability 208 * with older products that don't support α and friends. 209 */ 210 const unsigned long ENCODE_FLAGS_ENCODE_BASIC_ENTITIES = 8192; 211 212 /** 213 * Save the specified DOM document to file and optionally all linked files 214 * (e.g. images, CSS, JS & subframes). Do not call this method until the 215 * document has finished loading! 216 * 217 * @param aDocument Document to save to file. Some implementations of 218 * this interface may also support <CODE>nullptr</CODE> 219 * to imply the currently loaded document. Can be an 220 * nsIWebBrowserPersistDocument or Document. 221 * @param aFile Target local file. This may be a nsIFile object or an 222 * nsIURI object with a file scheme or a scheme that 223 * supports uploading (e.g. ftp). 224 * @param aDataPath Path to directory where URIs linked to the document 225 * are saved or nullptr if no linked URIs should be saved. 226 * This may be a nsIFile object or an nsIURI object 227 * with a file scheme. 228 * @param aOutputContentType The desired MIME type format to save the 229 * document and all subdocuments into or nullptr to use 230 * the default behaviour. 231 * @param aEncodingFlags Flags to pass to the encoder. 232 * @param aWrapColumn For text documents, indicates the desired width to 233 * wrap text at. Parameter is ignored if wrapping is not 234 * specified by the encoding flags. 235 * 236 * @see nsIWebBrowserPersistDocument 237 * @see WebBrowserPersistable 238 * @see nsIFile 239 * @see nsIURI 240 * 241 * @throws NS_ERROR_INVALID_ARG One or more arguments was invalid. 242 */ 243 void saveDocument(in nsISupports aDocument, 244 in nsISupports aFile, in nsISupports aDataPath, 245 in string aOutputContentType, in unsigned long aEncodingFlags, 246 in unsigned long aWrapColumn); 247 248 /** 249 * Cancels the current operation. The caller is responsible for cleaning up 250 * partially written files or directories. This has the same effect as calling 251 * cancel with an argument of NS_BINDING_ABORTED. 252 */ 253 void cancelSave(); 254 }; 255 256 /** 257 * We don't export nsWebBrowserPersist.h as a public header, so we need a place 258 * to put the CID/ContractID. All places uses the WebBrowserPersist include 259 * nsIWebBrowserPersist.h, so we define our contract IDs here for now. 260 */ 261 %{ C++ 262 // {7E677795-C582-4cd1-9E8D-8271B3474D2A} 263 #define NS_WEBBROWSERPERSIST_CID \ 264 { 0x7e677795, 0xc582, 0x4cd1, { 0x9e, 0x8d, 0x82, 0x71, 0xb3, 0x47, 0x4d, 0x2a } } 265 #define NS_WEBBROWSERPERSIST_CONTRACTID \ 266 "@mozilla.org/embedding/browser/nsWebBrowserPersist;1" 267 %}