diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/components/doh/DoHConfig.jsm | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/components/doh/DoHConfig.jsm | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/browser/components/doh/DoHConfig.jsm b/browser/components/doh/DoHConfig.jsm new file mode 100644 index 0000000000..1c3852bab9 --- /dev/null +++ b/browser/components/doh/DoHConfig.jsm @@ -0,0 +1,76 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* + * This module provides an interface to acces DoH config settings - e.g. whether + * DoH is enabled, whether capabilities are enabled, etc. Currently this just + * provides getters for prefs, but imminently will be extended to read config + * from a Remote Settings collection and filter by client region etc. + */ +var EXPORTED_SYMBOLS = ["Config"]; + +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + +ChromeUtils.defineModuleGetter( + this, + "Preferences", + "resource://gre/modules/Preferences.jsm" +); + +const kEnabledPref = "doh-rollout.enabled"; + +const kTRRSelectionEnabledPref = "doh-rollout.trr-selection.enabled"; +const kTRRSelectionCommitResultPref = "doh-rollout.trr-selection.commit-result"; + +const kProviderSteeringEnabledPref = "doh-rollout.provider-steering.enabled"; +const kProviderSteeringListPref = "doh-rollout.provider-steering.provider-list"; + +const kPrefChangedTopic = "nsPref:changed"; + +const Config = { + init() { + Preferences.observe(kEnabledPref, this); + }, + + observe(subject, topic, data) { + switch (topic) { + case kPrefChangedTopic: + this.notifyNewConfig(); + break; + } + }, + + kConfigUpdateTopic: "doh-config-updated", + notifyNewConfig() { + Services.obs.notifyObservers(null, this.kConfigUpdateTopic); + }, + + get enabled() { + return Preferences.get(kEnabledPref, false); + }, + + trrSelection: { + get enabled() { + return Preferences.get(kTRRSelectionEnabledPref, false); + }, + + get commitResult() { + return Preferences.get(kTRRSelectionCommitResultPref, false); + }, + }, + + providerSteering: { + get enabled() { + return Preferences.get(kProviderSteeringEnabledPref, false); + }, + + get providerList() { + return Preferences.get(kProviderSteeringListPref, "[]"); + }, + }, +}; + +Config.init(); |