Skip to content

Commit 474e96c

Browse files
committed
Prompt the user to restart if the extension requires it.
1 parent 0ca66b1 commit 474e96c

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

bootstrap.js

+32-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function onClickHanlder(ev) {
125125
zipWriter.close();
126126

127127
AddonManager.getInstallForFile(oFile,aInstall => {
128-
let done = (aMsg) => {
128+
let done = (aMsg,aAddon) => {
129129
let c = 'check';
130130
if(typeof aMsg === 'number') {
131131
l.textContent = 'Error ' + aMsg;
@@ -137,7 +137,36 @@ function onClickHanlder(ev) {
137137
}
138138
f.style.animation = null;
139139
f.className = f.className.replace('hourglass',c);
140-
iNotify(aMsg, () => oFile.remove(!1));
140+
iNotify(aMsg, () => {
141+
oFile.remove(!1);
142+
143+
if(aAddon && aAddon.pendingOperations) {
144+
let m = aAddon.name + ' requires restart.\n\n'
145+
+ 'Would you like to restart '
146+
+ Services.appinfo.name + ' now?';
147+
148+
m = Services.prompt.confirmEx(null,
149+
addon.name,m,1027,0,0,0,null,{});
150+
151+
if(!m) {
152+
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
153+
.createInstance(Ci.nsISupportsPRBool);
154+
155+
Services.obs.notifyObservers(cancelQuit,
156+
"quit-application-requested", null);
157+
158+
if(!cancelQuit.data) {
159+
Services.obs.notifyObservers(null,
160+
"quit-application-granted", null);
161+
162+
Services.startup.quit(
163+
Ci.nsIAppStartup.eAttemptQuit |
164+
Ci.nsIAppStartup.eRestart
165+
);
166+
}
167+
}
168+
}
169+
});
141170
};
142171

143172
aInstall.addListener({
@@ -150,7 +179,7 @@ function onClickHanlder(ev) {
150179
aInstall.removeListener(this);
151180

152181
done(aAddon.name + ' ' + aAddon.version
153-
+ ' has been installed successfully.');
182+
+ ' has been installed successfully.',aAddon);
154183
}
155184
});
156185
aInstall.install();

0 commit comments

Comments
 (0)