tor-browser

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

nsIClassifiedChannel.idl (7062B)


      1 /* -*- Mode: C++; 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 %{C++
      9 namespace mozilla::net {
     10 // This struct is used to hold classification flags for both
     11 // firstPartyClassificationFlags and thirdPartyClassificationFlags.
     12 struct ClassificationFlags {
     13  uint32_t firstPartyFlags;
     14  uint32_t thirdPartyFlags;
     15 };
     16 }
     17 %}
     18 
     19 /**
     20 * nsIClassifiedChannel
     21 *
     22 * A channel may optionally implement this interface if it carries classified
     23 * result information of channel classifier. The information contains, for
     24 * example, the name of matched table and the name of matched provider.
     25 */
     26 [builtinclass, scriptable, uuid(70cf6091-a1de-4aa8-8224-058f8964be31)]
     27 interface nsIClassifiedChannel : nsISupports
     28 {
     29  /**
     30   * Sets matched info of the classified channel.
     31   *
     32   * @param aList
     33   *        Name of the Safe Browsing list that matched (e.g. goog-phish-shavar).
     34   * @param aProvider
     35   *        Name of the Safe Browsing provider that matched (e.g. google)
     36   * @param aFullHash
     37   *        Full hash of URL that matched Safe Browsing list.
     38   */
     39  void setMatchedInfo(in ACString aList,
     40                      in ACString aProvider,
     41                      in ACString aFullHash);
     42 
     43  /**
     44   * Name of the list that matched
     45   */
     46  readonly attribute ACString matchedList;
     47 
     48  /**
     49   * Name of provider that matched
     50   */
     51  readonly attribute ACString matchedProvider;
     52 
     53  /**
     54   * Full hash of URL that matched
     55   */
     56  readonly attribute ACString matchedFullHash;
     57 
     58  /**
     59   * Sets matched tracking info of the classified channel.
     60   *
     61   * @param aLists
     62   *        Name of the Tracking Protection list that matched (e.g. content-track-digest256).
     63   * @param aFullHash
     64   *        Full hash of URLs that matched Tracking Protection list.
     65   */
     66  void setMatchedTrackingInfo(in Array<ACString> aLists,
     67                              in Array<ACString> aFullHashes);
     68 
     69  /**
     70   * Name of the lists that matched
     71   */
     72  readonly attribute Array<ACString> matchedTrackingLists;
     73 
     74  /**
     75   * Full hash of URLs that matched
     76   */
     77  readonly attribute Array<ACString> matchedTrackingFullHashes;
     78 
     79  /**
     80   * Returns the classification flags if the channel has been processed by
     81   * URL-Classifier features and is considered first-party.
     82   */
     83  [infallible] readonly attribute unsigned long firstPartyClassificationFlags;
     84 
     85  /**
     86   * Returns the classification flags if the channel has been processed by
     87   * URL-Classifier features and is considered third-party with the top
     88   * window URI.
     89   */
     90  [infallible] readonly attribute unsigned long thirdPartyClassificationFlags;
     91 
     92  /*
     93    * Returns the classification flags if the channel has been processed by
     94    * URL-Classifier features. This value is equal to
     95    * "firstPartyClassificationFlags || thirdPartyClassificationFlags".
     96    *
     97    * Note that top-level channels could be classified as well.
     98    * In order to identify third-party resources specifically, use
     99    * classificationThirdPartyFlags;
    100    */
    101  [infallible] readonly attribute unsigned long classificationFlags;
    102 
    103  cenum ClassificationFlags : 32 {
    104    /**
    105     * The resource is on the fingerprinting list.
    106     */
    107    CLASSIFIED_FINGERPRINTING = 0x00000001,
    108    CLASSIFIED_FINGERPRINTING_CONTENT = 0x00000002,
    109 
    110    /**
    111     * The resource is on the cryptomining list.
    112     */
    113    CLASSIFIED_CRYPTOMINING = 0x00000004,
    114    CLASSIFIED_CRYPTOMINING_CONTENT = 0x00000008,
    115 
    116    /**
    117     * The following are about tracking annotation and are available only
    118     * if the privacy.trackingprotection.annotate_channels pref.
    119     * CLASSIFIED_TRACKING is set if we are not able to identify the
    120     * type of classification.
    121     */
    122    CLASSIFIED_TRACKING = 0x00000010,
    123    CLASSIFIED_TRACKING_AD = 0x00000020,
    124    CLASSIFIED_TRACKING_ANALYTICS = 0x00000040,
    125    CLASSIFIED_TRACKING_SOCIAL = 0x00000080,
    126    CLASSIFIED_TRACKING_CONTENT = 0x00000100,
    127 
    128    /**
    129     * The following are about social tracking.
    130     */
    131    CLASSIFIED_SOCIALTRACKING = 0x00000200,
    132    CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x00000400,
    133    CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x00000800,
    134    CLASSIFIED_SOCIALTRACKING_TWITTER = 0x00001000,
    135 
    136    /**
    137     * The following are about email tracking.
    138     */
    139    CLASSIFIED_EMAILTRACKING = 0x00002000,
    140    CLASSIFIED_EMAILTRACKING_CONTENT = 0x00004000,
    141 
    142    /**
    143     * The following are about consent managers.
    144     */
    145    CLASSIFIED_CONSENTMANAGER = 0x00008000,
    146 
    147    /**
    148     * The following are about anti fraud.
    149     */
    150    CLASSIFIED_ANTIFRAUD = 0x00010000,
    151 
    152    /**
    153     * This is exposed to help to identify tracking classification using the
    154     * basic lists.
    155     */
    156    CLASSIFIED_ANY_BASIC_TRACKING = CLASSIFIED_TRACKING |
    157      CLASSIFIED_TRACKING_AD | CLASSIFIED_TRACKING_ANALYTICS |
    158      CLASSIFIED_TRACKING_SOCIAL | CLASSIFIED_FINGERPRINTING,
    159 
    160    /**
    161     * This is exposed to help to identify tracking classification using the
    162     * strict lists.
    163     */
    164    CLASSIFIED_ANY_STRICT_TRACKING = CLASSIFIED_ANY_BASIC_TRACKING |
    165      CLASSIFIED_TRACKING_CONTENT | CLASSIFIED_FINGERPRINTING_CONTENT,
    166 
    167    /**
    168     * This is exposed to help to identify social tracking classification
    169     * flags.
    170     */
    171    CLASSIFIED_ANY_SOCIAL_TRACKING = CLASSIFIED_SOCIALTRACKING |
    172      CLASSIFIED_SOCIALTRACKING_FACEBOOK |
    173      CLASSIFIED_SOCIALTRACKING_LINKEDIN | CLASSIFIED_SOCIALTRACKING_TWITTER,
    174  };
    175 
    176  /**
    177   * Returns true  if the channel has been processed by URL-Classifier features
    178   * and is considered third-party with the top window URI, and if it has loaded
    179   * a resource that is classified as a tracker.
    180   *
    181   * This is a helper attribute which returns the same value of
    182   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
    183   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_STRICT_TRACKING) or
    184   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_SOCIAL_TRACKING)
    185   */
    186  boolean isThirdPartyTrackingResource();
    187 
    188 %{ C++
    189  inline bool IsThirdPartyTrackingResource()
    190  {
    191    bool value = false;
    192    if (NS_SUCCEEDED(IsThirdPartyTrackingResource(&value)) && value) {
    193      return true;
    194    }
    195    return false;
    196  }
    197 %}
    198 
    199  /**
    200   * Returns true if the channel has loaded a 3rd party resource that is
    201   * classified as a social tracker.
    202   *
    203   * This is a helper attribute which returns the same value of
    204   * (classificationFlags & CLASSIFIED_ANY_SOCIAL_TRACKING)
    205   *
    206   * Note that top-level channels could be marked as tracking
    207   * resources. In order to identify third-party social tracking resources
    208   * specifically, check the flags manually or add a new helper here.
    209   */
    210  boolean isThirdPartySocialTrackingResource();
    211 
    212 %{ C++
    213  inline bool IsThirdPartySocialTrackingResource()
    214  {
    215    bool value = false;
    216    if (NS_SUCCEEDED(IsThirdPartySocialTrackingResource(&value)) && value) {
    217      return true;
    218    }
    219    return false;
    220  }
    221 %}
    222 };