1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6#include "nsISupports.idl"
7
8interface nsIPrincipal;
9
10/**
11 * Interface for a class that manages updates of the url classifier database.
12 */
13
14[scriptable, uuid(d60a08ee-5c83-4eb6-bdfb-79fd0716501e)]
15interface nsIUrlListManager : nsISupports
16{
17    /**
18     * Get the gethash url for this table
19     */
20    ACString getGethashUrl(in ACString tableName);
21
22    /**
23     * Get the update url for this table
24     */
25    ACString getUpdateUrl(in ACString tableName);
26
27    /**
28     * Add a table to the list of tables we are managing. The name is a
29     * string of the format provider_name-semantic_type-table_type.  For
30     * @param tableName A string of the format
31     *        provider_name-semantic_type-table_type.  For example,
32     *        goog-white-enchash or goog-black-url.
33     * @param providerName The name of the entity providing the list.
34     * @param updateUrl The URL from which to fetch updates.
35     * @param gethashUrl The URL from which to fetch hash completions.
36     */
37    boolean registerTable(in ACString tableName,
38                          in ACString providerName,
39                          in ACString updateUrl,
40                          in ACString gethashUrl);
41
42    /**
43     * Unregister table from the list
44     */
45    void unregisterTable(in ACString tableName);
46
47    /**
48     * Turn on update checking for a table. I.e., during the next server
49     * check, download updates for this table.
50     */
51    void enableUpdate(in ACString tableName);
52
53    /**
54     * Turn off update checking for all tables.
55     */
56    void disableAllUpdates();
57
58    /**
59     * Turn off update checking for a single table. Only used in tests.
60     */
61    void disableUpdate(in ACString tableName);
62
63    /**
64     * Toggle update checking, if necessary.
65     */
66    void maybeToggleUpdateChecking();
67
68    /**
69     * This is currently used by about:url-classifier to force an update
70     * for the update url. Update may still fail because of backoff algorithm.
71     */
72    boolean checkForUpdates(in ACString updateUrl);
73
74    /**
75     * Force updates for the given tables, updates are still restricted to
76     * backoff algorithm.
77     * @param tables  A string lists all the tables that we want to trigger updates.
78     *                table names are separated with ','.
79     */
80    boolean forceUpdates(in ACString tableNames);
81
82    /**
83     * This is currently used by about:url-classifier to get back-off time
84     * (in millisecond since epoch) for the given provider. Return 0 if we
85     * are not in back-off mode.
86     */
87    uint64_t getBackOffTime(in ACString provider);
88
89    /**
90     * Return true if someone registers a table, this is used by testcase
91     * to figure out it SafeBrowsing.jsm is initialized.
92     */
93    boolean isRegistered();
94};
95