nsISupports
Last changed in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)Implemented by: @mozilla.org/toolkit/app-startup;1
. To use the service:
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1
"]
.getService(Components.interfaces.nsIAppStartup);
void createHiddenWindow(); |
boolean createStartupState(in long aWindowWidth, in long aWindowHeight); Obsolete since Gecko 1.9.1 |
void destroyHiddenWindow(); |
void doProfileStartup(in nsICmdLineService aCmdLineService, in boolean canInteract); Obsolete since Gecko 1.9.1 |
void ensure1Window(in nsICmdLineService aCmdLineService); Obsolete since Gecko 1.9.1 |
void enterLastWindowClosingSurvivalArea(); |
void exitLastWindowClosingSurvivalArea(); |
void getStartupInfo(); |
void hideSplashScreen(); Obsolete since Gecko 1.9.1 |
void initialize(in nsISupports nativeAppSupportOrSplashScreen); Obsolete since Gecko 1.9.1 |
void quit(in PRUint32 aMode); |
void restartInSafeMode(in PRUint32 aQuitMode); |
void run(); |
Attribute | Type | Description |
interrupted |
boolean |
true if the startup process was interrupted by an interactive prompt. This can be used, for example, when doing performance testing of the startup process to discount numbers for tests that were interrupted by a user prompt. |
nativeAppSupport |
|
Getter for "native application support." Read only. Obsolete since Gecko 1.9.1 |
The following flags may be passed as the aMode
parameter to the quit()
method. One and only one of the "Quit" flags must be specified. The eRestart
flag may be bit-wise combined with one of the "Quit" flags to cause the application to restart after it quits.
Constant | Value | Description |
eConsiderQuit |
0x01 | Attempt to quit if all windows are closed. |
eAttemptQuit |
0x02 | Try to close all windows, then quit if successful. |
eForceQuit |
0x03 | Force all windows to close, then quit. |
eRestart |
0x10 | Restart the application after quitting. The application will be restarted with the same profile and an empty command line. |
eRestartNotSameProfile |
0x100 | Restart the application after quitting. The application will be restarted with an empty command line and the normal profile selection process will take place on startup. |
Create the hidden window.
void createHiddenWindow();
None.
Creates the initial state of the application by launching tasks specfied by "general.startup.*" prefs.
boolean createStartupState( in long aWindowWidth, in long aWindowHeight );
aWindowWidth
aWindowHeight
TRUE
if a window was opened.
Destroys the hidden window. This will have no effect if the hidden window has not yet been created.
void destroyHiddenWindow();
None.
Starts up the profile manager with the given arguments.
void doProfileStartup( in nsICmdLineService aCmdLineService, in boolean canInteract );
aCmdLineService
canInteract
FALSE
and UI is needed, will fail.Ensures that at least one window exists after creating the startup state. If one has not been made, this will create a browser window.
void ensure1Window( in nsICmdLineService aCmdLineService );
aCmdLineService
Serves for situations when all application windows will be closed but we don't want to take this as a signal to quit the application. Bracket the code where the last window could close with these.
void enterLastWindowClosingSurvivalArea();
None.
This method serves for situations when all application windows will be closed but we don't want to take this as a signal to quit the application. Bracket the code where the last window could close with these.
void exitLastWindowClosingSurvivalArea();
None.
Returns a JavaScript object with events from startup and the timestamps indicating when they occurred.
None.
A JavaScript object with the following fields. Keys are the event names and their values are the times. Events that didn't occur are not in the object.
Event identifier (key) | Description |
---|---|
main |
Time at which main application core was loaded. Note: Only available with libxul builds.
|
firstPaint |
Time the first paint occurred. Note: Only available with libxul builds.
|
sessionRestored |
Time session restore finished. |
This example logs startup time information to the console.
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"] .getService(Components.interfaces.nsIConsoleService); var startupInfo = Components.classes["@mozilla.org/toolkit/app-startup;1"] .getService(Ci.nsIAppStartup_MOZILLA_2_0).getStartupInfo(); var keys = Object.keys(startupInfo); keys.sort(function(a, b) { return startupInfo[a] - startupInfo[b]; }); for each (var name in keys) { aConsoleService.logStringMessage(name + ": " + startupInfo[name]); }
To calculate how long startup took, compute the difference between the event's timestamp and the timestamp of the process
event.
Remove the splash screen (if visible). This need be called only once per application session.
void hideSplashScreen();
None.
Required initialization routine.
void initialize( in nsISupports nativeAppSupportOrSplashScreen );
nativeAppSupportOrSplashScreen
nsINativeAppSupport
or nsISplashScreen
; this object will be used to implement HideSplashScreen.Exit the event loop, and shut down the application.
void quit( in PRUint32 aMode );
aMode
Restart the application in safe mode.
void quit( in PRUint32 aQuitMode );
aQuitMode
Runs an application event loop: normally the main event pump which defines the lifetime of the application. If there are no windows open and no outstanding calls to enterLastWindowClosingSurvivalArea()
this method will exit immediately.
void run();
None.
Returns NS_SUCCESS_RESTART_APP
code. This return code indicates that the application should be restarted because quit was called with the eRestart
flag.