2001-11-01 14:47:05 +03:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-11-01 14:47:05 +03:00
|
|
|
|
2005-04-10 16:37:36 +04:00
|
|
|
#include "nsICancelable.idl"
|
2020-01-23 11:36:00 +03:00
|
|
|
#include "nsIContentPolicy.idl"
|
2001-11-01 14:47:05 +03:00
|
|
|
|
|
|
|
interface nsIURI;
|
|
|
|
interface nsIInputStream;
|
|
|
|
interface nsIWebProgressListener;
|
2012-06-06 06:08:30 +04:00
|
|
|
interface nsIFile;
|
2004-09-07 18:42:23 +04:00
|
|
|
interface nsIChannel;
|
2012-10-04 23:07:51 +04:00
|
|
|
interface nsILoadContext;
|
2018-06-22 17:41:39 +03:00
|
|
|
interface nsIPrincipal;
|
2019-07-16 21:02:16 +03:00
|
|
|
interface nsIReferrerInfo;
|
2001-11-01 14:47:05 +03:00
|
|
|
|
|
|
|
/**
|
2003-01-09 02:53:10 +03:00
|
|
|
* Interface for persisting DOM documents and URIs to local or remote storage.
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
2015-08-06 00:25:39 +03:00
|
|
|
[scriptable, uuid(8cd752a4-60b1-42c3-a819-65c7a1138a28)]
|
2005-04-10 16:37:36 +04:00
|
|
|
interface nsIWebBrowserPersist : nsICancelable
|
2001-11-01 14:47:05 +03:00
|
|
|
{
|
|
|
|
/** No special persistence behaviour. */
|
|
|
|
const unsigned long PERSIST_FLAGS_NONE = 0;
|
2012-05-09 05:02:32 +04:00
|
|
|
/** Use cached data if present (skipping validation), else load from network */
|
2001-11-01 14:47:05 +03:00
|
|
|
const unsigned long PERSIST_FLAGS_FROM_CACHE = 1;
|
|
|
|
/** Bypass the cached data. */
|
|
|
|
const unsigned long PERSIST_FLAGS_BYPASS_CACHE = 2;
|
|
|
|
/** Ignore any redirected data (usually adverts). */
|
|
|
|
const unsigned long PERSIST_FLAGS_IGNORE_REDIRECTED_DATA = 4;
|
|
|
|
/** Ignore IFRAME content (usually adverts). */
|
|
|
|
const unsigned long PERSIST_FLAGS_IGNORE_IFRAMES = 8;
|
2001-11-07 02:43:39 +03:00
|
|
|
/** Do not run the incoming data through a content converter e.g. to decompress it */
|
|
|
|
const unsigned long PERSIST_FLAGS_NO_CONVERSION = 16;
|
2002-01-14 15:41:27 +03:00
|
|
|
/** Replace existing files on the disk (use with due diligence!) */
|
|
|
|
const unsigned long PERSIST_FLAGS_REPLACE_EXISTING_FILES = 32;
|
2002-02-28 17:09:07 +03:00
|
|
|
/** Don't modify or add base tags */
|
|
|
|
const unsigned long PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS = 64;
|
|
|
|
/** Make changes to original dom rather than cloning nodes */
|
|
|
|
const unsigned long PERSIST_FLAGS_FIXUP_ORIGINAL_DOM = 128;
|
2002-03-14 17:15:02 +03:00
|
|
|
/** Fix links relative to destination location (not origin) */
|
|
|
|
const unsigned long PERSIST_FLAGS_FIXUP_LINKS_TO_DESTINATION = 256;
|
2003-03-25 15:19:05 +03:00
|
|
|
/** Don't make any adjustments to links */
|
2002-03-21 17:17:31 +03:00
|
|
|
const unsigned long PERSIST_FLAGS_DONT_FIXUP_LINKS = 512;
|
2002-06-03 17:08:27 +04:00
|
|
|
/** Force serialization of output (one file at a time; not concurrent) */
|
|
|
|
const unsigned long PERSIST_FLAGS_SERIALIZE_OUTPUT = 1024;
|
2003-03-25 15:19:05 +03:00
|
|
|
/** Don't make any adjustments to filenames */
|
|
|
|
const unsigned long PERSIST_FLAGS_DONT_CHANGE_FILENAMES = 2048;
|
2003-05-16 22:08:43 +04:00
|
|
|
/** Fail on broken inline links */
|
|
|
|
const unsigned long PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS = 4096;
|
2003-05-30 15:42:25 +04:00
|
|
|
/**
|
|
|
|
* Automatically cleanup after a failed or cancelled operation, deleting all
|
|
|
|
* created files and directories. This flag does nothing for failed upload
|
|
|
|
* operations to remote servers.
|
|
|
|
*/
|
|
|
|
const unsigned long PERSIST_FLAGS_CLEANUP_ON_FAILURE = 8192;
|
2004-10-10 08:03:34 +04:00
|
|
|
/**
|
|
|
|
* Let the WebBrowserPersist decide whether the incoming data is encoded
|
|
|
|
* and whether it needs to go through a content converter e.g. to
|
|
|
|
* decompress it.
|
|
|
|
*/
|
|
|
|
const unsigned long PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION = 16384;
|
2007-07-13 21:31:10 +04:00
|
|
|
/**
|
|
|
|
* Append the downloaded data to the target file.
|
|
|
|
* This can only be used when persisting to a local file.
|
|
|
|
*/
|
|
|
|
const unsigned long PERSIST_FLAGS_APPEND_TO_FILE = 32768;
|
2003-05-30 15:42:25 +04:00
|
|
|
|
2003-01-09 02:53:10 +03:00
|
|
|
/**
|
2017-08-04 12:37:53 +03:00
|
|
|
* Flags governing how data is fetched and saved from the network.
|
2003-01-09 02:53:10 +03:00
|
|
|
* It is best to set this value explicitly unless you are prepared
|
|
|
|
* to accept the default values.
|
|
|
|
*/
|
2001-11-01 14:47:05 +03:00
|
|
|
attribute unsigned long persistFlags;
|
2017-08-04 12:37:53 +03:00
|
|
|
|
2001-11-01 14:47:05 +03:00
|
|
|
/** Persister is ready to save data */
|
|
|
|
const unsigned long PERSIST_STATE_READY = 1;
|
|
|
|
/** Persister is saving data */
|
|
|
|
const unsigned long PERSIST_STATE_SAVING = 2;
|
|
|
|
/** Persister has finished saving data */
|
|
|
|
const unsigned long PERSIST_STATE_FINISHED = 3;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current state of the persister object.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long currentState;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Value indicating the success or failure of the persist
|
|
|
|
* operation.
|
|
|
|
*
|
2013-05-16 16:26:55 +04:00
|
|
|
* @throws NS_BINDING_ABORTED Operation cancelled.
|
|
|
|
* @throws NS_ERROR_FAILURE Non-specific failure.
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
2012-08-06 16:02:31 +04:00
|
|
|
readonly attribute nsresult result;
|
2001-11-01 14:47:05 +03:00
|
|
|
|
|
|
|
/**
|
2002-01-14 16:32:31 +03:00
|
|
|
* Callback listener for progress notifications. The object that the
|
|
|
|
* embbedder supplies may also implement nsIInterfaceRequestor and be
|
|
|
|
* prepared to return nsIAuthPrompt or other interfaces that may be required
|
|
|
|
* to download data.
|
|
|
|
*
|
|
|
|
* @see nsIAuthPrompt
|
|
|
|
* @see nsIInterfaceRequestor
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
|
|
|
attribute nsIWebProgressListener progressListener;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the specified URI to file.
|
|
|
|
*
|
2002-01-14 15:41:27 +03:00
|
|
|
* @param aURI URI to save to file. Some implementations of this interface
|
2012-07-30 18:20:58 +04:00
|
|
|
* may also support <CODE>nullptr</CODE> to imply the currently
|
2002-01-14 15:41:27 +03:00
|
|
|
* loaded URI.
|
2018-06-22 17:41:39 +03:00
|
|
|
* @param aTriggeringPrincipal
|
|
|
|
* The triggering principal for the URI we're saving.
|
2018-03-06 06:19:42 +03:00
|
|
|
* @param aCacheKey The necko cache key integer.
|
2019-07-16 21:02:16 +03:00
|
|
|
* @param aReferrerInfo The referrer info for compute and send referrer via
|
|
|
|
* HTTP Referer header.
|
2003-01-09 02:53:10 +03:00
|
|
|
* @param aPostData Post data to pass with an HTTP request or
|
2012-07-30 18:20:58 +04:00
|
|
|
* <CODE>nullptr</CODE>.
|
2003-01-09 02:53:10 +03:00
|
|
|
* @param aExtraHeaders Additional headers to supply with an HTTP request
|
2012-07-30 18:20:58 +04:00
|
|
|
* or <CODE>nullptr</CODE>.
|
2012-06-06 06:08:30 +04:00
|
|
|
* @param aFile Target file. This may be a nsIFile object or an
|
2003-01-09 02:53:10 +03:00
|
|
|
* nsIURI object with a file scheme or a scheme that
|
|
|
|
* supports uploading (e.g. ftp).
|
2020-01-23 11:36:00 +03:00
|
|
|
* @param aContentPolicyType The type of content we're saving.
|
2012-10-04 23:07:51 +04:00
|
|
|
* @param aPrivacyContext A context from which the privacy status of this
|
|
|
|
* save operation can be determined. Must only be null
|
|
|
|
* in situations in which no such context is available
|
|
|
|
* (eg. the operation has no logical association with any
|
|
|
|
* window or document)
|
2002-01-14 16:32:31 +03:00
|
|
|
*
|
2012-06-06 06:08:30 +04:00
|
|
|
* @see nsIFile
|
2002-01-14 16:32:31 +03:00
|
|
|
* @see nsIURI
|
2003-01-09 02:53:10 +03:00
|
|
|
* @see nsIInputStream
|
2001-11-01 14:47:05 +03:00
|
|
|
*
|
2013-05-16 16:26:55 +04:00
|
|
|
* @throws NS_ERROR_INVALID_ARG One or more arguments was invalid.
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
2018-06-22 17:41:39 +03:00
|
|
|
void saveURI(in nsIURI aURI, in nsIPrincipal aTriggeringPrincipal,
|
|
|
|
in unsigned long aCacheKey,
|
2019-07-16 21:02:16 +03:00
|
|
|
in nsIReferrerInfo aReferrerInfo,
|
2014-11-18 16:47:14 +03:00
|
|
|
in nsIInputStream aPostData,
|
2012-10-04 23:07:51 +04:00
|
|
|
in string aExtraHeaders, in nsISupports aFile,
|
2020-01-23 11:36:00 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType,
|
2012-10-04 23:07:51 +04:00
|
|
|
in nsILoadContext aPrivacyContext);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aIsPrivate Treat the save operation as private (ie. with
|
|
|
|
* regards to networking operations and persistence
|
|
|
|
* of intermediate data, etc.)
|
|
|
|
* @see saveURI for all other parameter descriptions
|
|
|
|
*/
|
2018-06-22 17:41:39 +03:00
|
|
|
void savePrivacyAwareURI(in nsIURI aURI,
|
|
|
|
in nsIPrincipal aTriggeringPrincipal, in unsigned long aCacheKey,
|
2019-07-16 21:02:16 +03:00
|
|
|
in nsIReferrerInfo aReferrerInfo,
|
2014-11-18 16:47:14 +03:00
|
|
|
in nsIInputStream aPostData,
|
2012-10-04 23:07:51 +04:00
|
|
|
in string aExtraHeaders, in nsISupports aFile,
|
2020-01-23 11:36:00 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType,
|
2012-10-04 23:07:51 +04:00
|
|
|
in boolean aIsPrivate);
|
2002-01-14 15:41:27 +03:00
|
|
|
|
2004-09-07 18:42:23 +04:00
|
|
|
/**
|
|
|
|
* Save a channel to a file. It must not be opened yet.
|
|
|
|
* @see saveURI
|
|
|
|
*/
|
|
|
|
void saveChannel(in nsIChannel aChannel, in nsISupports aFile);
|
|
|
|
|
2002-01-14 15:41:27 +03:00
|
|
|
/** Output only the current selection as opposed to the whole document. */
|
|
|
|
const unsigned long ENCODE_FLAGS_SELECTION_ONLY = 1;
|
|
|
|
/**
|
|
|
|
* For plaintext output. Convert html to plaintext that looks like the html.
|
|
|
|
* Implies wrap (except inside <pre>), since html wraps.
|
|
|
|
* HTML output: always do prettyprinting, ignoring existing formatting.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_FORMATTED = 2;
|
|
|
|
/**
|
|
|
|
* Output without formatting or wrapping the content. This flag
|
|
|
|
* may be used to preserve the original formatting as much as possible.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_RAW = 4;
|
|
|
|
/** Output only the body section, no HTML tags. */
|
|
|
|
const unsigned long ENCODE_FLAGS_BODY_ONLY = 8;
|
|
|
|
/** Wrap even if when not doing formatted output (e.g. for text fields). */
|
|
|
|
const unsigned long ENCODE_FLAGS_PREFORMATTED = 16;
|
|
|
|
/** Wrap documents at the specified column. */
|
|
|
|
const unsigned long ENCODE_FLAGS_WRAP = 32;
|
|
|
|
/**
|
|
|
|
* For plaintext output. Output for format flowed (RFC 2646). This is used
|
|
|
|
* when converting to text for mail sending. This differs just slightly
|
|
|
|
* but in an important way from normal formatted, and that is that
|
|
|
|
* lines are space stuffed. This can't (correctly) be done later.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_FORMAT_FLOWED = 64;
|
|
|
|
/** Convert links to absolute links where possible. */
|
|
|
|
const unsigned long ENCODE_FLAGS_ABSOLUTE_LINKS = 128;
|
2002-12-14 01:12:10 +03:00
|
|
|
|
2002-01-14 15:41:27 +03:00
|
|
|
/**
|
|
|
|
* Output with carriage return line breaks. May also be combined with
|
|
|
|
* ENCODE_FLAGS_LF_LINEBREAKS and if neither is specified, the platform
|
|
|
|
* default format is used.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_CR_LINEBREAKS = 512;
|
|
|
|
/**
|
|
|
|
* Output with linefeed line breaks. May also be combined with
|
|
|
|
* ENCODE_FLAGS_CR_LINEBREAKS and if neither is specified, the platform
|
|
|
|
* default format is used.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_LF_LINEBREAKS = 1024;
|
|
|
|
/** For plaintext output. Output the content of noscript elements. */
|
|
|
|
const unsigned long ENCODE_FLAGS_NOSCRIPT_CONTENT = 2048;
|
|
|
|
/** For plaintext output. Output the content of noframes elements. */
|
|
|
|
const unsigned long ENCODE_FLAGS_NOFRAMES_CONTENT = 4096;
|
2001-11-01 14:47:05 +03:00
|
|
|
|
2002-12-14 01:12:10 +03:00
|
|
|
/**
|
2017-08-04 12:37:53 +03:00
|
|
|
* Encode basic entities, e.g. output instead of character code 0xa0.
|
2002-12-14 01:12:10 +03:00
|
|
|
* The basic set is just & < > " for interoperability
|
|
|
|
* with older products that don't support α and friends.
|
|
|
|
*/
|
|
|
|
const unsigned long ENCODE_FLAGS_ENCODE_BASIC_ENTITIES = 8192;
|
|
|
|
|
2001-11-01 14:47:05 +03:00
|
|
|
/**
|
|
|
|
* Save the specified DOM document to file and optionally all linked files
|
|
|
|
* (e.g. images, CSS, JS & subframes). Do not call this method until the
|
|
|
|
* document has finished loading!
|
|
|
|
*
|
2002-01-14 15:41:27 +03:00
|
|
|
* @param aDocument Document to save to file. Some implementations of
|
2012-07-30 18:20:58 +04:00
|
|
|
* this interface may also support <CODE>nullptr</CODE>
|
2015-08-06 00:25:39 +03:00
|
|
|
* to imply the currently loaded document. Can be an
|
2018-05-11 20:46:15 +03:00
|
|
|
* nsIWebBrowserPersistDocument or Document.
|
2012-06-06 06:08:30 +04:00
|
|
|
* @param aFile Target local file. This may be a nsIFile object or an
|
2003-01-09 02:53:10 +03:00
|
|
|
* nsIURI object with a file scheme or a scheme that
|
|
|
|
* supports uploading (e.g. ftp).
|
2002-01-14 16:32:31 +03:00
|
|
|
* @param aDataPath Path to directory where URIs linked to the document
|
2012-07-30 18:20:58 +04:00
|
|
|
* are saved or nullptr if no linked URIs should be saved.
|
2012-06-06 06:08:30 +04:00
|
|
|
* This may be a nsIFile object or an nsIURI object
|
2002-01-14 16:32:31 +03:00
|
|
|
* with a file scheme.
|
2017-08-04 12:37:53 +03:00
|
|
|
* @param aOutputContentType The desired MIME type format to save the
|
2012-07-30 18:20:58 +04:00
|
|
|
* document and all subdocuments into or nullptr to use
|
2002-01-14 15:41:27 +03:00
|
|
|
* the default behaviour.
|
|
|
|
* @param aEncodingFlags Flags to pass to the encoder.
|
|
|
|
* @param aWrapColumn For text documents, indicates the desired width to
|
|
|
|
* wrap text at. Parameter is ignored if wrapping is not
|
|
|
|
* specified by the encoding flags.
|
|
|
|
*
|
2015-08-06 00:25:39 +03:00
|
|
|
* @see nsIWebBrowserPersistDocument
|
2018-04-09 23:30:33 +03:00
|
|
|
* @see WebBrowserPersistable
|
2012-06-06 06:08:30 +04:00
|
|
|
* @see nsIFile
|
2002-01-14 16:32:31 +03:00
|
|
|
* @see nsIURI
|
2001-11-01 14:47:05 +03:00
|
|
|
*
|
2013-05-16 16:26:55 +04:00
|
|
|
* @throws NS_ERROR_INVALID_ARG One or more arguments was invalid.
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
2015-08-06 00:25:39 +03:00
|
|
|
void saveDocument(in nsISupports aDocument,
|
2002-01-14 15:41:27 +03:00
|
|
|
in nsISupports aFile, in nsISupports aDataPath,
|
|
|
|
in string aOutputContentType, in unsigned long aEncodingFlags,
|
|
|
|
in unsigned long aWrapColumn);
|
2001-11-01 14:47:05 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels the current operation. The caller is responsible for cleaning up
|
2005-04-10 16:37:36 +04:00
|
|
|
* partially written files or directories. This has the same effect as calling
|
|
|
|
* cancel with an argument of NS_BINDING_ABORTED.
|
2001-11-01 14:47:05 +03:00
|
|
|
*/
|
|
|
|
void cancelSave();
|
|
|
|
};
|
2018-08-07 04:10:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We don't export nsWebBrowserPersist.h as a public header, so we need a place
|
|
|
|
* to put the CID/ContractID. All places uses the WebBrowserPersist include
|
|
|
|
* nsIWebBrowserPersist.h, so we define our contract IDs here for now.
|
|
|
|
*/
|
|
|
|
%{ C++
|
|
|
|
// {7E677795-C582-4cd1-9E8D-8271B3474D2A}
|
|
|
|
#define NS_WEBBROWSERPERSIST_CID \
|
|
|
|
{ 0x7e677795, 0xc582, 0x4cd1, { 0x9e, 0x8d, 0x82, 0x71, 0xb3, 0x47, 0x4d, 0x2a } }
|
|
|
|
#define NS_WEBBROWSERPERSIST_CONTRACTID \
|
|
|
|
"@mozilla.org/embedding/browser/nsWebBrowserPersist;1"
|
|
|
|
%}
|