Classes | Defines | Typedefs | Enumerations | Functions

nsXULAppAPI.h File Reference

#include "prtypes.h"
#include "nsID.h"
#include "xrecore.h"
#include "nsXPCOM.h"
#include "nsISupports.h"
#include "prlog.h"
Include dependency graph for nsXULAppAPI.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  nsXREAppData
 Application-specific data needed to start the apprunner. More...

Defines

#define NS_XRE_ENABLE_PROFILE_MIGRATOR   (1 << 1)
 Indicates whether or not the profile migrator service may be invoked at startup when creating a profile.
#define NS_XRE_ENABLE_EXTENSION_MANAGER   (1 << 2)
 Indicates whether or not the extension manager service should be initialized at startup.
#define NS_XRE_ENABLE_CRASH_REPORTER   (1 << 3)
 Indicates whether or not to use Breakpad crash reporting.
#define XRE_USER_APP_DATA_DIR   "UAppData"
 A directory service key which provides the platform-correct "application data" directory as follows, where $name and $vendor are as defined above and $vendor is optional:
#define XRE_EXTENSIONS_DIR_LIST   "XREExtDL"
 A directory service key which provides a list of all enabled extension directories.
#define XRE_EXECUTABLE_FILE   "XREExeF"
 A directory service key which provides the executable file used to launch the current process.
#define NS_APP_PROFILE_DIR_STARTUP   "ProfDS"
 A directory service key which specifies the profile directory.
#define NS_APP_PROFILE_LOCAL_DIR_STARTUP   "ProfLDS"
 A directory service key which specifies the profile directory.
#define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR   "XRESysLExtPD"
 A directory service key which specifies the system extension parent directory containing platform-specific extensions.
#define XRE_SYS_SHARE_EXTENSION_PARENT_DIR   "XRESysSExtPD"
 A directory service key which specifies the system extension parent directory containing platform-independent extensions.
#define XRE_USER_SYS_EXTENSION_DIR   "XREUSysExt"
 A directory service key which specifies the user system extension parent directory.
#define XRE_APP_DISTRIBUTION_DIR   "XREAppDist"
 A directory service key which specifies the distribution specific files for the application.

Typedefs

typedef void(* MainFunction )(void *aData)

Enumerations

enum  NSLocationType { NS_COMPONENT_LOCATION, NS_SKIN_LOCATION }
 

Register XPCOM components found in an array of files/directories.

More...
enum  GeckoProcessType {
  GeckoProcessType_Default = 0, GeckoProcessType_Plugin, GeckoProcessType_Content, GeckoProcessType_Jetpack,
  GeckoProcessType_IPDLUnitTest, GeckoProcessType_End, GeckoProcessType_Invalid = GeckoProcessType_End
}

Functions

int XRE_main (int argc, char *argv[], const nsXREAppData *sAppData)
 Begin an XUL application.
nsresult XRE_GetFileFromPath (const char *aPath, nsILocalFile **aResult)
 Given a path relative to the current working directory (or an absolute path), return an appropriate nsILocalFile object.
nsresult XRE_GetBinaryPath (const char *argv0, nsILocalFile **aResult)
 Get the path of the running application binary and store it in aResult.
const mozilla::ModuleXRE_GetStaticModule ()
 Get the static module built in to libxul.
nsresult XRE_LockProfileDirectory (nsILocalFile *aDirectory, nsISupports **aLockObject)
 Lock a profile directory using platform-specific semantics.
nsresult XRE_InitEmbedding2 (nsILocalFile *aLibXULDirectory, nsILocalFile *aAppDirectory, nsIDirectoryServiceProvider *aAppDirProvider)
 Initialize libXUL for embedding purposes.
nsresult XRE_AddStaticComponent (const mozilla::Module *aComponent)
 Register static XPCOM component information.
nsresult XRE_AddManifestLocation (NSLocationType aType, nsILocalFile *aLocation)
nsresult XRE_AddJarManifestLocation (NSLocationType aType, nsILocalFile *aLocation)
 Register XPCOM components found in a JAR.
void XRE_NotifyProfile ()
 Fire notifications to inform the toolkit about a new profile.
void XRE_TermEmbedding ()
 Terminate embedding started with XRE_InitEmbedding or XRE_InitEmbedding2.
nsresult XRE_CreateAppData (nsILocalFile *aINIFile, nsXREAppData **aAppData)
 Create a new nsXREAppData structure from an application.ini file.
nsresult XRE_ParseAppData (nsILocalFile *aINIFile, nsXREAppData *aAppData)
 Parse an INI file (application.ini or override.ini) into an existing nsXREAppData structure.
void XRE_FreeAppData (nsXREAppData *aAppData)
 Free a nsXREAppData structure that was allocated with XRE_CreateAppData.
void pr_static_assert (int arg[(sizeof(kGeckoProcessTypeString)/sizeof(kGeckoProcessTypeString[0])==GeckoProcessType_End)?1:-1])
const char * XRE_ChildProcessTypeToString (GeckoProcessType aProcessType)
GeckoProcessType XRE_StringToChildProcessType (const char *aProcessTypeString)
nsresult XRE_InitChildProcess (int aArgc, char *aArgv[], GeckoProcessType aProcess)
GeckoProcessType XRE_GetProcessType ()
nsresult XRE_InitParentProcess (int aArgc, char *aArgv[], MainFunction aMainFunction, void *aMainFunctionExtraData)
int XRE_RunIPDLTest (int aArgc, char *aArgv[])
nsresult XRE_RunAppShell ()
nsresult XRE_InitCommandLine (int aArgc, char *aArgv[])
nsresult XRE_DeinitCommandLine ()
void XRE_ShutdownChildProcess ()
MessageLoop * XRE_GetIOMessageLoop ()
bool XRE_SendTestShellCommand (JSContext *aCx, JSString *aCommand, void *aCallback)
bool XRE_GetChildGlobalObject (JSContext *aCx, JSObject **globalp)
bool XRE_ShutdownTestShell ()
void XRE_InstallX11ErrorHandler ()

Define Documentation

#define NS_APP_PROFILE_DIR_STARTUP   "ProfDS"

A directory service key which specifies the profile directory.

Unlike the NS_APP_USER_PROFILE_50_DIR key, this key may be available when the profile hasn't been "started", or after is has been shut down. If the application is running without a profile, such as when showing the profile manager UI, this key will not be available. This key is provided by the XUL apprunner or by the aAppDirProvider object passed to XRE_InitEmbedding.

#define NS_APP_PROFILE_LOCAL_DIR_STARTUP   "ProfLDS"

A directory service key which specifies the profile directory.

Unlike the NS_APP_USER_PROFILE_LOCAL_50_DIR key, this key may be available when the profile hasn't been "started", or after is has been shut down. If the application is running without a profile, such as when showing the profile manager UI, this key will not be available. This key is provided by the XUL apprunner or by the aAppDirProvider object passed to XRE_InitEmbedding.

#define NS_XRE_ENABLE_CRASH_REPORTER   (1 << 3)

Indicates whether or not to use Breakpad crash reporting.

#define NS_XRE_ENABLE_EXTENSION_MANAGER   (1 << 2)

Indicates whether or not the extension manager service should be initialized at startup.

#define NS_XRE_ENABLE_PROFILE_MIGRATOR   (1 << 1)

Indicates whether or not the profile migrator service may be invoked at startup when creating a profile.

#define XRE_APP_DISTRIBUTION_DIR   "XREAppDist"

A directory service key which specifies the distribution specific files for the application.

#define XRE_EXECUTABLE_FILE   "XREExeF"

A directory service key which provides the executable file used to launch the current process.

This is the same value returned by the XRE_GetBinaryPath function defined below.

#define XRE_EXTENSIONS_DIR_LIST   "XREExtDL"

A directory service key which provides a list of all enabled extension directories.

The list includes compatible platform-specific extension subdirectories.

Note:
The directory list will have no members when the application is launched in safe mode.
#define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR   "XRESysLExtPD"

A directory service key which specifies the system extension parent directory containing platform-specific extensions.

This key may not be available on all platforms.

#define XRE_SYS_SHARE_EXTENSION_PARENT_DIR   "XRESysSExtPD"

A directory service key which specifies the system extension parent directory containing platform-independent extensions.

This key may not be available on all platforms. Additionally, the directory may be equal to that returned by XRE_SYS_LOCAL_EXTENSION_PARENT_DIR on some platforms.

#define XRE_USER_APP_DATA_DIR   "UAppData"

A directory service key which provides the platform-correct "application data" directory as follows, where $name and $vendor are as defined above and $vendor is optional:

Windows: HOME = Documents and Settings$USER Data UAppData = $HOME[$vendor]$name

Unix: HOME = ~ UAppData = $HOME/.[$vendor/]$name

Mac: HOME = ~ UAppData = $HOME/Library/Application Support/$name

Note that the "profile" member above will change the value of UAppData as follows:

Windows: UAppData = $HOME$profile

Unix: UAppData = $HOME/.$profile

Mac: UAppData = $HOME/Library/Application Support/$profile

#define XRE_USER_SYS_EXTENSION_DIR   "XREUSysExt"

A directory service key which specifies the user system extension parent directory.


Typedef Documentation

typedef void(* MainFunction)(void *aData)

Enumeration Type Documentation

Enumerator:
GeckoProcessType_Default 
GeckoProcessType_Plugin 
GeckoProcessType_Content 
GeckoProcessType_Jetpack 
GeckoProcessType_IPDLUnitTest 
GeckoProcessType_End 
GeckoProcessType_Invalid 

Register XPCOM components found in an array of files/directories.

This method may be called at any time before or after XRE_main or XRE_InitEmbedding.

Parameters:
aFiles An array of files or directories.
aFileCount the number of items in the aFiles array.
Note:
appdir/components is registered automatically.

NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM components as well as component/chrome manifest files.

NS_SKIN_LOCATION specifies a location to search for chrome manifest files which are only allowed to register only skin packages and style overlays.

Enumerator:
NS_COMPONENT_LOCATION 
NS_SKIN_LOCATION 

Function Documentation

void pr_static_assert ( int  arg[(sizeof(kGeckoProcessTypeString)/sizeof(kGeckoProcessTypeString[0]  ) 
nsresult XRE_AddJarManifestLocation ( NSLocationType  aType,
nsILocalFile aLocation 
)

Register XPCOM components found in a JAR.

This is similar to XRE_AddManifestLocation except the file specified must be a zip archive with a manifest named chrome.manifest This method may be called at any time before or after XRE_main or XRE_InitEmbedding.

Parameters:
aFiles An array of files or directories.
aFileCount the number of items in the aFiles array.
Note:
appdir/components is registered automatically.

NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM components as well as component/chrome manifest files.

NS_SKIN_LOCATION specifies a location to search for chrome manifest files which are only allowed to register only skin packages and style overlays.

nsresult XRE_AddManifestLocation ( NSLocationType  aType,
nsILocalFile aLocation 
)
nsresult XRE_AddStaticComponent ( const mozilla::Module aComponent  ) 

Register static XPCOM component information.

This method may be called at any time before or after XRE_main or XRE_InitEmbedding.

const char* XRE_ChildProcessTypeToString ( GeckoProcessType  aProcessType  ) 
nsresult XRE_CreateAppData ( nsILocalFile aINIFile,
nsXREAppData **  aAppData 
)

Create a new nsXREAppData structure from an application.ini file.

Parameters:
aINIFile The application.ini file to parse.
aAppData A newly-allocated nsXREAppData structure. The caller is responsible for freeing this structure using XRE_FreeAppData.
nsresult XRE_DeinitCommandLine (  ) 
void XRE_FreeAppData ( nsXREAppData aAppData  ) 

Free a nsXREAppData structure that was allocated with XRE_CreateAppData.

nsresult XRE_GetBinaryPath ( const char *  argv0,
nsILocalFile **  aResult 
)

Get the path of the running application binary and store it in aResult.

Parameters:
argv0 The value passed as argv[0] of main(). This value is only used on *nix, and only when other methods of determining the binary path have failed.
bool XRE_GetChildGlobalObject ( JSContext aCx,
JSObject **  globalp 
)
nsresult XRE_GetFileFromPath ( const char *  aPath,
nsILocalFile **  aResult 
)

Given a path relative to the current working directory (or an absolute path), return an appropriate nsILocalFile object.

Note:
Pass UTF8 strings on Windows... native charset on other platforms.
MessageLoop* XRE_GetIOMessageLoop (  ) 
GeckoProcessType XRE_GetProcessType (  ) 
const mozilla::Module* XRE_GetStaticModule (  ) 

Get the static module built in to libxul.

nsresult XRE_InitChildProcess ( int  aArgc,
char *  aArgv[],
GeckoProcessType  aProcess 
)
nsresult XRE_InitCommandLine ( int  aArgc,
char *  aArgv[] 
)
nsresult XRE_InitEmbedding2 ( nsILocalFile aLibXULDirectory,
nsILocalFile aAppDirectory,
nsIDirectoryServiceProvider aAppDirProvider 
)

Initialize libXUL for embedding purposes.

Parameters:
aLibXULDirectory The directory in which the libXUL shared library was found.
aAppDirectory The directory in which the application components and resources can be found. This will map to the NS_OS_CURRENT_PROCESS_DIR directory service key.
aAppDirProvider A directory provider for the application. This provider will be aggregated by a libxul provider which will provide the base required GRE keys.
Note:
This function must be called from the "main" thread.
At the present time, this function may only be called once in a given process. Use XRE_TermEmbedding to clean up and free resources allocated by XRE_InitEmbedding.
nsresult XRE_InitParentProcess ( int  aArgc,
char *  aArgv[],
MainFunction  aMainFunction,
void *  aMainFunctionExtraData 
)
void XRE_InstallX11ErrorHandler (  ) 
nsresult XRE_LockProfileDirectory ( nsILocalFile aDirectory,
nsISupports **  aLockObject 
)

Lock a profile directory using platform-specific semantics.

Parameters:
aDirectory The profile directory to lock.
aLockObject An opaque lock object. The directory will remain locked as long as the XPCOM reference is held.
int XRE_main ( int  argc,
char *  argv[],
const nsXREAppData sAppData 
)

Begin an XUL application.

Does not return until the user exits the application.

Parameters:
argc/argv Command-line parameters to pass to the application. On Windows, these should be in UTF8. On unix-like platforms these are in the "native" character set.
aAppData Information about the application to be run.
Returns:
A native result code suitable for returning from main().
Note:
If the binary is linked against the standalone XPCOM glue, XPCOMGlueStartup() should be called before this method.
void XRE_NotifyProfile (  ) 

Fire notifications to inform the toolkit about a new profile.

This method should be called after XRE_InitEmbedding if the embedder wishes to run with a profile. Normally the embedder should call XRE_LockProfileDirectory to lock the directory before calling this method.

Note:
There are two possibilities for selecting a profile:

1) Select the profile before calling XRE_InitEmbedding. The aAppDirProvider object passed to XRE_InitEmbedding should provide the NS_APP_USER_PROFILE_50_DIR key, and may also provide the following keys:

  • NS_APP_USER_PROFILE_LOCAL_50_DIR
  • NS_APP_PROFILE_DIR_STARTUP
  • NS_APP_PROFILE_LOCAL_DIR_STARTUP In this scenario XRE_NotifyProfile should be called immediately after XRE_InitEmbedding. Component registration information will be stored in the profile and JS components may be stored in the fastload cache.

2) Select a profile some time after calling XRE_InitEmbedding. In this case the embedder must install a directory service provider which provides NS_APP_USER_PROFILE_50_DIR and optionally NS_APP_USER_PROFILE_LOCAL_50_DIR. Component registration information will be stored in the application directory and JS components will not fastload.

nsresult XRE_ParseAppData ( nsILocalFile aINIFile,
nsXREAppData aAppData 
)

Parse an INI file (application.ini or override.ini) into an existing nsXREAppData structure.

Parameters:
aINIFile The INI file to parse
aAppData The nsXREAppData structure to fill.
nsresult XRE_RunAppShell (  ) 
int XRE_RunIPDLTest ( int  aArgc,
char *  aArgv[] 
)
bool XRE_SendTestShellCommand ( JSContext aCx,
JSString aCommand,
void *  aCallback 
)
void XRE_ShutdownChildProcess (  ) 
bool XRE_ShutdownTestShell (  ) 
GeckoProcessType XRE_StringToChildProcessType ( const char *  aProcessTypeString  ) 
void XRE_TermEmbedding (  ) 

Terminate embedding started with XRE_InitEmbedding or XRE_InitEmbedding2.