blob: 79343f3004132530fb931703e7820cb450f9e33b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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;
}
|