Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. // Derived from chrome://mozapps/content/extensions/extensions.js
  2.  
  3. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  4.  
  5. // Notify all windows that an application quit has been requested.
  6. var os = Components.classes["@mozilla.org/observer-service;1"]
  7. .getService(Components.interfaces.nsIObserverService);
  8. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  9. .createInstance(Components.interfaces.nsISupportsPRBool);
  10. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  11.  
  12. // Something aborted the quit process.
  13. if (cancelQuit.data)
  14. return;
  15.  
  16. // Notify all windows that an application quit has been granted.
  17. os.notifyObservers(null, "quit-application-granted", null);
  18.  
  19. // Enumerate all windows and call shutdown handlers
  20. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  21. .getService(Components.interfaces.nsIWindowMediator);
  22. var windows = wm.getEnumerator(null);
  23. while (windows.hasMoreElements()) {
  24. var win = windows.getNext();
  25. if (("tryToClose" in win) && !win.tryToClose())
  26. return;
  27. }
  28. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  29. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement