summaryrefslogtreecommitdiffstats
path: root/netwerk/url-classifier/nsIUrlClassifierFeature.idl
blob: a7ee58289dac4d45bd7f6c4810922d44bbd04589 (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
/* 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"

%{C++
#include "nsStringFwd.h"
#include "nsTArrayForwardDeclare.h"
%}
[ref] native StringArrayRef(nsTArray<nsCString>);
[ref] native ConstStringArrayRef(const nsTArray<nsCString>);

interface nsIChannel;
interface nsIURI;

/**
 * A single URLClassifier feature.
 */
[builtinclass, scriptable, uuid(a6c9b24e-b4f1-426e-af58-2c976c3943a8)]
interface nsIUrlClassifierFeature : nsISupports
{
  cenum listType: 8 {
    blocklist = 0,
    entitylist = 1,
  };

  cenum URIType: 8 {
    blocklistURI = 0,
    entitylistURI = 1,
    pairwiseEntitylistURI = 2,
  };

  /**
   * The feature name
   */
  readonly attribute ACString name;

  /**
   * Returns the tables for one of the possible lists.
   */
  [noscript] StringArrayRef getTables(in nsIUrlClassifierFeature_listType aListType);

  /**
   * Returns true if |aTable| is part of the tables of |aListType| type.
   */
  [noscript] boolean hasTable(in ACString aTable,
                              in nsIUrlClassifierFeature_listType aListType);

  /**
   * Returns true if |aHost| is contained in the preference of |aListType| type.
   * |aPrefTableName| will be set to the table name to use.
   */
  [noscript] boolean hasHostInPreferences(in ACString aHost,
                                          in nsIUrlClassifierFeature_listType aListType,
                                          out ACString aPrefTableName);

  /**
   * Returns a comma-separated list of hosts to be ignored.
   */
  readonly attribute ACString exceptionHostList;

  /**
   * When this feature matches the channel, this method is executed to do
   * 'something' on the channel. For instance, a tracking-annotation feature
   * would mark the channel as tracker, a tracking-protection feature would
   * cancel the channel.
   * Returns if we should process other feature results or not. For instance,
   * tracking-protection cancel the channel, and after that we should stop
   * processing other features.
   */
  [noscript] boolean processChannel(in nsIChannel aChannel,
                                    in ConstStringArrayRef aList,
                                    in ConstStringArrayRef aHashes);

  /**
   * Features can work with different URLs from a channel (channel url, or
   * top-level, or something else). This method returns what we need to use for
   * the current list.
   * If the returned URI is created by CreatePairwiseEntityListURI(), the
   * URIType is pairwiseEntitylistURI. Otherwise, it depends on the listType.
   */
  [noscript] nsIURI getURIByListType(in nsIChannel channel,
                                     in nsIUrlClassifierFeature_listType listType,
                                     out nsIUrlClassifierFeature_URIType URIType);
};

/**
 * The result of the classifier operation is this interface.
 * See asyncClassifyLocalWithFeatures() in nsIURIClassifier.idl.
 */
[builtinclass, scriptable, uuid(ccb88140-5d66-4873-9815-a1b98d6cdc92)]
interface nsIUrlClassifierFeatureResult : nsISupports
{
  readonly attribute nsIURI uri;

  readonly attribute nsIUrlClassifierFeature feature;

  // Comma separate tables or preferences.
  readonly attribute ACString list;
};

/**
 * Callback function for nsIURIClassifier lookups.
 * See asyncClassifyLocalWithFeatures() in nsIURIClassifier.idl.
 */
[scriptable, function, uuid(2ea83c26-dfc9-44ed-9cfc-171d4753d78e)]
interface nsIUrlClassifierFeatureCallback : nsISupports
{
  /**
   * Called by the URI classifier service when it is done checking a URI.
   *
   * Clients are responsible for associating callback objects with classify()
   * calls.
   *
   * @param aResults
   *        List of nsIUrlClassifierFeatureResult objects.
   */
  void onClassifyComplete(in Array<nsIUrlClassifierFeatureResult> aResults);
};