nsIWebNavigation.idl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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/. */
  5. #include "nsISupports.idl"
  6. interface nsIDOMDocument;
  7. interface nsIInputStream;
  8. interface nsISHistory;
  9. interface nsIURI;
  10. interface nsIPrincipal;
  11. /**
  12. * The nsIWebNavigation interface defines an interface for navigating the web.
  13. * It provides methods and attributes to direct an object to navigate to a new
  14. * location, stop or restart an in process load, or determine where the object
  15. * has previously gone.
  16. */
  17. [scriptable, uuid(3ade79d4-8cb9-4952-b18d-4f9b63ca0d31)]
  18. interface nsIWebNavigation : nsISupports
  19. {
  20. /**
  21. * Indicates if the object can go back. If true this indicates that
  22. * there is back session history available for navigation.
  23. */
  24. readonly attribute boolean canGoBack;
  25. /**
  26. * Indicates if the object can go forward. If true this indicates that
  27. * there is forward session history available for navigation
  28. */
  29. readonly attribute boolean canGoForward;
  30. /**
  31. * Tells the object to navigate to the previous session history item. When a
  32. * page is loaded from session history, all content is loaded from the cache
  33. * (if available) and page state (such as form values and scroll position) is
  34. * restored.
  35. *
  36. * @throw NS_ERROR_UNEXPECTED
  37. * Indicates that the call was unexpected at this time, which implies
  38. * that canGoBack is false.
  39. */
  40. void goBack();
  41. /**
  42. * Tells the object to navigate to the next session history item. When a
  43. * page is loaded from session history, all content is loaded from the cache
  44. * (if available) and page state (such as form values and scroll position) is
  45. * restored.
  46. *
  47. * @throw NS_ERROR_UNEXPECTED
  48. * Indicates that the call was unexpected at this time, which implies
  49. * that canGoForward is false.
  50. */
  51. void goForward();
  52. /**
  53. * Tells the object to navigate to the session history item at a given index.
  54. *
  55. * @throw NS_ERROR_UNEXPECTED
  56. * Indicates that the call was unexpected at this time, which implies
  57. * that session history entry at the given index does not exist.
  58. */
  59. void gotoIndex(in long index);
  60. /****************************************************************************
  61. * The following flags may be bitwise combined to form the load flags
  62. * parameter passed to either the loadURI or reload method. Some of these
  63. * flags are only applicable to loadURI.
  64. */
  65. /**
  66. * This flags defines the range of bits that may be specified. Flags
  67. * outside this range may be used, but may not be passed to Reload().
  68. */
  69. const unsigned long LOAD_FLAGS_MASK = 0xffff;
  70. /**
  71. * This is the default value for the load flags parameter.
  72. */
  73. const unsigned long LOAD_FLAGS_NONE = 0x0000;
  74. /**
  75. * Flags 0x1, 0x2, 0x4, 0x8 are reserved for internal use by
  76. * nsIWebNavigation implementations for now.
  77. */
  78. /**
  79. * This flag specifies that the load should have the semantics of an HTML
  80. * Meta-refresh tag (i.e., that the cache should be bypassed). This flag
  81. * is only applicable to loadURI.
  82. * XXX the meaning of this flag is poorly defined.
  83. * XXX no one uses this, so we should probably deprecate and remove it.
  84. */
  85. const unsigned long LOAD_FLAGS_IS_REFRESH = 0x0010;
  86. /**
  87. * This flag specifies that the load should have the semantics of a link
  88. * click. This flag is only applicable to loadURI.
  89. * XXX the meaning of this flag is poorly defined.
  90. */
  91. const unsigned long LOAD_FLAGS_IS_LINK = 0x0020;
  92. /**
  93. * This flag specifies that history should not be updated. This flag is only
  94. * applicable to loadURI.
  95. */
  96. const unsigned long LOAD_FLAGS_BYPASS_HISTORY = 0x0040;
  97. /**
  98. * This flag specifies that any existing history entry should be replaced.
  99. * This flag is only applicable to loadURI.
  100. */
  101. const unsigned long LOAD_FLAGS_REPLACE_HISTORY = 0x0080;
  102. /**
  103. * This flag specifies that the local web cache should be bypassed, but an
  104. * intermediate proxy cache could still be used to satisfy the load.
  105. */
  106. const unsigned long LOAD_FLAGS_BYPASS_CACHE = 0x0100;
  107. /**
  108. * This flag specifies that any intermediate proxy caches should be bypassed
  109. * (i.e., that the content should be loaded from the origin server).
  110. */
  111. const unsigned long LOAD_FLAGS_BYPASS_PROXY = 0x0200;
  112. /**
  113. * This flag specifies that a reload was triggered as a result of detecting
  114. * an incorrect character encoding while parsing a previously loaded
  115. * document.
  116. */
  117. const unsigned long LOAD_FLAGS_CHARSET_CHANGE = 0x0400;
  118. /**
  119. * If this flag is set, Stop() will be called before the load starts
  120. * and will stop both content and network activity (the default is to
  121. * only stop network activity). Effectively, this passes the
  122. * STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
  123. */
  124. const unsigned long LOAD_FLAGS_STOP_CONTENT = 0x0800;
  125. /**
  126. * A hint this load was prompted by an external program: take care!
  127. */
  128. const unsigned long LOAD_FLAGS_FROM_EXTERNAL = 0x1000;
  129. /**
  130. This flag is set when a user explicitly disables the Mixed Content
  131. Blocker, and allows Mixed Content to load on an https page.
  132. */
  133. const unsigned long LOAD_FLAGS_ALLOW_MIXED_CONTENT = 0x2000;
  134. /**
  135. * This flag specifies that this is the first load in this object.
  136. * Set with care, since setting incorrectly can cause us to assume that
  137. * nothing was actually loaded in this object if the load ends up being
  138. * handled by an external application. This flag must not be passed to
  139. * Reload.
  140. */
  141. const unsigned long LOAD_FLAGS_FIRST_LOAD = 0x4000;
  142. /**
  143. * This flag specifies that the load should not be subject to popup
  144. * blocking checks. This flag must not be passed to Reload.
  145. */
  146. const unsigned long LOAD_FLAGS_ALLOW_POPUPS = 0x8000;
  147. /**
  148. * This flag specifies that the URI classifier should not be checked for
  149. * this load. This flag must not be passed to Reload.
  150. */
  151. const unsigned long LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10000;
  152. /**
  153. * Force relevant cookies to be sent with this load even if normally they
  154. * wouldn't be.
  155. */
  156. const unsigned long LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20000;
  157. /**
  158. * Prevent the owner principal from being inherited for this load.
  159. * Note: Within Gecko we use the term principal rather than owners
  160. * but some legacy addons might still rely on the outdated term.
  161. */
  162. const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL = 0x40000;
  163. const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_OWNER = 0x40000;
  164. /**
  165. * Overwrite the returned error code with a specific result code
  166. * when an error page is displayed.
  167. */
  168. const unsigned long LOAD_FLAGS_ERROR_LOAD_CHANGES_RV = 0x80000;
  169. /**
  170. * This flag specifies that the URI may be submitted to a third-party
  171. * server for correction. This should only be applied to non-sensitive
  172. * URIs entered by users. This flag must not be passed to Reload.
  173. */
  174. const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x100000;
  175. /**
  176. * This flag specifies that common scheme typos should be corrected.
  177. */
  178. const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS = 0x200000;
  179. /**
  180. * Allows a top-level data: navigation to occur. E.g. view-image
  181. * is an explicit user action which should be allowed.
  182. */
  183. const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;
  184. /**
  185. * Loads a given URI. This will give priority to loading the requested URI
  186. * in the object implementing this interface. If it can't be loaded here
  187. * however, the URI dispatcher will go through its normal process of content
  188. * loading.
  189. *
  190. * @param aURI
  191. * The URI string to load. For HTTP and FTP URLs and possibly others,
  192. * characters above U+007F will be converted to UTF-8 and then URL-
  193. * escaped per the rules of RFC 2396.
  194. * @param aLoadFlags
  195. * Flags modifying load behaviour. This parameter is a bitwise
  196. * combination of the load flags defined above. (Undefined bits are
  197. * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
  198. * for this parameter.
  199. * @param aReferrer
  200. * The referring URI. If this argument is null, then the referring
  201. * URI will be inferred internally.
  202. * @param aPostData
  203. * If the URI corresponds to a HTTP request, then this stream is
  204. * appended directly to the HTTP request headers. It may be prefixed
  205. * with additional HTTP headers. This stream must contain a "\r\n"
  206. * sequence separating any HTTP headers from the HTTP request body.
  207. * This parameter is optional and may be null.
  208. * @param aHeaders
  209. * If the URI corresponds to a HTTP request, then any HTTP headers
  210. * contained in this stream are set on the HTTP request. The HTTP
  211. * header stream is formatted as:
  212. * ( HEADER "\r\n" )*
  213. * This parameter is optional and may be null.
  214. */
  215. void loadURI(in wstring aURI,
  216. in unsigned long aLoadFlags,
  217. in nsIURI aReferrer,
  218. in nsIInputStream aPostData,
  219. in nsIInputStream aHeaders);
  220. /**
  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
  224. * loading.
  225. *
  226. * Behaves like loadURI, but allows passing of additional parameters.
  227. *
  228. * @param aURI
  229. * The URI string to load. For HTTP and FTP URLs and possibly others,
  230. * characters above U+007F will be converted to UTF-8 and then URL-
  231. * escaped per the rules of RFC 2396.
  232. * @param aLoadFlags
  233. * Flags modifying load behaviour. This parameter is a bitwise
  234. * combination of the load flags defined above. (Undefined bits are
  235. * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
  236. * for this parameter.
  237. * @param aReferrer
  238. * The referring URI. If this argument is null, then the referring
  239. * URI will be inferred internally.
  240. * @param aReferrerPolicy
  241. * One of the REFERRER_POLICY_* constants from nsIHttpChannel.
  242. * Normal case is REFERRER_POLICY_DEFAULT.
  243. * @param aPostData
  244. * If the URI corresponds to a HTTP request, then this stream is
  245. * appended directly to the HTTP request headers. It may be prefixed
  246. * with additional HTTP headers. This stream must contain a "\r\n"
  247. * sequence separating any HTTP headers from the HTTP request body.
  248. * This parameter is optional and may be null.
  249. * @param aHeaders
  250. * If the URI corresponds to a HTTP request, then any HTTP headers
  251. * contained in this stream are set on the HTTP request. The HTTP
  252. * header stream is formatted as:
  253. * ( HEADER "\r\n" )*
  254. * This parameter is optional and may be null.
  255. * @param aBaseURI
  256. * Set to indicate a base URI to be associated with the load. Note
  257. * that at present this argument is only used with view-source aURIs
  258. * and cannot be used to resolve aURI.
  259. * This parameter is optional and may be null.
  260. * @param aTriggeringPrincipal
  261. * The principal that initiated the load of aURI. If omitted docShell
  262. * tries to create a codeBasePrincipal from aReferrer if not null. If
  263. * aReferrer is also null docShell peforms a load using the
  264. * SystemPrincipal as the triggeringPrincipal.
  265. */
  266. void loadURIWithOptions(in wstring aURI,
  267. in unsigned long aLoadFlags,
  268. in nsIURI aReferrer,
  269. in unsigned long aReferrerPolicy,
  270. in nsIInputStream aPostData,
  271. in nsIInputStream aHeaders,
  272. in nsIURI aBaseURI,
  273. [optional] in nsIPrincipal aTriggeringPrincipal);
  274. /**
  275. * Tells the Object to reload the current page. There may be cases where the
  276. * user will be asked to confirm the reload (for example, when it is
  277. * determined that the request is non-idempotent).
  278. *
  279. * @param aReloadFlags
  280. * Flags modifying load behaviour. This parameter is a bitwise
  281. * combination of the Load Flags defined above. (Undefined bits are
  282. * reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
  283. * for this parameter.
  284. *
  285. * @throw NS_BINDING_ABORTED
  286. * Indicating that the user canceled the reload.
  287. */
  288. void reload(in unsigned long aReloadFlags);
  289. /****************************************************************************
  290. * The following flags may be passed as the stop flags parameter to the stop
  291. * method defined on this interface.
  292. */
  293. /**
  294. * This flag specifies that all network activity should be stopped. This
  295. * includes both active network loads and pending META-refreshes.
  296. */
  297. const unsigned long STOP_NETWORK = 0x01;
  298. /**
  299. * This flag specifies that all content activity should be stopped. This
  300. * includes animated images, plugins and pending Javascript timeouts.
  301. */
  302. const unsigned long STOP_CONTENT = 0x02;
  303. /**
  304. * This flag specifies that all activity should be stopped.
  305. */
  306. const unsigned long STOP_ALL = 0x03;
  307. /**
  308. * Stops a load of a URI.
  309. *
  310. * @param aStopFlags
  311. * This parameter is one of the stop flags defined above.
  312. */
  313. void stop(in unsigned long aStopFlags);
  314. /**
  315. * Retrieves the current DOM document for the frame, or lazily creates a
  316. * blank document if there is none. This attribute never returns null except
  317. * for unexpected error situations.
  318. */
  319. readonly attribute nsIDOMDocument document;
  320. /**
  321. * The currently loaded URI or null.
  322. */
  323. readonly attribute nsIURI currentURI;
  324. /**
  325. * The referring URI for the currently loaded URI or null.
  326. */
  327. readonly attribute nsIURI referringURI;
  328. /**
  329. * The session history object used by this web navigation instance.
  330. */
  331. attribute nsISHistory sessionHistory;
  332. /**
  333. * Set an OriginAttributes dictionary in the docShell. This can be done only
  334. * before loading any content.
  335. */
  336. void setOriginAttributesBeforeLoading(in jsval originAttributes);
  337. };