summaryrefslogtreecommitdiffstats
path: root/docshell/base/nsIWebNavigation.idl
blob: 1800e7312ef6d3316f740b7af1c4b5d248250bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * 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/. */

#include "nsISupports.idl"

interface nsIInputStream;
interface nsISHistory;
interface nsIURI;
interface nsIPrincipal;
interface nsIChildSHistory;
webidl Document;

%{ C++
#include "mozilla/dom/ChildSHistory.h"
namespace mozilla {
namespace dom {
struct LoadURIOptions;
} // namespace dom
} // namespace mozilla
%}

[ref] native LoadURIOptionsRef(const mozilla::dom::LoadURIOptions);

/**
 * The nsIWebNavigation interface defines an interface for navigating the web.
 * It provides methods and attributes to direct an object to navigate to a new
 * location, stop or restart an in process load, or determine where the object
 * has previously gone.
 *
 * Even though this is builtinclass, most of the interface is also implemented
 * in RemoteWebNavigation, so if this interface changes, the implementation
 * there may also need to change.
 */
[scriptable, builtinclass, uuid(3ade79d4-8cb9-4952-b18d-4f9b63ca0d31)]
interface nsIWebNavigation : nsISupports
{
  /**
   * Indicates if the object can go back.  If true this indicates that
   * there is back session history available for navigation.
   */
  readonly attribute boolean canGoBack;

  /**
   * Indicates if the object can go forward.  If true this indicates that
   * there is forward session history available for navigation
   */
  readonly attribute boolean canGoForward;

  /**
   * Tells the object to navigate to the previous session history item.  When a
   * page is loaded from session history, all content is loaded from the cache
   * (if available) and page state (such as form values and scroll position) is
   * restored.
   *
   * @param {boolean} aRequireUserInteraction
   *        Tells goBack to skip history items that did not record any user
   *        interaction on their corresponding document while they were active.
   *        This means in case of multiple entries mapping to the same document,
   *        each entry has to have been flagged with user interaction separately.
   *        If no items have user interaction, the function will fall back
   *        to the first session history entry.
   *
   * @param {boolean} aUserActivation
   *        Tells goBack that the call was triggered by a user action (e.g.:
   *        The user clicked the back button).
   *
   * @throw NS_ERROR_UNEXPECTED
   *        Indicates that the call was unexpected at this time, which implies
   *        that canGoBack is false.
   */
  void goBack([optional] in boolean aRequireUserInteraction, [optional] in boolean aUserActivation);

  /**
   * Tells the object to navigate to the next session history item.  When a
   * page is loaded from session history, all content is loaded from the cache
   * (if available) and page state (such as form values and scroll position) is
   * restored.
   *
   * @param {boolean} aRequireUserInteraction
   *        Tells goForward to skip history items that did not record any user
   *        interaction on their corresponding document while they were active.
   *        This means in case of multiple entries mapping to the same document,
   *        each entry has to have been flagged with user interaction separately.
   *        If no items have user interaction, the function will fall back
   *        to the latest session history entry.
   *
   * @param {boolean} aUserActivation
   *        Tells goForward that the call was triggered by a user action (e.g.:
   *        The user clicked the forward button).
   *
   * @throw NS_ERROR_UNEXPECTED
   *        Indicates that the call was unexpected at this time, which implies
   *        that canGoForward is false.
   */
  void goForward([optional] in boolean aRequireUserInteraction, [optional] in boolean aUserActivation);

  /**
   * Tells the object to navigate to the session history item at a given index.
   *
   * @param {boolean} aUserActivation
   *        Tells goForward that the call was triggered by a user action (e.g.:
   *        The user clicked the forward button).
   *
   * @throw NS_ERROR_UNEXPECTED
   *        Indicates that the call was unexpected at this time, which implies
   *        that session history entry at the given index does not exist.
   */
  void gotoIndex(in long index, [optional] in boolean aUserActivation);

  /****************************************************************************
   * The following flags may be bitwise combined to form the load flags
   * parameter passed to either the loadURI or reload method.  Some of these
   * flags are only applicable to loadURI.
   */

  /**
   * This flags defines the range of bits that may be specified.  Flags
   * outside this range may be used, but may not be passed to Reload().
   */
  const unsigned long LOAD_FLAGS_MASK            = 0xffff;

  /**
   * This is the default value for the load flags parameter.
   */
  const unsigned long LOAD_FLAGS_NONE            = 0x0000;

  /**
   * Flags 0x1, 0x2, 0x4, 0x8 are reserved for internal use by
   * nsIWebNavigation implementations for now.
   */

  /**
   * This flag specifies that the load should have the semantics of an HTML
   * Meta-refresh tag (i.e., that the cache should be bypassed).  This flag
   * is only applicable to loadURI.
   * XXX the meaning of this flag is poorly defined.
   * XXX no one uses this, so we should probably deprecate and remove it.
   */
  const unsigned long LOAD_FLAGS_IS_REFRESH      = 0x0010;

  /**
   * This flag specifies that the load should have the semantics of a link
   * click.  This flag is only applicable to loadURI.
   * XXX the meaning of this flag is poorly defined.
   */
  const unsigned long LOAD_FLAGS_IS_LINK         = 0x0020;

  /**
   * This flag specifies that history should not be updated.  This flag is only
   * applicable to loadURI.
   */
  const unsigned long LOAD_FLAGS_BYPASS_HISTORY  = 0x0040;

  /**
   * This flag specifies that any existing history entry should be replaced.
   * This flag is only applicable to loadURI.
   */
  const unsigned long LOAD_FLAGS_REPLACE_HISTORY = 0x0080;

  /**
   * This flag specifies that the local web cache should be bypassed, but an
   * intermediate proxy cache could still be used to satisfy the load.
   */
  const unsigned long LOAD_FLAGS_BYPASS_CACHE    = 0x0100;

  /**
   * This flag specifies that any intermediate proxy caches should be bypassed
   * (i.e., that the content should be loaded from the origin server).
   */
  const unsigned long LOAD_FLAGS_BYPASS_PROXY    = 0x0200;

  /**
   * This flag specifies that a reload was triggered as a result of detecting
   * an incorrect character encoding while parsing a previously loaded
   * document.
   */
  const unsigned long LOAD_FLAGS_CHARSET_CHANGE  = 0x0400;

  /**
   * If this flag is set, Stop() will be called before the load starts
   * and will stop both content and network activity (the default is to
   * only stop network activity).  Effectively, this passes the
   * STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
   */
  const unsigned long LOAD_FLAGS_STOP_CONTENT    = 0x0800;

  /**
   * A hint this load was prompted by an external program: take care!
   */
  const unsigned long LOAD_FLAGS_FROM_EXTERNAL   = 0x1000;

  /**
   * This flag specifies that this is the first load in this object.
   * Set with care, since setting incorrectly can cause us to assume that
   * nothing was actually loaded in this object if the load ends up being
   * handled by an external application.  This flag must not be passed to
   * Reload.
   */
  const unsigned long LOAD_FLAGS_FIRST_LOAD = 0x4000;

  /**
   * This flag specifies that the load should not be subject to popup
   * blocking checks.  This flag must not be passed to Reload.
   */
  const unsigned long LOAD_FLAGS_ALLOW_POPUPS = 0x8000;

  /**
   * This flag specifies that the URI classifier should not be checked for
   * this load.  This flag must not be passed to Reload.
   */
  const unsigned long LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10000;

  /**
   * Force relevant cookies to be sent with this load even if normally they
   * wouldn't be.
   */
  const unsigned long LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20000;

  /**
   * Prevent the owner principal from being inherited for this load.
   */
  const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL = 0x40000;

  /**
   * Overwrite the returned error code with a specific result code
   * when an error page is displayed.
   */
  const unsigned long LOAD_FLAGS_ERROR_LOAD_CHANGES_RV = 0x80000;

  /**
   * This flag specifies that the URI may be submitted to a third-party
   * server for correction. This should only be applied to non-sensitive
   * URIs entered by users.  This flag must not be passed to Reload.
   */
  const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x100000;

  /**
   * This flag specifies that common scheme typos should be corrected.
   */
  const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS = 0x200000;

  /**
   * Allows a top-level data: navigation to occur. E.g. view-image
   * is an explicit user action which should be allowed.
   */
  const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;

  /**
   * This load is the result of an HTTP redirect.
   */
  const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;

  /**
   * These flags force TRR modes 1 or 3 for the load.
   */
  const unsigned long LOAD_FLAGS_DISABLE_TRR = 0x1000000;
  const unsigned long LOAD_FLAGS_FORCE_TRR = 0x2000000;

  /**
   * This load should bypass the LoadURIDelegate.loadUri.
   */
  const unsigned long LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE = 0x4000000;

  /**
   * This load has a user activation. (e.g: reload button was clicked)
   */
  const unsigned long LOAD_FLAGS_USER_ACTIVATION = 0x8000000;

  /**
   * Loads a given URI.  This will give priority to loading the requested URI
   * in the object implementing this interface.  If it can't be loaded here
   * however, the URI dispatcher will go through its normal process of content
   * loading.
   *
   * @param aURI
   *        The URI to load.
   * @param aLoadURIOptions
   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
   *        the triggeringPrincipal, the referrer info.
   */
  [implicit_jscontext, binaryname(LoadURIFromScript)]
  void loadURI(in nsIURI aURI,
               in jsval  aLoadURIOptions);

  /**
   * Parse / fix up a URI out of the string and load it.
   * This will give priority to loading the requested URI
   * in the object implementing this interface.  If it can't be loaded here
   * however, the URI dispatcher will go through its normal process of content
   * loading.
   *
   * @param aURIString
   *        The URI string to load.  For HTTP and FTP URLs and possibly others,
   *        characters above U+007F will be converted to UTF-8 and then URL-
   *        escaped per the rules of RFC 2396.
   *        This method may use nsIURIFixup to try to fix up typos etc. in the
   *        input string based on the load flag arguments in aLoadURIOptions.
   *        It can even convert the input to a search results page using the
   *        default search service.
   *        If you have an nsIURI anyway, prefer calling `loadURI`, above.
   * @param aLoadURIOptions
   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
   *        the triggeringPrincipal, the referrer info.
   */
  [implicit_jscontext, binaryname(FixupAndLoadURIStringFromScript)]
  void fixupAndLoadURIString(in AString aURIString,
                             in jsval   aLoadURIOptions);

  /**
   * A C++ friendly version of loadURI
   */
  [nostdcall, binaryname(LoadURI)]
  void binaryLoadURI(in nsIURI            aURI,
                     in LoadURIOptionsRef aLoadURIOptions);

  /**
   * A C++ friendly version of fixupAndLoadURIString
   */
  [nostdcall, binaryname(FixupAndLoadURIString)]
  void binaryFixupAndLoadURIString(in AString           aURIString,
                                   in LoadURIOptionsRef aLoadURIOptions);

  /**
   * Tells the Object to reload the current page.  There may be cases where the
   * user will be asked to confirm the reload (for example, when it is
   * determined that the request is non-idempotent).
   *
   * @param aReloadFlags
   *        Flags modifying load behaviour.  This parameter is a bitwise
   *        combination of the Load Flags defined above.  (Undefined bits are
   *        reserved for future use.)  Generally you will pass LOAD_FLAGS_NONE
   *        for this parameter.
   *
   * @throw NS_BINDING_ABORTED
   *        Indicating that the user canceled the reload.
   */
  void reload(in unsigned long aReloadFlags);

  /****************************************************************************
   * The following flags may be passed as the stop flags parameter to the stop
   * method defined on this interface.
   */

  /**
   * This flag specifies that all network activity should be stopped.  This
   * includes both active network loads and pending META-refreshes.
   */
  const unsigned long STOP_NETWORK = 0x01;

  /**
   * This flag specifies that all content activity should be stopped.  This
   * includes animated images, plugins and pending Javascript timeouts.
   */
  const unsigned long STOP_CONTENT = 0x02;

  /**
   * This flag specifies that all activity should be stopped.
   */
  const unsigned long STOP_ALL     = 0x03;

  /**
   * Stops a load of a URI.
   *
   * @param aStopFlags
   *        This parameter is one of the stop flags defined above.
   */
  void stop(in unsigned long aStopFlags);

  /**
   * Retrieves the current DOM document for the frame, or lazily creates a
   * blank document if there is none.  This attribute never returns null except
   * for unexpected error situations.
   */
  readonly attribute Document document;

  /**
   * The currently loaded URI or null.
   */
  readonly attribute nsIURI currentURI;

  /**
   * The session history object used by this web navigation instance. This
   * object will be a mozilla::dom::ChildSHistory object, but is returned as
   * nsISupports so it can be called from JS code.
   */
  [binaryname(SessionHistoryXPCOM)]
  readonly attribute nsISupports sessionHistory;

  %{ C++
  /**
   * Get the session history object used by this nsIWebNavigation instance.
   * Use this method instead of the XPCOM method when getting the
   * SessionHistory from C++ code.
   */
  already_AddRefed<mozilla::dom::ChildSHistory>
  GetSessionHistory()
  {
    nsCOMPtr<nsISupports> history;
    GetSessionHistoryXPCOM(getter_AddRefs(history));
    return history.forget()
      .downcast<mozilla::dom::ChildSHistory>();
  }
  %}

  /**
   * Resume a load which has been redirected from another process.
   *
   * A negative |aHistoryIndex| value corresponds to a non-history load being
   * resumed.
   */
  void resumeRedirectedLoad(in unsigned long long aLoadIdentifier,
                            in long aHistoryIndex);
};