forked from downthemall/downthemall-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
53 lines (48 loc) · 1.48 KB
/
bootstrap.js
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
/* 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";
/* global Services:true, APP_SHUTDOWN, ADDON_UPGRADE */
const {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
const {AddonManager} = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
function flush() {
//Drop XUL/XBL/JAR/CSS/etc caches
Services.obs.notifyObservers(null, "chrome-flush-caches", null);
}
function install() {}
function uninstall() {
flush();
}
function startup(data) {
// will unload itself
let _g = {};
Components.utils.import("chrome://dta-modules/content/glue.jsm", _g);
if (AddonManager.addUpgradeListener && data.instanceID) {
AddonManager.addUpgradeListener(data.instanceID, upgrade => {
if (_g.canUnload()) {
upgrade.install();
}
else {
_g.unload("eventual-shutdown", upgrade);
}
});
}
}
function shutdown(data, reason) {
if (AddonManager.addUpgradeListener && data.instanceID) {
try {
AddonManager.removeUpgradeListener(data.instanceID);
}
catch (ex) {
// oh well...
}
}
if (reason === APP_SHUTDOWN) {
// No need to cleanup; stuff will vanish anyway
return;
}
let _g = {};
Components.utils.import("chrome://dta-modules/content/glue.jsm", _g);
_g.unload("shutdown", reason === ADDON_UPGRADE);
Components.utils.unload("chrome://dta-modules/content/glue.jsm");
}