Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 4; 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 "nsICancelable.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIURI; |
michael@0 | 10 | interface nsIInputStream; |
michael@0 | 11 | interface nsIDOMDocument; |
michael@0 | 12 | interface nsIWebProgressListener; |
michael@0 | 13 | interface nsIFile; |
michael@0 | 14 | interface nsIChannel; |
michael@0 | 15 | interface nsILoadContext; |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * Interface for persisting DOM documents and URIs to local or remote storage. |
michael@0 | 19 | */ |
michael@0 | 20 | [scriptable, uuid(35c1f231-582b-4315-a26c-a1227e3539b4)] |
michael@0 | 21 | interface nsIWebBrowserPersist : nsICancelable |
michael@0 | 22 | { |
michael@0 | 23 | /** No special persistence behaviour. */ |
michael@0 | 24 | const unsigned long PERSIST_FLAGS_NONE = 0; |
michael@0 | 25 | /** Use cached data if present (skipping validation), else load from network */ |
michael@0 | 26 | const unsigned long PERSIST_FLAGS_FROM_CACHE = 1; |
michael@0 | 27 | /** Bypass the cached data. */ |
michael@0 | 28 | const unsigned long PERSIST_FLAGS_BYPASS_CACHE = 2; |
michael@0 | 29 | /** Ignore any redirected data (usually adverts). */ |
michael@0 | 30 | const unsigned long PERSIST_FLAGS_IGNORE_REDIRECTED_DATA = 4; |
michael@0 | 31 | /** Ignore IFRAME content (usually adverts). */ |
michael@0 | 32 | const unsigned long PERSIST_FLAGS_IGNORE_IFRAMES = 8; |
michael@0 | 33 | /** Do not run the incoming data through a content converter e.g. to decompress it */ |
michael@0 | 34 | const unsigned long PERSIST_FLAGS_NO_CONVERSION = 16; |
michael@0 | 35 | /** Replace existing files on the disk (use with due diligence!) */ |
michael@0 | 36 | const unsigned long PERSIST_FLAGS_REPLACE_EXISTING_FILES = 32; |
michael@0 | 37 | /** Don't modify or add base tags */ |
michael@0 | 38 | const unsigned long PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS = 64; |
michael@0 | 39 | /** Make changes to original dom rather than cloning nodes */ |
michael@0 | 40 | const unsigned long PERSIST_FLAGS_FIXUP_ORIGINAL_DOM = 128; |
michael@0 | 41 | /** Fix links relative to destination location (not origin) */ |
michael@0 | 42 | const unsigned long PERSIST_FLAGS_FIXUP_LINKS_TO_DESTINATION = 256; |
michael@0 | 43 | /** Don't make any adjustments to links */ |
michael@0 | 44 | const unsigned long PERSIST_FLAGS_DONT_FIXUP_LINKS = 512; |
michael@0 | 45 | /** Force serialization of output (one file at a time; not concurrent) */ |
michael@0 | 46 | const unsigned long PERSIST_FLAGS_SERIALIZE_OUTPUT = 1024; |
michael@0 | 47 | /** Don't make any adjustments to filenames */ |
michael@0 | 48 | const unsigned long PERSIST_FLAGS_DONT_CHANGE_FILENAMES = 2048; |
michael@0 | 49 | /** Fail on broken inline links */ |
michael@0 | 50 | const unsigned long PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS = 4096; |
michael@0 | 51 | /** |
michael@0 | 52 | * Automatically cleanup after a failed or cancelled operation, deleting all |
michael@0 | 53 | * created files and directories. This flag does nothing for failed upload |
michael@0 | 54 | * operations to remote servers. |
michael@0 | 55 | */ |
michael@0 | 56 | const unsigned long PERSIST_FLAGS_CLEANUP_ON_FAILURE = 8192; |
michael@0 | 57 | /** |
michael@0 | 58 | * Let the WebBrowserPersist decide whether the incoming data is encoded |
michael@0 | 59 | * and whether it needs to go through a content converter e.g. to |
michael@0 | 60 | * decompress it. |
michael@0 | 61 | */ |
michael@0 | 62 | const unsigned long PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION = 16384; |
michael@0 | 63 | /** |
michael@0 | 64 | * Append the downloaded data to the target file. |
michael@0 | 65 | * This can only be used when persisting to a local file. |
michael@0 | 66 | */ |
michael@0 | 67 | const unsigned long PERSIST_FLAGS_APPEND_TO_FILE = 32768; |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * Force relevant cookies to be sent with this load even if normally they |
michael@0 | 71 | * wouldn't be. |
michael@0 | 72 | */ |
michael@0 | 73 | const unsigned long PERSIST_FLAGS_FORCE_ALLOW_COOKIES = 65536; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Flags governing how data is fetched and saved from the network. |
michael@0 | 77 | * It is best to set this value explicitly unless you are prepared |
michael@0 | 78 | * to accept the default values. |
michael@0 | 79 | */ |
michael@0 | 80 | attribute unsigned long persistFlags; |
michael@0 | 81 | |
michael@0 | 82 | /** Persister is ready to save data */ |
michael@0 | 83 | const unsigned long PERSIST_STATE_READY = 1; |
michael@0 | 84 | /** Persister is saving data */ |
michael@0 | 85 | const unsigned long PERSIST_STATE_SAVING = 2; |
michael@0 | 86 | /** Persister has finished saving data */ |
michael@0 | 87 | const unsigned long PERSIST_STATE_FINISHED = 3; |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Current state of the persister object. |
michael@0 | 91 | */ |
michael@0 | 92 | readonly attribute unsigned long currentState; |
michael@0 | 93 | |
michael@0 | 94 | /** |
michael@0 | 95 | * Value indicating the success or failure of the persist |
michael@0 | 96 | * operation. |
michael@0 | 97 | * |
michael@0 | 98 | * @throws NS_BINDING_ABORTED Operation cancelled. |
michael@0 | 99 | * @throws NS_ERROR_FAILURE Non-specific failure. |
michael@0 | 100 | */ |
michael@0 | 101 | readonly attribute nsresult result; |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * Callback listener for progress notifications. The object that the |
michael@0 | 105 | * embbedder supplies may also implement nsIInterfaceRequestor and be |
michael@0 | 106 | * prepared to return nsIAuthPrompt or other interfaces that may be required |
michael@0 | 107 | * to download data. |
michael@0 | 108 | * |
michael@0 | 109 | * @see nsIAuthPrompt |
michael@0 | 110 | * @see nsIInterfaceRequestor |
michael@0 | 111 | */ |
michael@0 | 112 | attribute nsIWebProgressListener progressListener; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Save the specified URI to file. |
michael@0 | 116 | * |
michael@0 | 117 | * @param aURI URI to save to file. Some implementations of this interface |
michael@0 | 118 | * may also support <CODE>nullptr</CODE> to imply the currently |
michael@0 | 119 | * loaded URI. |
michael@0 | 120 | * @param aCacheKey An object representing the URI in the cache or |
michael@0 | 121 | * <CODE>nullptr</CODE>. This can be a necko cache key, |
michael@0 | 122 | * an nsIWebPageDescriptor, or the currentDescriptor of an |
michael@0 | 123 | * nsIWebPageDescriptor. |
michael@0 | 124 | * @param aReferrer The referrer URI to pass with an HTTP request or |
michael@0 | 125 | * <CODE>nullptr</CODE>. |
michael@0 | 126 | * @param aPostData Post data to pass with an HTTP request or |
michael@0 | 127 | * <CODE>nullptr</CODE>. |
michael@0 | 128 | * @param aExtraHeaders Additional headers to supply with an HTTP request |
michael@0 | 129 | * or <CODE>nullptr</CODE>. |
michael@0 | 130 | * @param aFile Target file. This may be a nsIFile object or an |
michael@0 | 131 | * nsIURI object with a file scheme or a scheme that |
michael@0 | 132 | * supports uploading (e.g. ftp). |
michael@0 | 133 | * @param aPrivacyContext A context from which the privacy status of this |
michael@0 | 134 | * save operation can be determined. Must only be null |
michael@0 | 135 | * in situations in which no such context is available |
michael@0 | 136 | * (eg. the operation has no logical association with any |
michael@0 | 137 | * window or document) |
michael@0 | 138 | * |
michael@0 | 139 | * @see nsIFile |
michael@0 | 140 | * @see nsIURI |
michael@0 | 141 | * @see nsIInputStream |
michael@0 | 142 | * |
michael@0 | 143 | * @throws NS_ERROR_INVALID_ARG One or more arguments was invalid. |
michael@0 | 144 | */ |
michael@0 | 145 | void saveURI(in nsIURI aURI, in nsISupports aCacheKey, |
michael@0 | 146 | in nsIURI aReferrer, in nsIInputStream aPostData, |
michael@0 | 147 | in string aExtraHeaders, in nsISupports aFile, |
michael@0 | 148 | in nsILoadContext aPrivacyContext); |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * @param aIsPrivate Treat the save operation as private (ie. with |
michael@0 | 152 | * regards to networking operations and persistence |
michael@0 | 153 | * of intermediate data, etc.) |
michael@0 | 154 | * @see saveURI for all other parameter descriptions |
michael@0 | 155 | */ |
michael@0 | 156 | void savePrivacyAwareURI(in nsIURI aURI, in nsISupports aCacheKey, |
michael@0 | 157 | in nsIURI aReferrer, in nsIInputStream aPostData, |
michael@0 | 158 | in string aExtraHeaders, in nsISupports aFile, |
michael@0 | 159 | in boolean aIsPrivate); |
michael@0 | 160 | |
michael@0 | 161 | /** |
michael@0 | 162 | * Save a channel to a file. It must not be opened yet. |
michael@0 | 163 | * @see saveURI |
michael@0 | 164 | */ |
michael@0 | 165 | void saveChannel(in nsIChannel aChannel, in nsISupports aFile); |
michael@0 | 166 | |
michael@0 | 167 | /** Output only the current selection as opposed to the whole document. */ |
michael@0 | 168 | const unsigned long ENCODE_FLAGS_SELECTION_ONLY = 1; |
michael@0 | 169 | /** |
michael@0 | 170 | * For plaintext output. Convert html to plaintext that looks like the html. |
michael@0 | 171 | * Implies wrap (except inside <pre>), since html wraps. |
michael@0 | 172 | * HTML output: always do prettyprinting, ignoring existing formatting. |
michael@0 | 173 | */ |
michael@0 | 174 | const unsigned long ENCODE_FLAGS_FORMATTED = 2; |
michael@0 | 175 | /** |
michael@0 | 176 | * Output without formatting or wrapping the content. This flag |
michael@0 | 177 | * may be used to preserve the original formatting as much as possible. |
michael@0 | 178 | */ |
michael@0 | 179 | const unsigned long ENCODE_FLAGS_RAW = 4; |
michael@0 | 180 | /** Output only the body section, no HTML tags. */ |
michael@0 | 181 | const unsigned long ENCODE_FLAGS_BODY_ONLY = 8; |
michael@0 | 182 | /** Wrap even if when not doing formatted output (e.g. for text fields). */ |
michael@0 | 183 | const unsigned long ENCODE_FLAGS_PREFORMATTED = 16; |
michael@0 | 184 | /** Wrap documents at the specified column. */ |
michael@0 | 185 | const unsigned long ENCODE_FLAGS_WRAP = 32; |
michael@0 | 186 | /** |
michael@0 | 187 | * For plaintext output. Output for format flowed (RFC 2646). This is used |
michael@0 | 188 | * when converting to text for mail sending. This differs just slightly |
michael@0 | 189 | * but in an important way from normal formatted, and that is that |
michael@0 | 190 | * lines are space stuffed. This can't (correctly) be done later. |
michael@0 | 191 | */ |
michael@0 | 192 | const unsigned long ENCODE_FLAGS_FORMAT_FLOWED = 64; |
michael@0 | 193 | /** Convert links to absolute links where possible. */ |
michael@0 | 194 | const unsigned long ENCODE_FLAGS_ABSOLUTE_LINKS = 128; |
michael@0 | 195 | |
michael@0 | 196 | /** |
michael@0 | 197 | * Attempt to encode entities standardized at W3C (HTML, MathML, etc). |
michael@0 | 198 | * This is a catch-all flag for documents with mixed contents. Beware of |
michael@0 | 199 | * interoperability issues. See below for other flags which might likely |
michael@0 | 200 | * do what you want. |
michael@0 | 201 | */ |
michael@0 | 202 | const unsigned long ENCODE_FLAGS_ENCODE_W3C_ENTITIES = 256; |
michael@0 | 203 | |
michael@0 | 204 | /** |
michael@0 | 205 | * Output with carriage return line breaks. May also be combined with |
michael@0 | 206 | * ENCODE_FLAGS_LF_LINEBREAKS and if neither is specified, the platform |
michael@0 | 207 | * default format is used. |
michael@0 | 208 | */ |
michael@0 | 209 | const unsigned long ENCODE_FLAGS_CR_LINEBREAKS = 512; |
michael@0 | 210 | /** |
michael@0 | 211 | * Output with linefeed line breaks. May also be combined with |
michael@0 | 212 | * ENCODE_FLAGS_CR_LINEBREAKS and if neither is specified, the platform |
michael@0 | 213 | * default format is used. |
michael@0 | 214 | */ |
michael@0 | 215 | const unsigned long ENCODE_FLAGS_LF_LINEBREAKS = 1024; |
michael@0 | 216 | /** For plaintext output. Output the content of noscript elements. */ |
michael@0 | 217 | const unsigned long ENCODE_FLAGS_NOSCRIPT_CONTENT = 2048; |
michael@0 | 218 | /** For plaintext output. Output the content of noframes elements. */ |
michael@0 | 219 | const unsigned long ENCODE_FLAGS_NOFRAMES_CONTENT = 4096; |
michael@0 | 220 | |
michael@0 | 221 | /** |
michael@0 | 222 | * Encode basic entities, e.g. output instead of character code 0xa0. |
michael@0 | 223 | * The basic set is just & < > " for interoperability |
michael@0 | 224 | * with older products that don't support α and friends. |
michael@0 | 225 | */ |
michael@0 | 226 | const unsigned long ENCODE_FLAGS_ENCODE_BASIC_ENTITIES = 8192; |
michael@0 | 227 | /** |
michael@0 | 228 | * Encode Latin1 entities. This includes the basic set and |
michael@0 | 229 | * accented letters between 128 and 255. |
michael@0 | 230 | */ |
michael@0 | 231 | const unsigned long ENCODE_FLAGS_ENCODE_LATIN1_ENTITIES = 16384; |
michael@0 | 232 | /** |
michael@0 | 233 | * Encode HTML4 entities. This includes the basic set, accented |
michael@0 | 234 | * letters, greek letters and certain special markup symbols. |
michael@0 | 235 | */ |
michael@0 | 236 | const unsigned long ENCODE_FLAGS_ENCODE_HTML_ENTITIES = 32768; |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Save the specified DOM document to file and optionally all linked files |
michael@0 | 240 | * (e.g. images, CSS, JS & subframes). Do not call this method until the |
michael@0 | 241 | * document has finished loading! |
michael@0 | 242 | * |
michael@0 | 243 | * @param aDocument Document to save to file. Some implementations of |
michael@0 | 244 | * this interface may also support <CODE>nullptr</CODE> |
michael@0 | 245 | * to imply the currently loaded document. |
michael@0 | 246 | * @param aFile Target local file. This may be a nsIFile object or an |
michael@0 | 247 | * nsIURI object with a file scheme or a scheme that |
michael@0 | 248 | * supports uploading (e.g. ftp). |
michael@0 | 249 | * @param aDataPath Path to directory where URIs linked to the document |
michael@0 | 250 | * are saved or nullptr if no linked URIs should be saved. |
michael@0 | 251 | * This may be a nsIFile object or an nsIURI object |
michael@0 | 252 | * with a file scheme. |
michael@0 | 253 | * @param aOutputContentType The desired MIME type format to save the |
michael@0 | 254 | * document and all subdocuments into or nullptr to use |
michael@0 | 255 | * the default behaviour. |
michael@0 | 256 | * @param aEncodingFlags Flags to pass to the encoder. |
michael@0 | 257 | * @param aWrapColumn For text documents, indicates the desired width to |
michael@0 | 258 | * wrap text at. Parameter is ignored if wrapping is not |
michael@0 | 259 | * specified by the encoding flags. |
michael@0 | 260 | * |
michael@0 | 261 | * @see nsIFile |
michael@0 | 262 | * @see nsIURI |
michael@0 | 263 | * |
michael@0 | 264 | * @throws NS_ERROR_INVALID_ARG One or more arguments was invalid. |
michael@0 | 265 | */ |
michael@0 | 266 | void saveDocument(in nsIDOMDocument aDocument, |
michael@0 | 267 | in nsISupports aFile, in nsISupports aDataPath, |
michael@0 | 268 | in string aOutputContentType, in unsigned long aEncodingFlags, |
michael@0 | 269 | in unsigned long aWrapColumn); |
michael@0 | 270 | |
michael@0 | 271 | /** |
michael@0 | 272 | * Cancels the current operation. The caller is responsible for cleaning up |
michael@0 | 273 | * partially written files or directories. This has the same effect as calling |
michael@0 | 274 | * cancel with an argument of NS_BINDING_ABORTED. |
michael@0 | 275 | */ |
michael@0 | 276 | void cancelSave(); |
michael@0 | 277 | }; |