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
7interface nsIArray;
8
9/**
10 * This interface contains feilds in Matches object of FullHashResponse(V4).
11 * Reference from:
12 * https://developers.google.com/safe-browsing/v4/update-api#http-post-response_2
13 */
14[scriptable, uuid(aabeb50e-d9f7-418e-9469-2cd9608958c0)]
15interface nsIFullHashMatch : nsISupports
16{
17  readonly attribute ACString tableName;
18
19  readonly attribute ACString fullHash;
20
21  readonly attribute uint32_t cacheDuration;
22};
23
24/**
25 * This interface is implemented by nsIUrlClassifierHashCompleter clients.
26 */
27[scriptable, uuid(da16de40-df26-414d-bde7-c4faf4504868)]
28interface nsIUrlClassifierHashCompleterCallback : nsISupports
29{
30  /**
31   * A complete hash has been found that matches the partial hash.
32   * This method may be called 0-n times for a given
33   * nsIUrlClassifierCompleter::complete() call.
34   *
35   * @param hash
36   *        The 256-bit hash that was discovered.
37   * @param table
38   *        The name of the table that this hash belongs to.
39   * @param chunkId
40   *        The database chunk that this hash belongs to.
41   */
42  void completionV2(in ACString hash,
43                    in ACString table,
44                    in uint32_t chunkId);
45
46  /**
47   * This will be called when a fullhash response is received and parsed
48   * no matter if any full hash has been found.
49   *
50   * @param partialHash
51   *        The hash that was sent for completion.
52   * @param table
53   *        The name of the table that this hash belongs to.
54   * @param negativeCacheDuration
55   *        The negative cache duration in millisecond.
56   * @param fullHashes
57   *        Array of fullhashes that match the prefix.
58   */
59  void completionV4(in ACString partialHash,
60                    in ACString table,
61                    in uint32_t negativeCacheDuration,
62                    in nsIArray fullHashes);
63
64  /**
65   * The completion is complete.  This method is called once per
66   * nsIUrlClassifierCompleter::complete() call, after all completion()
67   * calls are finished.
68   *
69   * @param status
70   *        NS_OK if the request completed successfully, or an error code.
71   */
72  void completionFinished(in nsresult status);
73};
74
75/**
76 * Clients updating the url-classifier database have the option of sending
77 * partial (32-bit) hashes of URL fragments to be blacklisted.  If the
78 * url-classifier encounters one of these truncated hashes, it will ask an
79 * nsIUrlClassifierCompleter instance to asynchronously provide the complete
80 * hash, along with some associated metadata.
81 * This is only ever used for testing and should absolutely be deleted (I
82 * think).
83 */
84[scriptable, uuid(231fb2ad-ea8a-4e63-a331-eafc3b434811)]
85interface nsIUrlClassifierHashCompleter : nsISupports
86{
87  /**
88   * Request a completed hash from the given gethash url.
89   *
90   * @param partialHash
91   *        The 32-bit hash encountered by the url-classifier.
92   * @param gethashUrl
93   *        The gethash url to use.
94   * @param tableName
95   *        The table where we matched the partial hash.
96   * @param callback
97   *        An nsIUrlClassifierCompleterCallback instance.
98   */
99  void complete(in ACString partialHash,
100                in ACString gethashUrl,
101                in ACString tableName,
102                in nsIUrlClassifierHashCompleterCallback callback);
103};
104