1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
8 interface nsIInputStream
;
11 interface nsIPrincipal
;
12 interface nsIChildSHistory
;
16 #include
"mozilla/dom/ChildSHistory.h"
20 * The nsIWebNavigation interface defines an interface for navigating the web.
21 * It provides methods and attributes to direct an object to navigate to a new
22 * location, stop or restart an in process load, or determine where the object
23 * has previously gone.
25 [scriptable
, uuid(3ade79d4
-8cb9
-4952-b18d
-4f9b63ca0d31
)]
26 interface nsIWebNavigation
: nsISupports
29 * Indicates if the object can go back. If true this indicates that
30 * there is back session history available for navigation.
32 readonly attribute
boolean canGoBack
;
35 * Indicates if the object can go forward. If true this indicates that
36 * there is forward session history available for navigation
38 readonly attribute
boolean canGoForward
;
41 * Tells the object to navigate to the previous session history item. When a
42 * page is loaded from session history, all content is loaded from the cache
43 * (if available) and page state (such as form values and scroll position) is
46 * @throw NS_ERROR_UNEXPECTED
47 * Indicates that the call was unexpected at this time, which implies
48 * that canGoBack is false.
53 * Tells the object to navigate to the next session history item. When a
54 * page is loaded from session history, all content is loaded from the cache
55 * (if available) and page state (such as form values and scroll position) is
58 * @throw NS_ERROR_UNEXPECTED
59 * Indicates that the call was unexpected at this time, which implies
60 * that canGoForward is false.
65 * Tells the object to navigate to the session history item at a given index.
67 * @throw NS_ERROR_UNEXPECTED
68 * Indicates that the call was unexpected at this time, which implies
69 * that session history entry at the given index does not exist.
71 void gotoIndex
(in long index
);
73 /****************************************************************************
74 * The following flags may be bitwise combined to form the load flags
75 * parameter passed to either the loadURI or reload method. Some of these
76 * flags are only applicable to loadURI.
80 * This flags defines the range of bits that may be specified. Flags
81 * outside this range may be used, but may not be passed to Reload().
83 const unsigned long LOAD_FLAGS_MASK
= 0xffff;
86 * This is the default value for the load flags parameter.
88 const unsigned long LOAD_FLAGS_NONE
= 0x0000;
91 * Flags 0x1, 0x2, 0x4, 0x8 are reserved for internal use by
92 * nsIWebNavigation implementations for now.
96 * This flag specifies that the load should have the semantics of an HTML
97 * Meta-refresh tag (i.e., that the cache should be bypassed). This flag
98 * is only applicable to loadURI.
99 * XXX the meaning of this flag is poorly defined.
100 * XXX no one uses this, so we should probably deprecate and remove it.
102 const unsigned long LOAD_FLAGS_IS_REFRESH
= 0x0010;
105 * This flag specifies that the load should have the semantics of a link
106 * click. This flag is only applicable to loadURI.
107 * XXX the meaning of this flag is poorly defined.
109 const unsigned long LOAD_FLAGS_IS_LINK
= 0x0020;
112 * This flag specifies that history should not be updated. This flag is only
113 * applicable to loadURI.
115 const unsigned long LOAD_FLAGS_BYPASS_HISTORY
= 0x0040;
118 * This flag specifies that any existing history entry should be replaced.
119 * This flag is only applicable to loadURI.
121 const unsigned long LOAD_FLAGS_REPLACE_HISTORY
= 0x0080;
124 * This flag specifies that the local web cache should be bypassed, but an
125 * intermediate proxy cache could still be used to satisfy the load.
127 const unsigned long LOAD_FLAGS_BYPASS_CACHE
= 0x0100;
130 * This flag specifies that any intermediate proxy caches should be bypassed
131 * (i.e., that the content should be loaded from the origin server).
133 const unsigned long LOAD_FLAGS_BYPASS_PROXY
= 0x0200;
136 * This flag specifies that a reload was triggered as a result of detecting
137 * an incorrect character encoding while parsing a previously loaded
140 const unsigned long LOAD_FLAGS_CHARSET_CHANGE
= 0x0400;
143 * If this flag is set, Stop() will be called before the load starts
144 * and will stop both content and network activity (the default is to
145 * only stop network activity). Effectively, this passes the
146 * STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
148 const unsigned long LOAD_FLAGS_STOP_CONTENT
= 0x0800;
151 * A hint this load was prompted by an external program: take care!
153 const unsigned long LOAD_FLAGS_FROM_EXTERNAL
= 0x1000;
156 This flag is set when a user explicitly disables the Mixed Content
157 Blocker, and allows Mixed Content to load on an https page.
159 const unsigned long LOAD_FLAGS_ALLOW_MIXED_CONTENT
= 0x2000;
162 * This flag specifies that this is the first load in this object.
163 * Set with care, since setting incorrectly can cause us to assume that
164 * nothing was actually loaded in this object if the load ends up being
165 * handled by an external application. This flag must not be passed to
168 const unsigned long LOAD_FLAGS_FIRST_LOAD
= 0x4000;
171 * This flag specifies that the load should not be subject to popup
172 * blocking checks. This flag must not be passed to Reload.
174 const unsigned long LOAD_FLAGS_ALLOW_POPUPS
= 0x8000;
177 * This flag specifies that the URI classifier should not be checked for
178 * this load. This flag must not be passed to Reload.
180 const unsigned long LOAD_FLAGS_BYPASS_CLASSIFIER
= 0x10000;
183 * Force relevant cookies to be sent with this load even if normally they
186 const unsigned long LOAD_FLAGS_FORCE_ALLOW_COOKIES
= 0x20000;
189 * Prevent the owner principal from being inherited for this load.
190 * Note: Within Gecko we use the term principal rather than owners
191 * but some legacy addons might still rely on the outdated term.
193 const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL
= 0x40000;
194 const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_OWNER
= 0x40000;
197 * Overwrite the returned error code with a specific result code
198 * when an error page is displayed.
200 const unsigned long LOAD_FLAGS_ERROR_LOAD_CHANGES_RV
= 0x80000;
203 * This flag specifies that the URI may be submitted to a third-party
204 * server for correction. This should only be applied to non-sensitive
205 * URIs entered by users. This flag must not be passed to Reload.
207 const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP
= 0x100000;
210 * This flag specifies that common scheme typos should be corrected.
212 const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS
= 0x200000;
215 * Allows a top-level data: navigation to occur. E.g. view-image
216 * is an explicit user action which should be allowed.
218 const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI
= 0x400000;
221 * Loads a given URI. This will give priority to loading the requested URI
222 * in the object implementing this interface. If it can't be loaded here
223 * however, the URI dispatcher will go through its normal process of content
227 * The URI string to load. For HTTP and FTP URLs and possibly others,
228 * characters above U+007F will be converted to UTF-8 and then URL-
229 * escaped per the rules of RFC 2396.
231 * Flags modifying load behaviour. This parameter is a bitwise
232 * combination of the load flags defined above. (Undefined bits are
233 * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
234 * for this parameter.
236 * The referring URI. If this argument is null, then the referring
237 * URI will be inferred internally.
239 * If the URI corresponds to a HTTP request, then this stream is
240 * appended directly to the HTTP request headers. It may be prefixed
241 * with additional HTTP headers. This stream must contain a "\r\n"
242 * sequence separating any HTTP headers from the HTTP request body.
243 * This parameter is optional and may be null.
245 * If the URI corresponds to a HTTP request, then any HTTP headers
246 * contained in this stream are set on the HTTP request. The HTTP
247 * header stream is formatted as:
249 * This parameter is optional and may be null.
250 * @param aTriggeringPrincipal
251 * The principal that initiated the load of aURI. If omitted docShell
252 * tries to create a codeBasePrincipal from aReferrer if not null. If
253 * aReferrer is also null docShell peforms a load using the
254 * SystemPrincipal as the triggeringPrincipal.
256 void loadURI
(in wstring aURI
,
257 in unsigned long aLoadFlags
,
259 in nsIInputStream aPostData
,
260 in nsIInputStream aHeaders
,
261 [optional] in nsIPrincipal aTriggeringPrincipal
);
264 * Loads a given URI. This will give priority to loading the requested URI
265 * in the object implementing this interface. If it can't be loaded here
266 * however, the URI dispatcher will go through its normal process of content
269 * Behaves like loadURI, but allows passing of additional parameters.
272 * The URI string to load. For HTTP and FTP URLs and possibly others,
273 * characters above U+007F will be converted to UTF-8 and then URL-
274 * escaped per the rules of RFC 2396.
276 * Flags modifying load behaviour. This parameter is a bitwise
277 * combination of the load flags defined above. (Undefined bits are
278 * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
279 * for this parameter.
281 * The referring URI. If this argument is null, then the referring
282 * URI will be inferred internally.
283 * @param aReferrerPolicy
284 * One of the REFERRER_POLICY_* constants from nsIHttpChannel.
285 * Normal case is REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE.
287 * If the URI corresponds to a HTTP request, then this stream is
288 * appended directly to the HTTP request headers. It may be prefixed
289 * with additional HTTP headers. This stream must contain a "\r\n"
290 * sequence separating any HTTP headers from the HTTP request body.
291 * This parameter is optional and may be null.
293 * If the URI corresponds to a HTTP request, then any HTTP headers
294 * contained in this stream are set on the HTTP request. The HTTP
295 * header stream is formatted as:
297 * This parameter is optional and may be null.
299 * Set to indicate a base URI to be associated with the load. Note
300 * that at present this argument is only used with view-source aURIs
301 * and cannot be used to resolve aURI.
302 * This parameter is optional and may be null.
303 * @param aTriggeringPrincipal
304 * The principal that initiated the load of aURI. If omitted docShell
305 * tries to create a codeBasePrincipal from aReferrer if not null. If
306 * aReferrer is also null docShell peforms a load using the
307 * SystemPrincipal as the triggeringPrincipal.
309 void loadURIWithOptions
(in wstring aURI
,
310 in unsigned long aLoadFlags
,
312 in unsigned long aReferrerPolicy
,
313 in nsIInputStream aPostData
,
314 in nsIInputStream aHeaders
,
316 [optional] in nsIPrincipal aTriggeringPrincipal
);
319 * Tells the Object to reload the current page. There may be cases where the
320 * user will be asked to confirm the reload (for example, when it is
321 * determined that the request is non-idempotent).
323 * @param aReloadFlags
324 * Flags modifying load behaviour. This parameter is a bitwise
325 * combination of the Load Flags defined above. (Undefined bits are
326 * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
327 * for this parameter.
329 * @throw NS_BINDING_ABORTED
330 * Indicating that the user canceled the reload.
332 void reload
(in unsigned long aReloadFlags
);
334 /****************************************************************************
335 * The following flags may be passed as the stop flags parameter to the stop
336 * method defined on this interface.
340 * This flag specifies that all network activity should be stopped. This
341 * includes both active network loads and pending META-refreshes.
343 const unsigned long STOP_NETWORK
= 0x01;
346 * This flag specifies that all content activity should be stopped. This
347 * includes animated images, plugins and pending Javascript timeouts.
349 const unsigned long STOP_CONTENT
= 0x02;
352 * This flag specifies that all activity should be stopped.
354 const unsigned long STOP_ALL
= 0x03;
357 * Stops a load of a URI.
360 * This parameter is one of the stop flags defined above.
362 void stop
(in unsigned long aStopFlags
);
365 * Retrieves the current DOM document for the frame, or lazily creates a
366 * blank document if there is none. This attribute never returns null except
367 * for unexpected error situations.
369 readonly attribute Document document
;
372 * The currently loaded URI or null.
374 readonly attribute nsIURI currentURI
;
377 * The referring URI for the currently loaded URI or null.
379 readonly attribute nsIURI referringURI
;
382 * The session history object used by this web navigation instance. This
383 * object will be a mozilla::dom::ChildSHistory object, but is returned as
384 * nsISupports so it can be called from JS code.
386 [binaryname
(SessionHistoryXPCOM
)]
387 readonly attribute nsISupports sessionHistory
;
391 * Get the session history object used by this nsIWebNavigation instance.
392 * Use this method instead of the XPCOM method when getting the
393 * SessionHistory from C++ code.
395 already_AddRefed
<mozilla
::dom
::ChildSHistory
>
398 nsCOMPtr
<nsISupports
> history
;
399 GetSessionHistoryXPCOM
(getter_AddRefs
(history
));
400 return history.forget
()
401 .downcast
<mozilla
::dom
::ChildSHistory
>();
406 * Set an OriginAttributes dictionary in the docShell. This can be done only
407 * before loading any content.
409 void setOriginAttributesBeforeLoading
(in jsval originAttributes
);