Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Derived from chrome://mozapps/content/extensions/extensions.js
- const nsIAppStartup = Components.interfaces.nsIAppStartup;
- // Notify all windows that an application quit has been requested.
- var os = Components.classes["@mozilla.org/observer-service;1"]
- .getService(Components.interfaces.nsIObserverService);
- var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
- .createInstance(Components.interfaces.nsISupportsPRBool);
- os.notifyObservers(cancelQuit, "quit-application-requested", null);
- // Something aborted the quit process.
- if (cancelQuit.data)
- return;
- // Notify all windows that an application quit has been granted.
- os.notifyObservers(null, "quit-application-granted", null);
- // Enumerate all windows and call shutdown handlers
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var windows = wm.getEnumerator(null);
- while (windows.hasMoreElements()) {
- var win = windows.getNext();
- if (("tryToClose" in win) && !win.tryToClose())
- return;
- }
- Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
- .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement