tor-browser

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

nsIURIClassifier.idl (4348B)


      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 "nsIUrlClassifierFeature.idl"
      7 
      8 %{C++
      9 #include "nsStringFwd.h"
     10 #include "nsTArrayForwardDeclare.h"
     11 %}
     12 [ref] native StringArrayRef(nsTArray<nsCString>);
     13 
     14 interface nsIChannel;
     15 interface nsISerialEventTarget;
     16 interface nsIPrincipal;
     17 interface nsIURI;
     18 interface nsIUrlClassifierFeatureCallback;
     19 
     20 /**
     21 * Callback function for nsIURIClassifier lookups.
     22 */
     23 [scriptable, function, uuid(8face46e-0c96-470f-af40-0037dcd797bd)]
     24 interface nsIURIClassifierCallback : nsISupports
     25 {
     26  /**
     27   * Called by the URI classifier service when it is done checking a URI.
     28   *
     29   * Clients are responsible for associating callback objects with classify()
     30   * calls.
     31   *
     32   * @param aErrorCode
     33   *        The error code with which the channel should be cancelled, or
     34   *        NS_OK if the load should continue normally.
     35   * @param aList
     36   *        Name of the list that matched
     37   * @param aProvider
     38   *        Name of provider that matched
     39   * @param aFullHash
     40   *        Full hash of URL that matched
     41   */
     42  void onClassifyComplete(in nsresult aErrorCode,
     43                          in ACString aList,
     44                          in ACString aProvider,
     45                          in ACString aFullHash);
     46 };
     47 
     48 /**
     49 * The URI classifier service checks a URI against lists of phishing
     50 * and malware sites.
     51 */
     52 [scriptable, uuid(596620cc-76e3-4133-9d90-360e59a794cf)]
     53 interface nsIURIClassifier : nsISupports
     54 {
     55  /**
     56   * Classify a Principal using its URI.
     57   *
     58   * @param aPrincipal
     59   *        The principal that should be checked by the URI classifier.
     60   *
     61   * @param aCallback
     62   *        The URI classifier will call this callback when the URI has been
     63   *        classified.
     64   *
     65   * @return <code>false</code> if classification is not necessary.  The
     66   *         callback will not be called.
     67   *         <code>true</code> if classification will be performed.  The
     68   *         callback will be called.
     69   */
     70  boolean classify(in nsIPrincipal aPrincipal,
     71                   in nsIURIClassifierCallback aCallback);
     72 
     73  /**
     74   * Asynchronously classify a URI with list of features. This does not make
     75   * network requests.
     76   */
     77  void asyncClassifyLocalWithFeatures(in nsIURI aURI,
     78                                      in Array<nsIUrlClassifierFeature> aFeatures,
     79                                      in nsIUrlClassifierFeature_listType aListType,
     80                                      in nsIUrlClassifierFeatureCallback aCallback,
     81                                      [optional] in boolean aIdlePriority);
     82 
     83  /**
     84   * Asynchronously classify a URI with list of features. This does not make
     85   * network requests. This takes a list of names so it can safely be called in
     86   * the content process.
     87   */
     88  void asyncClassifyLocalWithFeatureNames(in nsIURI aURI,
     89                                      in Array<ACString> aFeatures,
     90                                      in nsIUrlClassifierFeature_listType aListType,
     91                                      in nsIUrlClassifierFeatureCallback aCallback);
     92 
     93  /**
     94   * Returns a feature named aFeatureName.
     95   */
     96  nsIUrlClassifierFeature getFeatureByName(in ACString aFeatureName);
     97 
     98  /**
     99   * Returns all the feature names.
    100   */
    101  Array<ACString> getFeatureNames();
    102 
    103  /**
    104   * Create a new feature with a list of tables. This method is just for
    105   * testing! Don't use it elsewhere.
    106   */
    107  nsIUrlClassifierFeature createFeatureWithTables(in ACString aName,
    108                                                  in Array<ACString> aBlocklistTables,
    109                                                  in Array<ACString> aEntitylistTables);
    110 
    111  /**
    112   * Report to the provider that a Safe Browsing warning was shown.
    113   *
    114   * @param aChannel
    115   *        Channel for which the URL matched something on the threat list.
    116   * @param aProvider
    117   *        Provider to notify.
    118   * @param aList
    119   *        List where the full hash was found.
    120   * @param aFullHash
    121   *        Full URL hash that triggered the warning.
    122   */
    123 
    124  void sendThreatHitReport(in nsIChannel aChannel, in ACString aProvider,
    125                           in ACString aList, in ACString aFullHash);
    126 };