Skip to content
Snippets Groups Projects
Commit e7da6e7c authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 31740: Remove some unnecessary RemoteSettings instances

Bug 40788: Tor Browser is phoning home

The hijack-list component is the only remaining one calling home.
This is a temporary workaround, to use the remote settings.

We should do something like this commit at a more generic level, for all
RemoteSettings users.


(cherry picked from commit 2a2e87c3)
parent 566eaec6
No related branches found
No related tags found
No related merge requests found
......@@ -8,19 +8,19 @@ const { XPCOMUtils } = ChromeUtils.import(
);
XPCOMUtils.defineLazyModuleGetters(this, {
RemoteSettings: "resource://services-settings/remote-settings.js",
RemoteSettingsClient: "resource://services-settings/RemoteSettingsClient.jsm",
});
var EXPORTED_SYMBOLS = ["IgnoreLists"];
Cu.importGlobalProperties(["fetch"]);
const SETTINGS_IGNORELIST_KEY = "hijack-blocklists";
var EXPORTED_SYMBOLS = ["IgnoreLists"];
class IgnoreListsManager {
_ignoreListSettings = null;
async init() {
if (!this._ignoreListSettings) {
this._ignoreListSettings = RemoteSettings(SETTINGS_IGNORELIST_KEY);
}
// TODO: Restore the initialization, once we use only the local dumps for
// the remote settings.
}
async getAndSubscribe(listener) {
......@@ -30,7 +30,7 @@ class IgnoreListsManager {
const settings = await this._getIgnoreList();
// Listen for future updates after we first get the values.
this._ignoreListSettings.on("sync", listener);
this._ignoreListSettings?.on("sync", listener);
return settings;
}
......@@ -70,6 +70,14 @@ class IgnoreListsManager {
* could be obtained.
*/
async _getIgnoreListSettings(firstTime = true) {
if (!this._ignoreListSettings) {
const dump = await fetch(
"resource:///defaults/settings/main/hijack-blocklists.json"
);
const { data } = await dump.json();
return data;
}
let result = [];
try {
result = await this._ignoreListSettings.get({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment