diff options
Diffstat (limited to 'devtools/client/aboutdebugging/src/modules/debug-target-collapsibilities.js')
-rw-r--r-- | devtools/client/aboutdebugging/src/modules/debug-target-collapsibilities.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/src/modules/debug-target-collapsibilities.js b/devtools/client/aboutdebugging/src/modules/debug-target-collapsibilities.js new file mode 100644 index 0000000000..efba47e03a --- /dev/null +++ b/devtools/client/aboutdebugging/src/modules/debug-target-collapsibilities.js @@ -0,0 +1,46 @@ +/* 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"; + +const PREF_PREFIX = "devtools.aboutdebugging.collapsibilities."; +const { + DEBUG_TARGET_PANE, +} = require("resource://devtools/client/aboutdebugging/src/constants.js"); + +/** + * This module provides a collection of helper methods to read and update the debug + * target pane's collapsibilities. + */ + +/** + * @return {Object} + * { + * key: constants.DEBUG_TARGET_PANE + * value: true - collapsed + * false - expanded + * } + */ +function getDebugTargetCollapsibilities() { + const map = new Map(); + + for (const key of Object.values(DEBUG_TARGET_PANE)) { + const pref = Services.prefs.getBoolPref(PREF_PREFIX + key, false); + map.set(key, pref); + } + + return map; +} +exports.getDebugTargetCollapsibilities = getDebugTargetCollapsibilities; + +/** + * @param collapsibilities - Same format to getDebugTargetCollapsibilities. + */ +function setDebugTargetCollapsibilities(collapsibilities) { + for (const key of Object.values(DEBUG_TARGET_PANE)) { + const isCollapsed = collapsibilities.get(key); + Services.prefs.setBoolPref(PREF_PREFIX + key, isCollapsed); + } +} +exports.setDebugTargetCollapsibilities = setDebugTargetCollapsibilities; |