diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/base/content/troubleshootMode.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | comm/mail/base/content/troubleshootMode.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/comm/mail/base/content/troubleshootMode.js b/comm/mail/base/content/troubleshootMode.js new file mode 100644 index 0000000000..79343f3004 --- /dev/null +++ b/comm/mail/base/content/troubleshootMode.js @@ -0,0 +1,74 @@ +/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +var { XPIDatabase } = ChromeUtils.import( + "resource://gre/modules/addons/XPIDatabase.jsm" +); + +function restartApp() { + Services.startup.quit( + Services.startup.eForceQuit | Services.startup.eRestart + ); +} + +function deleteLocalstore() { + // Delete the xulstore file. + let xulstoreFile = Services.dirsvc.get("ProfD", Ci.nsIFile); + xulstoreFile.append("xulstore.json"); + if (xulstoreFile.exists()) { + xulstoreFile.remove(false); + } +} + +async function disableAddons() { + XPIDatabase.syncLoadDB(false); + let addons = XPIDatabase.getAddons(); + for (let addon of addons) { + if (addon.type == "theme") { + // Setting userDisabled to false on the default theme activates it, + // disables all other themes and deactivates the applied persona, if + // any. + const DEFAULT_THEME_ID = "default-theme@mozilla.org"; + if (addon.id == DEFAULT_THEME_ID) { + await XPIDatabase.updateAddonDisabledState(addon, { + userDisabled: false, + }); + } + } else { + await XPIDatabase.updateAddonDisabledState(addon, { userDisabled: true }); + } + } +} + +async function onOK(event) { + event.preventDefault(); + if (document.getElementById("resetToolbars").checked) { + deleteLocalstore(); + } + if (document.getElementById("disableAddons").checked) { + await disableAddons(); + } + restartApp(); +} + +function onCancel() { + Services.startup.quit(Services.startup.eForceQuit); +} + +function onLoad() { + document + .getElementById("tasks") + .addEventListener("CheckboxStateChange", updateOKButtonState); + + document.addEventListener("dialogaccept", onOK); + document.addEventListener("dialogcancel", onCancel); + document.addEventListener("dialogextra1", () => window.close()); +} + +function updateOKButtonState() { + document.querySelector("dialog").getButton("accept").disabled = + !document.getElementById("resetToolbars").checked && + !document.getElementById("disableAddons").checked; +} |