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 7%{C++ 8#include "nsStringFwd.h" 9#include "nsTArrayForwardDeclare.h" 10%} 11[ref] native StringArrayRef(nsTArray<nsCString>); 12[ref] native ConstStringArrayRef(const nsTArray<nsCString>); 13 14interface nsIChannel; 15interface nsIURI; 16 17/** 18 * A single URLClassifier feature. 19 */ 20[builtinclass, scriptable, uuid(a6c9b24e-b4f1-426e-af58-2c976c3943a8)] 21interface nsIUrlClassifierFeature : nsISupports 22{ 23 cenum listType: 8 { 24 blocklist = 0, 25 entitylist = 1, 26 }; 27 28 cenum URIType: 8 { 29 blocklistURI = 0, 30 entitylistURI = 1, 31 pairwiseEntitylistURI = 2, 32 }; 33 34 /** 35 * The feature name 36 */ 37 readonly attribute ACString name; 38 39 /** 40 * Returns the tables for one of the possible lists. 41 */ 42 [noscript] StringArrayRef getTables(in nsIUrlClassifierFeature_listType aListType); 43 44 /** 45 * Returns true if |aTable| is part of the tables of |aListType| type. 46 */ 47 [noscript] boolean hasTable(in ACString aTable, 48 in nsIUrlClassifierFeature_listType aListType); 49 50 /** 51 * Returns true if |aHost| is contained in the preference of |aListType| type. 52 * |aPrefTableName| will be set to the table name to use. 53 */ 54 [noscript] boolean hasHostInPreferences(in ACString aHost, 55 in nsIUrlClassifierFeature_listType aListType, 56 out ACString aPrefTableName); 57 58 /** 59 * Returns a comma-separated list of hosts to be ignored. 60 */ 61 readonly attribute ACString exceptionHostList; 62 63 /** 64 * When this feature matches the channel, this method is executed to do 65 * 'something' on the channel. For instance, a tracking-annotation feature 66 * would mark the channel as tracker, a tracking-protection feature would 67 * cancel the channel. 68 * Returns if we should process other feature results or not. For instance, 69 * tracking-protection cancel the channel, and after that we should stop 70 * processing other features. 71 */ 72 [noscript] boolean processChannel(in nsIChannel aChannel, 73 in ConstStringArrayRef aList, 74 in ConstStringArrayRef aHashes); 75 76 /** 77 * Features can work with different URLs from a channel (channel url, or 78 * top-level, or something else). This method returns what we need to use for 79 * the current list. 80 * If the returned URI is created by CreatePairwiseEntityListURI(), the 81 * URIType is pairwiseEntitylistURI. Otherwise, it depends on the listType. 82 */ 83 [noscript] nsIURI getURIByListType(in nsIChannel channel, 84 in nsIUrlClassifierFeature_listType listType, 85 out nsIUrlClassifierFeature_URIType URIType); 86}; 87 88/** 89 * The result of the classifier operation is this interface. 90 * See asyncClassifyLocalWithFeatures() in nsIURIClassifier.idl. 91 */ 92[builtinclass, scriptable, uuid(ccb88140-5d66-4873-9815-a1b98d6cdc92)] 93interface nsIUrlClassifierFeatureResult : nsISupports 94{ 95 readonly attribute nsIURI uri; 96 97 readonly attribute nsIUrlClassifierFeature feature; 98 99 // Comma separate tables or preferences. 100 readonly attribute ACString list; 101}; 102 103/** 104 * Callback function for nsIURIClassifier lookups. 105 * See asyncClassifyLocalWithFeatures() in nsIURIClassifier.idl. 106 */ 107[scriptable, function, uuid(2ea83c26-dfc9-44ed-9cfc-171d4753d78e)] 108interface nsIUrlClassifierFeatureCallback : nsISupports 109{ 110 /** 111 * Called by the URI classifier service when it is done checking a URI. 112 * 113 * Clients are responsible for associating callback objects with classify() 114 * calls. 115 * 116 * @param aResults 117 * List of nsIUrlClassifierFeatureResult objects. 118 */ 119 void onClassifyComplete(in Array<nsIUrlClassifierFeatureResult> aResults); 120}; 121