tor-browser

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

nsIReferrerInfo.idl (4844B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "nsISupports.idl"
      6 #include "nsISerializable.idl"
      7 
      8 %{C++
      9 namespace mozilla::dom {
     10 enum class ReferrerPolicy : uint8_t;
     11 }
     12 %}
     13 
     14 interface nsIURI;
     15 webidl Document;
     16 webidl Element;
     17 
     18 native ReferrerPolicy(mozilla::dom::ReferrerPolicy);
     19 native URIRef(already_AddRefed<nsIURI>);
     20 
     21 [scriptable, builtinclass, uuid(081cdc36-f2e2-4f94-87bf-78578f06f1eb)]
     22 interface nsIReferrerInfo : nsISerializable
     23 {
     24  /**
     25   * Unfortunately we can not query the ReferrerPolicy values defined within
     26   * ReferrerPolicy.webidl directly from xpidl. Hence we define the enum value
     27   * ReferrerPolicyIDL to set up the ReferrerInfo object from JS. If you need
     28   * ReferrerPolicy in native code, please directly query it from
     29   * ReferrerPolicy.webidl.
     30   *
     31   * Note that the deserialization code assumes that the ReferrerPolicyIDL only
     32   * uses one byte. If we would need to change the format here, we should also
     33   * update the deserialization code.
     34   */
     35  cenum ReferrerPolicyIDL : 8 {
     36  /**
     37   * The undefined state, or no referrer policy, usually causing a fallback to a
     38   * referrer policy definded in higher level policy. For example: request by
     39   * clicking <a> element with empty referrer policy will be sent with the
     40   * referrer policy of the a element’s node document.
     41   * If there is no higher-level policy available, we fall back to the default
     42   * value, which usually is "no-referrer-when-downgrade".
     43   */
     44  EMPTY = 0,
     45  /**
     46   * Do not send referrer from https->http
     47   */
     48  NO_REFERRER_WHEN_DOWNGRADE = 1,
     49  /**
     50   * Do not send referrer at all.
     51   */
     52  NO_REFERRER = 2,
     53  /**
     54   * Only send the origin of the referring URL
     55   */
     56  ORIGIN = 3,
     57  /**
     58   * Send origin when cross-origin.
     59   */
     60  ORIGIN_WHEN_CROSS_ORIGIN = 4,
     61  /**
     62   * Always sends the referrer, even on downgrade.
     63   */
     64  UNSAFE_URL = 5,
     65  /**
     66   * Send referrer when same-origin, no referrer when cross-origin
     67   */
     68  SAME_ORIGIN = 6,
     69  /**
     70   * Send origin when request from https->https or http->http(s). No referrer
     71   * when request from https->http.
     72   */
     73  STRICT_ORIGIN = 7,
     74  /**
     75   * Send referrer when same-origin, send origin when cross-origin from
     76   * https->https or http->http(s). No referrer when request from https->http.
     77   */
     78  STRICT_ORIGIN_WHEN_CROSS_ORIGIN = 8,
     79  };
     80 
     81  /**
     82   * The original referrer URI which indicates the full referrer before applying
     83   * referrer policy
     84   */
     85  [infallible] readonly attribute nsIURI originalReferrer;
     86 
     87  /**
     88   * Referrer policy which is applied to the referrer
     89   */
     90  [implicit_jscontext] readonly attribute nsIReferrerInfo_ReferrerPolicyIDL referrerPolicy;
     91 
     92  /**
     93   * C++ friendly version of referrerPolicy getter
     94   */
     95  [noscript, notxpcom, nostdcall, binaryname(ReferrerPolicy)]
     96  ReferrerPolicy binaryReferrerPolicy();
     97 
     98  /**
     99   * Get referrer policy as string
    100   */
    101  ACString getReferrerPolicyString();
    102 
    103  /**
    104   * Indicates if the referrer should not be sent or not even when it's available.
    105   */
    106  [infallible] readonly attribute boolean sendReferrer;
    107 
    108  /**
    109  * Indicates if the referrer should not be sent or not even when it's available.
    110  */
    111  readonly attribute ACString computedReferrerSpec;
    112 
    113  /**
    114   * Get the computed referrer, if one has been set. The computed referrer is
    115   * the original referrer manipulated by the referrer-policy. Use the result of
    116   * this function as the actual referrer value for the channel.
    117   */
    118  [must_use, noscript, nostdcall, notxpcom]
    119  URIRef GetComputedReferrer();
    120 
    121  /**
    122   * Returns whether the other referrerInfo is equivalent to this referrerInfo.
    123   */
    124  boolean equals(in nsIReferrerInfo other);
    125 
    126  /**
    127   * Initialize method to create ReferrerInfo object from JS
    128   * @param aReferrerPolicy referrer policy of the created object
    129   * @param aSendReferrer sendReferrer of the created object, defaults to false
    130   * @param aOriginalReferrer the original referrer, defaults to null.
    131   */
    132  void init(in nsIReferrerInfo_ReferrerPolicyIDL aReferrerPolicy,
    133           [optional] in boolean aSendReferrer,
    134           [optional] in nsIURI aOriginalReferrer);
    135 
    136  /**
    137   * Initialize with a given document.
    138   * @param aDocument the document to init referrerInfo object
    139   */
    140  void initWithDocument([const] in Document aDocument);
    141 
    142  /**
    143   * Initialize with a given node. It you are working with node which supports
    144   * referrerpolicy attribute: <a>, <img>, <area>, <script>, <iframe>, please
    145   * try to use this init instead of initWithDocument, because referrer policy
    146   * from rel and attribute has a higher priority.
    147   * @param aNode the element to init referrerInfo object
    148   */
    149  void initWithElement([const] in Element aNode);
    150 };