summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsIClassifiedChannel.idl
blob: 7108e0be6b9de9203ac8248b86603c0bbe6bb79c (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
/* -*- Mode: C++; 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"

/**
 * nsIClassifiedChannel
 *
 * A channel may optionally implement this interface if it carries classified
 * result information of channel classifier. The information contains, for
 * example, the name of matched table and the name of matched provider.
 */
[builtinclass, scriptable, uuid(70cf6091-a1de-4aa8-8224-058f8964be31)]
interface nsIClassifiedChannel : nsISupports
{
  /**
   * Sets matched info of the classified channel.
   *
   * @param aList
   *        Name of the Safe Browsing list that matched (e.g. goog-phish-shavar).
   * @param aProvider
   *        Name of the Safe Browsing provider that matched (e.g. google)
   * @param aFullHash
   *        Full hash of URL that matched Safe Browsing list.
   */
  void setMatchedInfo(in ACString aList,
                      in ACString aProvider,
                      in ACString aFullHash);

  /**
   * Name of the list that matched
   */
  readonly attribute ACString matchedList;

  /**
   * Name of provider that matched
   */
  readonly attribute ACString matchedProvider;

  /**
   * Full hash of URL that matched
   */
  readonly attribute ACString matchedFullHash;

  /**
   * Sets matched tracking info of the classified channel.
   *
   * @param aLists
   *        Name of the Tracking Protection list that matched (e.g. content-track-digest256).
   * @param aFullHash
   *        Full hash of URLs that matched Tracking Protection list.
   */
  void setMatchedTrackingInfo(in Array<ACString> aLists,
                              in Array<ACString> aFullHashes);

  /**
   * Name of the lists that matched
   */
  readonly attribute Array<ACString> matchedTrackingLists;

  /**
   * Full hash of URLs that matched
   */
  readonly attribute Array<ACString> matchedTrackingFullHashes;

  /**
   * Returns the classification flags if the channel has been processed by
   * URL-Classifier features and is considered first-party.
   */
  [infallible] readonly attribute unsigned long firstPartyClassificationFlags;

  /**
   * Returns the classification flags if the channel has been processed by
   * URL-Classifier features and is considered third-party with the top
   * window URI.
   */
  [infallible] readonly attribute unsigned long thirdPartyClassificationFlags;

  /*
    * Returns the classification flags if the channel has been processed by
    * URL-Classifier features. This value is equal to
    * "firstPartyClassificationFlags || thirdPartyClassificationFlags".
    *
    * Note that top-level channels could be classified as well.
    * In order to identify third-party resources specifically, use
    * classificationThirdPartyFlags;
    */
  [infallible] readonly attribute unsigned long classificationFlags;

  cenum ClassificationFlags : 32 {
    /**
     * The resource is on the fingerprinting list.
     */
    CLASSIFIED_FINGERPRINTING = 0x0001,
    CLASSIFIED_FINGERPRINTING_CONTENT = 0x0080,

    /**
     * The resource is on the cryptomining list.
     */
    CLASSIFIED_CRYPTOMINING = 0x0002,
    CLASSIFIED_CRYPTOMINING_CONTENT = 0x0100,

    /**
     * The following are about tracking annotation and are available only
     * if the privacy.trackingprotection.annotate_channels pref.
     * CLASSIFIED_TRACKING is set if we are not able to identify the
     * type of classification.
     */
    CLASSIFIED_TRACKING = 0x0004,
    CLASSIFIED_TRACKING_AD = 0x0008,
    CLASSIFIED_TRACKING_ANALYTICS = 0x0010,
    CLASSIFIED_TRACKING_SOCIAL = 0x0020,
    CLASSIFIED_TRACKING_CONTENT = 0x0040,

    /**
     * The following are about social tracking.
     */
    CLASSIFIED_SOCIALTRACKING = 0x0200,
    CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x0400,
    CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x0800,
    CLASSIFIED_SOCIALTRACKING_TWITTER = 0x1000,

    /**
     * This is exposed to help to identify tracking classification using the
     * basic lists.
     */
    CLASSIFIED_ANY_BASIC_TRACKING = CLASSIFIED_TRACKING |
      CLASSIFIED_TRACKING_AD | CLASSIFIED_TRACKING_ANALYTICS |
      CLASSIFIED_TRACKING_SOCIAL | CLASSIFIED_FINGERPRINTING,

    /**
     * This is exposed to help to identify tracking classification using the
     * strict lists.
     */
    CLASSIFIED_ANY_STRICT_TRACKING = CLASSIFIED_ANY_BASIC_TRACKING |
      CLASSIFIED_TRACKING_CONTENT | CLASSIFIED_FINGERPRINTING_CONTENT,

    /**
     * This is exposed to help to identify social tracking classification
     * flags.
     */
    CLASSIFIED_ANY_SOCIAL_TRACKING = CLASSIFIED_SOCIALTRACKING |
      CLASSIFIED_SOCIALTRACKING_FACEBOOK |
      CLASSIFIED_SOCIALTRACKING_LINKEDIN | CLASSIFIED_SOCIALTRACKING_TWITTER,
  };

  /**
   * Returns true  if the channel has been processed by URL-Classifier features
   * and is considered third-party with the top window URI, and if it has loaded
   * a resource that is classified as a tracker.
   *
   * This is a helper attribute which returns the same value of
   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_STRICT_TRACKING) or
   * (thirdPartyClassificationFlags & CLASSIFIED_ANY_SOCIAL_TRACKING)
   */
  boolean isThirdPartyTrackingResource();

%{ C++
  inline bool IsThirdPartyTrackingResource()
  {
    bool value = false;
    if (NS_SUCCEEDED(IsThirdPartyTrackingResource(&value)) && value) {
      return true;
    }
    return false;
  }
%}

  /**
   * Returns true if the channel has loaded a 3rd party resource that is
   * classified as a social tracker.
   *
   * This is a helper attribute which returns the same value of
   * (classificationFlags & CLASSIFIED_ANY_SOCIAL_TRACKING)
   *
   * Note that top-level channels could be marked as tracking
   * resources. In order to identify third-party social tracking resources
   * specifically, check the flags manually or add a new helper here.
   */
  boolean isThirdPartySocialTrackingResource();

%{ C++
  inline bool IsThirdPartySocialTrackingResource()
  {
    bool value = false;
    if (NS_SUCCEEDED(IsThirdPartySocialTrackingResource(&value)) && value) {
      return true;
    }
    return false;
  }
%}
};