There's currently no "one true way" how to restart a Toolkit application (see bug 335864 comment #11). Why not add a goRestartApplication method which does whatever necessary for a restart - similar to the existing goQuitApplication for quitting? This might prevent some duplicated code and prevent extensions from accidentally omitting the call to canQuitApplication on which other extensions do rely.
Created attachment 222080 [details] [diff] [review] goRestartApplication as a convenience wrapper for goQuitApplication
Comment on attachment 222080 [details] [diff] [review] goRestartApplication as a convenience wrapper for goQuitApplication >Index: toolkit/content/globalOverlay.js >+ var nsIAppStartup = Components.interfaces.nsIAppStartup; const nsIAppStartup? >+ var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'] >+ .getService(nsIAppStartup); >+ appStartup.quit(aFlags || nsIAppStartup.eAttemptQuit); Why not just extend goQuitApplication(true) to mean restart? mconnor should review this.
Created attachment 222232 [details] [diff] [review] goRestartApplication as a convenience wrapper for goQuitApplication (In reply to comment #2) > Why not just extend goQuitApplication(true) to mean restart? For one, because I don't feel psychic enough to know that we'll never have a third reason/way of shutting down - and for the other that a boolean pref on a method called quitApplication simply doesn't look right (I'd rather expect it to mean: force-quit as opposed to just try-to-quit). And of course, because goRestartApplication is simply easier to understand when used in the code.
Rather a case for FUEL now. -> WONTFIX
Is there a fuel bug about this?
I don't know. If there isn't, maybe there's really no demand for such functionality at all...
I've seen the question about this asked quite a few times, so I think there is. CCing mfinkle to comment on this.
Application.quit() and Application.restart() sound like good additions to FUEL. I agree that there is not enough emphasis on shutting down correctly using the "canQuitApplication" method. Unfortunately, FUEL is not in toolkit yet.
Created attachment 335742 [details] [diff] [review] Application.quit() and Application.restart() This should be the "one true way" of quitting/restarting any toolkit app. The question remains whether goQuitApplication should just wrap Application.quit(), whether it should go away completely (together with canQuitApplication) or whether it should remain untouched.
So is this a single simple way to quit/restart from any code (chrome or js component)?
(In reply to comment #11) You could even use this from C++ through XPCOM, so yeah, it'll work from anywhere.
It would be a good idea to specify what "if nobody objects" means in the IDL, I think (i.e. mention quit-application-requested).
Created attachment 336237 [details] [diff] [review] for check-in (In reply to comment #13) Sure.
aSubject instanceof Components.interfaces.nsISupportsBoolean should be: aSubject instanceof Components.interfaces.nsISupportsPRBool
Tests pass with that change
Created attachment 336250 [details] [diff] [review] for check-in (with passing tests) Ugh, that's embarrassing. Thanks for catching this, Mark!