commit 97d317e8f6fe5b38341acc6274135396e20feb8c
parent feabba83768d5182873923896fe068e6ab3d03fb
Author: Mark Striemer <mstriemer@mozilla.com>
Date: Fri, 19 Dec 2025 04:14:16 +0000
Bug 2005797 - Part 1: Extract SettingGroupManager to its own module r=akulyk
The new AI features page looks like a good starting point for
configuring an entire pane through config. Extract the
SettingGroupManager to its own module so the AI features config can be
put into its own file.
Differential Revision: https://phabricator.services.mozilla.com/D276732
Diffstat:
3 files changed, 48 insertions(+), 35 deletions(-)
diff --git a/browser/components/preferences/config/SettingGroupManager.mjs b/browser/components/preferences/config/SettingGroupManager.mjs
@@ -0,0 +1,40 @@
+/* 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/. */
+
+/** @import {SettingGroupConfig} from "chrome://browser/content/preferences/widgets/setting-group.mjs" */
+
+export const SettingGroupManager = {
+ /** @type {Map<string, SettingGroupConfig>} */
+ _data: new Map(),
+
+ /**
+ * @param {string} id
+ */
+ get(id) {
+ if (!this._data.has(id)) {
+ throw new Error(`Setting group "${id}" not found`);
+ }
+ return this._data.get(id);
+ },
+
+ /**
+ * @param {string} id
+ * @param {SettingGroupConfig} config
+ */
+ registerGroup(id, config) {
+ if (this._data.has(id)) {
+ throw new Error(`Setting group "${id}" already registered`);
+ }
+ this._data.set(id, config);
+ },
+
+ /**
+ * @param {Record<string, SettingGroupConfig>} groupConfigs
+ */
+ registerGroups(groupConfigs) {
+ for (let id in groupConfigs) {
+ this.registerGroup(id, groupConfigs[id]);
+ }
+ },
+};
diff --git a/browser/components/preferences/jar.mn b/browser/components/preferences/jar.mn
@@ -25,6 +25,7 @@ browser.jar:
content/browser/preferences/web-appearance-light.svg
content/browser/preferences/etp-toggle-promo.svg
content/browser/preferences/etp-advanced-banner.svg
+ content/browser/preferences/config/SettingGroupManager.mjs (config/SettingGroupManager.mjs)
content/browser/preferences/widgets/dialog-button.mjs (widgets/dialog-button/dialog-button.mjs)
content/browser/preferences/widgets/placeholder-message.mjs (widgets/placeholder-message/placeholder-message.mjs)
content/browser/preferences/widgets/placeholder-message.css (widgets/placeholder-message/placeholder-message.css)
diff --git a/browser/components/preferences/preferences.js b/browser/components/preferences/preferences.js
@@ -18,7 +18,7 @@
/** @import MozButton from "chrome://global/content/elements/moz-button.mjs" */
/** @import {SettingConfig, SettingEmitChange} from "chrome://global/content/preferences/Setting.mjs" */
/** @import {SettingControlConfig} from "chrome://browser/content/preferences/widgets/setting-control.mjs" */
-/** @import {SettingGroup, SettingGroupConfig} from "chrome://browser/content/preferences/widgets/setting-group.mjs" */
+/** @import {SettingGroup} from "chrome://browser/content/preferences/widgets/setting-group.mjs" */
/** @import {SettingPane, SettingPaneConfig} from "chrome://browser/content/preferences/widgets/setting-pane.mjs" */
"use strict";
@@ -223,40 +223,12 @@ var SettingPaneManager = {
},
};
-var SettingGroupManager = {
- /** @type {Map<string, SettingGroupConfig>} */
- _data: new Map(),
-
- /**
- * @param {string} id
- */
- get(id) {
- if (!this._data.has(id)) {
- throw new Error(`Setting group "${id}" not found`);
- }
- return this._data.get(id);
- },
-
- /**
- * @param {string} id
- * @param {SettingGroupConfig} config
- */
- registerGroup(id, config) {
- if (this._data.has(id)) {
- throw new Error(`Setting group "${id}" already registered`);
- }
- this._data.set(id, config);
- },
-
- /**
- * @param {Record<string, SettingGroupConfig>} groupConfigs
- */
- registerGroups(groupConfigs) {
- for (let id in groupConfigs) {
- this.registerGroup(id, groupConfigs[id]);
- }
- },
-};
+var SettingGroupManager = ChromeUtils.importESModule(
+ "chrome://browser/content/preferences/config/SettingGroupManager.mjs",
+ {
+ global: "current",
+ }
+).SettingGroupManager;
/**
* Register initial config-based setting panes here. If you need to register a