tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsIWebNavigation.idl (15726B)


      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 
      6 #include "nsISupports.idl"
      7 
      8 interface nsIInputStream;
      9 interface nsISHistory;
     10 interface nsIURI;
     11 interface nsIPrincipal;
     12 interface nsIChildSHistory;
     13 webidl Document;
     14 
     15 %{ C++
     16 #include "mozilla/dom/ChildSHistory.h"
     17 namespace mozilla {
     18 namespace dom {
     19 struct LoadURIOptions;
     20 } // namespace dom
     21 } // namespace mozilla
     22 %}
     23 
     24 [ref] native LoadURIOptionsRef(const mozilla::dom::LoadURIOptions);
     25 
     26 /**
     27 * The nsIWebNavigation interface defines an interface for navigating the web.
     28 * It provides methods and attributes to direct an object to navigate to a new
     29 * location, stop or restart an in process load, or determine where the object
     30 * has previously gone.
     31 *
     32 * Even though this is builtinclass, most of the interface is also implemented
     33 * in RemoteWebNavigation, so if this interface changes, the implementation
     34 * there may also need to change.
     35 */
     36 [scriptable, builtinclass, uuid(3ade79d4-8cb9-4952-b18d-4f9b63ca0d31)]
     37 interface nsIWebNavigation : nsISupports
     38 {
     39  /**
     40   * Indicates if the object can go back.  If true this indicates that
     41   * there is back session history available for navigation.
     42   */
     43  readonly attribute boolean canGoBack;
     44 
     45  /**
     46   * Indicates if the object can go back.  If true this indicates that
     47   * there is back session history available for navigation, ignoring
     48   * whether or not the history has been interacted with by the user.
     49   */
     50  readonly attribute boolean canGoBackIgnoringUserInteraction;
     51 
     52  /**
     53   * Indicates if the object can go forward.  If true this indicates that
     54   * there is forward session history available for navigation
     55   */
     56  readonly attribute boolean canGoForward;
     57 
     58  /**
     59   * Tells the object to navigate to the previous session history item.  When a
     60   * page is loaded from session history, all content is loaded from the cache
     61   * (if available) and page state (such as form values and scroll position) is
     62   * restored.
     63   *
     64   * @param {boolean} aRequireUserInteraction
     65   *        Tells goBack to skip history items that did not record any user
     66   *        interaction on their corresponding document while they were active.
     67   *        This means in case of multiple entries mapping to the same document,
     68   *        each entry has to have been flagged with user interaction separately.
     69   *        If no items have user interaction, the function will fall back
     70   *        to the first session history entry.
     71   *
     72   * @param {boolean} aUserActivation
     73   *        Tells goBack that the call was triggered by a user action (e.g.:
     74   *        The user clicked the back button).
     75   *
     76   * @throw NS_ERROR_UNEXPECTED
     77   *        Indicates that the call was unexpected at this time, which implies
     78   *        that canGoBack is false.
     79   */
     80  [can_run_script]
     81  void goBack([optional] in boolean aRequireUserInteraction, [optional] in boolean aUserActivation);
     82 
     83  /**
     84   * Tells the object to navigate to the next session history item.  When a
     85   * page is loaded from session history, all content is loaded from the cache
     86   * (if available) and page state (such as form values and scroll position) is
     87   * restored.
     88   *
     89   * @param {boolean} aRequireUserInteraction
     90   *        Tells goForward to skip history items that did not record any user
     91   *        interaction on their corresponding document while they were active.
     92   *        This means in case of multiple entries mapping to the same document,
     93   *        each entry has to have been flagged with user interaction separately.
     94   *        If no items have user interaction, the function will fall back
     95   *        to the latest session history entry.
     96   *
     97   * @param {boolean} aUserActivation
     98   *        Tells goForward that the call was triggered by a user action (e.g.:
     99   *        The user clicked the forward button).
    100   *
    101   * @throw NS_ERROR_UNEXPECTED
    102   *        Indicates that the call was unexpected at this time, which implies
    103   *        that canGoForward is false.
    104   */
    105  [can_run_script]
    106  void goForward([optional] in boolean aRequireUserInteraction, [optional] in boolean aUserActivation);
    107 
    108  /**
    109   * Tells the object to navigate to the session history item at a given index.
    110   *
    111   * @param {boolean} aUserActivation
    112   *        Tells goForward that the call was triggered by a user action (e.g.:
    113   *        The user clicked the forward button).
    114   *
    115   * @throw NS_ERROR_UNEXPECTED
    116   *        Indicates that the call was unexpected at this time, which implies
    117   *        that session history entry at the given index does not exist.
    118   */
    119  [can_run_script]
    120  void gotoIndex(in long index, [optional] in boolean aUserActivation);
    121 
    122  /****************************************************************************
    123   * The following flags may be bitwise combined to form the load flags
    124   * parameter passed to either the loadURI or reload method.  Some of these
    125   * flags are only applicable to loadURI.
    126   */
    127 
    128  /**
    129   * This flags defines the range of bits that may be specified.  Flags
    130   * outside this range may be used, but may not be passed to Reload().
    131   */
    132  const unsigned long LOAD_FLAGS_MASK            = 0xffff;
    133 
    134  /**
    135   * This is the default value for the load flags parameter.
    136   */
    137  const unsigned long LOAD_FLAGS_NONE            = 0x0000;
    138 
    139  /**
    140   * Flags 0x1, 0x2, 0x4, 0x8 are reserved for internal use by
    141   * nsIWebNavigation implementations for now.
    142   */
    143 
    144  /**
    145   * This flag specifies that the load should have the semantics of an HTML
    146   * Meta-refresh tag (i.e., that the cache should be bypassed).  This flag
    147   * is only applicable to loadURI.
    148   * XXX the meaning of this flag is poorly defined.
    149   * XXX no one uses this, so we should probably deprecate and remove it.
    150   */
    151  const unsigned long LOAD_FLAGS_IS_REFRESH      = 0x0010;
    152 
    153  /**
    154   * This flag specifies that the load should have the semantics of a link
    155   * click.  This flag is only applicable to loadURI.
    156   * XXX the meaning of this flag is poorly defined.
    157   */
    158  const unsigned long LOAD_FLAGS_IS_LINK         = 0x0020;
    159 
    160  /**
    161   * This flag specifies that history should not be updated.  This flag is only
    162   * applicable to loadURI.
    163   */
    164  const unsigned long LOAD_FLAGS_BYPASS_HISTORY  = 0x0040;
    165 
    166  /**
    167   * This flag specifies that any existing history entry should be replaced.
    168   * This flag is only applicable to loadURI.
    169   */
    170  const unsigned long LOAD_FLAGS_REPLACE_HISTORY = 0x0080;
    171 
    172  /**
    173   * This flag specifies that the local web cache should be bypassed, but an
    174   * intermediate proxy cache could still be used to satisfy the load.
    175   */
    176  const unsigned long LOAD_FLAGS_BYPASS_CACHE    = 0x0100;
    177 
    178  /**
    179   * This flag specifies that any intermediate proxy caches should be bypassed
    180   * (i.e., that the content should be loaded from the origin server).
    181   */
    182  const unsigned long LOAD_FLAGS_BYPASS_PROXY    = 0x0200;
    183 
    184  /**
    185   * This flag specifies that a reload was triggered as a result of detecting
    186   * an incorrect character encoding while parsing a previously loaded
    187   * document.
    188   */
    189  const unsigned long LOAD_FLAGS_CHARSET_CHANGE  = 0x0400;
    190 
    191  /**
    192   * If this flag is set, Stop() will be called before the load starts
    193   * and will stop both content and network activity (the default is to
    194   * only stop network activity).  Effectively, this passes the
    195   * STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
    196   */
    197  const unsigned long LOAD_FLAGS_STOP_CONTENT    = 0x0800;
    198 
    199  /**
    200   * A hint this load was prompted by an external program: take care!
    201   */
    202  const unsigned long LOAD_FLAGS_FROM_EXTERNAL   = 0x1000;
    203 
    204  /**
    205   * This flag specifies that this is the first load in this object.
    206   * Set with care, since setting incorrectly can cause us to assume that
    207   * nothing was actually loaded in this object if the load ends up being
    208   * handled by an external application.  This flag must not be passed to
    209   * Reload.
    210   */
    211  const unsigned long LOAD_FLAGS_FIRST_LOAD = 0x4000;
    212 
    213  /**
    214   * This flag specifies that the load should not be subject to popup
    215   * blocking checks.  This flag must not be passed to Reload.
    216   */
    217  const unsigned long LOAD_FLAGS_ALLOW_POPUPS = 0x8000;
    218 
    219  /**
    220   * This flag specifies that the URI classifier should not be checked for
    221   * this load.  This flag must not be passed to Reload.
    222   */
    223  const unsigned long LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10000;
    224 
    225  /**
    226   * Force relevant cookies to be sent with this load even if normally they
    227   * wouldn't be.
    228   */
    229  const unsigned long LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20000;
    230 
    231  /**
    232   * Prevent the owner principal from being inherited for this load.
    233   */
    234  const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL = 0x40000;
    235 
    236  /**
    237   * Overwrite the returned error code with a specific result code
    238   * when an error page is displayed.
    239   */
    240  const unsigned long LOAD_FLAGS_ERROR_LOAD_CHANGES_RV = 0x80000;
    241 
    242  /**
    243   * This flag specifies that the URI may be submitted to a third-party
    244   * server for correction. This should only be applied to non-sensitive
    245   * URIs entered by users.  This flag must not be passed to Reload.
    246   */
    247  const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x100000;
    248 
    249  /**
    250   * This flag specifies that common scheme typos should be corrected.
    251   */
    252  const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS = 0x200000;
    253 
    254  /**
    255   * Allows a top-level data: navigation to occur. E.g. view-image
    256   * is an explicit user action which should be allowed.
    257   */
    258  const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;
    259 
    260  /**
    261   * This load is the result of an HTTP redirect.
    262   */
    263  const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
    264 
    265  /**
    266   * These flags force TRR_DISABLED_MODE or TRR_ONLY_MODE on the
    267   * browsingContext's defaultLoadFlags.
    268   * The basic use case for this is the captive portal login tab
    269   * that needs skip TRR even when the browser defaults to TRR-only mode.
    270   */
    271  const unsigned long LOAD_FLAGS_DISABLE_TRR = 0x1000000;
    272  const unsigned long LOAD_FLAGS_FORCE_TRR = 0x2000000;
    273 
    274  /**
    275   * This load should bypass the LoadURIDelegate.loadUri.
    276   */
    277  const unsigned long LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE = 0x4000000;
    278 
    279  /**
    280   * This load has a user activation. (e.g: reload button was clicked)
    281   */
    282  const unsigned long LOAD_FLAGS_USER_ACTIVATION = 0x8000000;
    283 
    284  /**
    285   * Loads a given URI.  This will give priority to loading the requested URI
    286   * in the object implementing this interface.  If it can't be loaded here
    287   * however, the URI dispatcher will go through its normal process of content
    288   * loading.
    289   *
    290   * @param aURI
    291   *        The URI to load.
    292   * @param aLoadURIOptions
    293   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
    294   *        the triggeringPrincipal, the referrer info.
    295   */
    296  [implicit_jscontext, binaryname(LoadURIFromScript)]
    297  void loadURI(in nsIURI aURI,
    298               in jsval  aLoadURIOptions);
    299 
    300  /**
    301   * Parse / fix up a URI out of the string and load it.
    302   * This will give priority to loading the requested URI
    303   * in the object implementing this interface.  If it can't be loaded here
    304   * however, the URI dispatcher will go through its normal process of content
    305   * loading.
    306   *
    307   * @param aURIString
    308   *        The URI string to load.  For HTTP and FTP URLs and possibly others,
    309   *        characters above U+007F will be converted to UTF-8 and then URL-
    310   *        escaped per the rules of RFC 2396.
    311   *        This method may use nsIURIFixup to try to fix up typos etc. in the
    312   *        input string based on the load flag arguments in aLoadURIOptions.
    313   *        It can even convert the input to a search results page using the
    314   *        default search service.
    315   *        If you have an nsIURI anyway, prefer calling `loadURI`, above.
    316   * @param aLoadURIOptions
    317   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
    318   *        the triggeringPrincipal, the referrer info.
    319   */
    320  [implicit_jscontext, binaryname(FixupAndLoadURIStringFromScript)]
    321  void fixupAndLoadURIString(in AString aURIString,
    322                             in jsval   aLoadURIOptions);
    323 
    324  /**
    325   * A C++ friendly version of loadURI
    326   */
    327  [nostdcall, binaryname(LoadURI)]
    328  void binaryLoadURI(in nsIURI            aURI,
    329                     in LoadURIOptionsRef aLoadURIOptions);
    330 
    331  /**
    332   * A C++ friendly version of fixupAndLoadURIString
    333   */
    334  [nostdcall, binaryname(FixupAndLoadURIString)]
    335  void binaryFixupAndLoadURIString(in AString           aURIString,
    336                                   in LoadURIOptionsRef aLoadURIOptions);
    337 
    338  /**
    339   * Tells the Object to reload the current page.  There may be cases where the
    340   * user will be asked to confirm the reload (for example, when it is
    341   * determined that the request is non-idempotent).
    342   *
    343   * @param aReloadFlags
    344   *        Flags modifying load behaviour.  This parameter is a bitwise
    345   *        combination of the Load Flags defined above.  (Undefined bits are
    346   *        reserved for future use.)  Generally you will pass LOAD_FLAGS_NONE
    347   *        for this parameter.
    348   *
    349   * @throw NS_BINDING_ABORTED
    350   *        Indicating that the user canceled the reload.
    351   */
    352  void reload(in unsigned long aReloadFlags);
    353 
    354  /****************************************************************************
    355   * The following flags may be passed as the stop flags parameter to the stop
    356   * method defined on this interface.
    357   */
    358 
    359  /**
    360   * This flag specifies that all network activity should be stopped.  This
    361   * includes both active network loads and pending META-refreshes.
    362   */
    363  const unsigned long STOP_NETWORK = 0x01;
    364 
    365  /**
    366   * This flag specifies that all content activity should be stopped.  This
    367   * includes animated images, plugins and pending Javascript timeouts.
    368   */
    369  const unsigned long STOP_CONTENT = 0x02;
    370 
    371  /**
    372   * This flag specifies that all activity should be stopped.
    373   */
    374  const unsigned long STOP_ALL     = 0x03;
    375 
    376  /**
    377   * Stops a load of a URI.
    378   *
    379   * @param aStopFlags
    380   *        This parameter is one of the stop flags defined above.
    381   */
    382  void stop(in unsigned long aStopFlags);
    383 
    384  /**
    385   * Retrieves the current DOM document for the frame, or lazily creates a
    386   * blank document if there is none.  This attribute never returns null except
    387   * for unexpected error situations.
    388   */
    389  readonly attribute Document document;
    390 
    391  /**
    392   * The currently loaded URI or null.
    393   */
    394  readonly attribute nsIURI currentURI;
    395 
    396  /**
    397   * The session history object used by this web navigation instance. This
    398   * object will be a mozilla::dom::ChildSHistory object, but is returned as
    399   * nsISupports so it can be called from JS code.
    400   */
    401  [binaryname(SessionHistoryXPCOM)]
    402  readonly attribute nsISupports sessionHistory;
    403 
    404  %{ C++
    405  /**
    406   * Get the session history object used by this nsIWebNavigation instance.
    407   * Use this method instead of the XPCOM method when getting the
    408   * SessionHistory from C++ code.
    409   */
    410  already_AddRefed<mozilla::dom::ChildSHistory>
    411  GetSessionHistory()
    412  {
    413    nsCOMPtr<nsISupports> history;
    414    GetSessionHistoryXPCOM(getter_AddRefs(history));
    415    return history.forget()
    416      .downcast<mozilla::dom::ChildSHistory>();
    417  }
    418  %}
    419 
    420  /**
    421   * Resume a load which has been redirected from another process.
    422   *
    423   * A negative |aHistoryIndex| value corresponds to a non-history load being
    424   * resumed.
    425   */
    426  void resumeRedirectedLoad(in unsigned long long aLoadIdentifier,
    427                            in long aHistoryIndex);
    428 };