xpcom/build/nsXULAppAPI.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/build/nsXULAppAPI.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,470 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _nsXULAppAPI_h__
    1.10 +#define _nsXULAppAPI_h__
    1.11 +
    1.12 +#include "nsID.h"
    1.13 +#include "xrecore.h"
    1.14 +#include "nsXPCOM.h"
    1.15 +#include "nsISupports.h"
    1.16 +#include "prlog.h"
    1.17 +#include "nsXREAppData.h"
    1.18 +#include "js/TypeDecls.h"
    1.19 +
    1.20 +#include "mozilla/ArrayUtils.h"
    1.21 +#include "mozilla/Assertions.h"
    1.22 +
    1.23 +/**
    1.24 + * A directory service key which provides the platform-correct "application
    1.25 + * data" directory as follows, where $name and $vendor are as defined above and
    1.26 + * $vendor is optional:
    1.27 + *
    1.28 + * Windows:
    1.29 + *   HOME = Documents and Settings\$USER\Application Data
    1.30 + *   UAppData = $HOME[\$vendor]\$name
    1.31 + *
    1.32 + * Unix:
    1.33 + *   HOME = ~
    1.34 + *   UAppData = $HOME/.[$vendor/]$name
    1.35 + *
    1.36 + * Mac:
    1.37 + *   HOME = ~
    1.38 + *   UAppData = $HOME/Library/Application Support/$name
    1.39 + *
    1.40 + * Note that the "profile" member above will change the value of UAppData as
    1.41 + * follows:
    1.42 + *
    1.43 + * Windows:
    1.44 + *   UAppData = $HOME\$profile
    1.45 + *
    1.46 + * Unix:
    1.47 + *   UAppData = $HOME/.$profile
    1.48 + *
    1.49 + * Mac:
    1.50 + *   UAppData = $HOME/Library/Application Support/$profile
    1.51 + */
    1.52 +#define XRE_USER_APP_DATA_DIR "UAppData"
    1.53 +
    1.54 +/**
    1.55 + * A directory service key which provides a list of all enabled extension
    1.56 + * directories and files (packed XPIs).  The list includes compatible
    1.57 + * platform-specific extension subdirectories.
    1.58 + *
    1.59 + * @note The directory list will have no members when the application is
    1.60 + *       launched in safe mode.
    1.61 + */
    1.62 +#define XRE_EXTENSIONS_DIR_LIST "XREExtDL"
    1.63 +
    1.64 +/**
    1.65 + * A directory service key which provides the executable file used to
    1.66 + * launch the current process.  This is the same value returned by the
    1.67 + * XRE_GetBinaryPath function defined below.
    1.68 + */
    1.69 +#define XRE_EXECUTABLE_FILE "XREExeF"
    1.70 +
    1.71 +/**
    1.72 + * A directory service key which specifies the profile
    1.73 + * directory. Unlike the NS_APP_USER_PROFILE_50_DIR key, this key may
    1.74 + * be available when the profile hasn't been "started", or after is
    1.75 + * has been shut down. If the application is running without a
    1.76 + * profile, such as when showing the profile manager UI, this key will
    1.77 + * not be available. This key is provided by the XUL apprunner or by
    1.78 + * the aAppDirProvider object passed to XRE_InitEmbedding.
    1.79 + */
    1.80 +#define NS_APP_PROFILE_DIR_STARTUP "ProfDS"
    1.81 +
    1.82 +/**
    1.83 + * A directory service key which specifies the profile
    1.84 + * directory. Unlike the NS_APP_USER_PROFILE_LOCAL_50_DIR key, this key may
    1.85 + * be available when the profile hasn't been "started", or after is
    1.86 + * has been shut down. If the application is running without a
    1.87 + * profile, such as when showing the profile manager UI, this key will
    1.88 + * not be available. This key is provided by the XUL apprunner or by
    1.89 + * the aAppDirProvider object passed to XRE_InitEmbedding.
    1.90 + */
    1.91 +#define NS_APP_PROFILE_LOCAL_DIR_STARTUP "ProfLDS"
    1.92 +
    1.93 +/**
    1.94 + * A directory service key which specifies the system extension
    1.95 + * parent directory containing platform-specific extensions.
    1.96 + * This key may not be available on all platforms.
    1.97 + */
    1.98 +#define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR "XRESysLExtPD"
    1.99 +
   1.100 +/**
   1.101 + * A directory service key which specifies the system extension
   1.102 + * parent directory containing platform-independent extensions.
   1.103 + * This key may not be available on all platforms.
   1.104 + * Additionally, the directory may be equal to that returned by
   1.105 + * XRE_SYS_LOCAL_EXTENSION_PARENT_DIR on some platforms.
   1.106 + */
   1.107 +#define XRE_SYS_SHARE_EXTENSION_PARENT_DIR "XRESysSExtPD"
   1.108 +
   1.109 +/**
   1.110 + * A directory service key which specifies the user system extension
   1.111 + * parent directory.
   1.112 + */
   1.113 +#define XRE_USER_SYS_EXTENSION_DIR "XREUSysExt"
   1.114 +
   1.115 +/**
   1.116 + * A directory service key which specifies the distribution specific files for
   1.117 + * the application.
   1.118 + */
   1.119 +#define XRE_APP_DISTRIBUTION_DIR "XREAppDist"
   1.120 +
   1.121 +/**
   1.122 + * A directory service key which provides the update directory.
   1.123 + * At present this is supported only on Windows.
   1.124 + * Windows: Documents and Settings\<User>\Local Settings\Application Data\
   1.125 + *          <Vendor>\<Application>\<relative path to app dir from Program Files>
   1.126 + * If appDir is not under the Program Files, directory service will fail.
   1.127 + * Callers should fallback to appDir.
   1.128 + */
   1.129 +#define XRE_UPDATE_ROOT_DIR "UpdRootD"
   1.130 +
   1.131 +/**
   1.132 + * A directory service key which provides an alternate location 
   1.133 + * to UpdRootD to  to store large files. This key is currently 
   1.134 + * only implemented in the Gonk directory service provider. 
   1.135 + */
   1.136 +
   1.137 +#define XRE_UPDATE_ARCHIVE_DIR "UpdArchD"
   1.138 +
   1.139 +/**
   1.140 + * A directory service key which provides the directory where an OS update is
   1.141 +*  applied.
   1.142 + * At present this is supported only in Gonk.
   1.143 + */
   1.144 +#define XRE_OS_UPDATE_APPLY_TO_DIR "OSUpdApplyToD"
   1.145 +
   1.146 +/**
   1.147 + * Platform flag values for XRE_main.
   1.148 + *
   1.149 + * XRE_MAIN_FLAG_USE_METRO - On Windows, use the winrt backend. Defaults
   1.150 + * to win32 backend.
   1.151 + */
   1.152 +#define XRE_MAIN_FLAG_USE_METRO 0x01
   1.153 +
   1.154 +/**
   1.155 + * Begin an XUL application. Does not return until the user exits the
   1.156 + * application.
   1.157 + *
   1.158 + * @param argc/argv Command-line parameters to pass to the application. On
   1.159 + *                  Windows, these should be in UTF8. On unix-like platforms
   1.160 + *                  these are in the "native" character set.
   1.161 + *
   1.162 + * @param aAppData  Information about the application to be run.
   1.163 + *
   1.164 + * @param aFlags    Platform specific flags.
   1.165 + *
   1.166 + * @return         A native result code suitable for returning from main().
   1.167 + *
   1.168 + * @note           If the binary is linked against the standalone XPCOM glue,
   1.169 + *                 XPCOMGlueStartup() should be called before this method.
   1.170 + */
   1.171 +XRE_API(int,
   1.172 +        XRE_main, (int argc, char* argv[], const nsXREAppData* aAppData,
   1.173 +                   uint32_t aFlags))
   1.174 +
   1.175 +/**
   1.176 + * Given a path relative to the current working directory (or an absolute
   1.177 + * path), return an appropriate nsIFile object.
   1.178 + *
   1.179 + * @note Pass UTF8 strings on Windows... native charset on other platforms.
   1.180 + */
   1.181 +XRE_API(nsresult,
   1.182 +        XRE_GetFileFromPath, (const char *aPath, nsIFile* *aResult))
   1.183 +
   1.184 +/**
   1.185 + * Get the path of the running application binary and store it in aResult.
   1.186 + * @param argv0   The value passed as argv[0] of main(). This value is only
   1.187 + *                used on *nix, and only when other methods of determining
   1.188 + *                the binary path have failed.
   1.189 + */
   1.190 +XRE_API(nsresult,
   1.191 +        XRE_GetBinaryPath, (const char *argv0, nsIFile* *aResult))
   1.192 +
   1.193 +/**
   1.194 + * Get the static module built in to libxul.
   1.195 + */
   1.196 +XRE_API(const mozilla::Module*,
   1.197 +        XRE_GetStaticModule, ())
   1.198 +
   1.199 +/**
   1.200 + * Lock a profile directory using platform-specific semantics.
   1.201 + *
   1.202 + * @param aDirectory  The profile directory to lock.
   1.203 + * @param aLockObject An opaque lock object. The directory will remain locked
   1.204 + *                    as long as the XPCOM reference is held.
   1.205 + */
   1.206 +XRE_API(nsresult,
   1.207 +        XRE_LockProfileDirectory, (nsIFile* aDirectory,
   1.208 +                                   nsISupports* *aLockObject))
   1.209 +
   1.210 +/**
   1.211 + * Initialize libXUL for embedding purposes.
   1.212 + *
   1.213 + * @param aLibXULDirectory   The directory in which the libXUL shared library
   1.214 + *                           was found.
   1.215 + * @param aAppDirectory      The directory in which the application components
   1.216 + *                           and resources can be found. This will map to
   1.217 + *                           the NS_OS_CURRENT_PROCESS_DIR directory service
   1.218 + *                           key.
   1.219 + * @param aAppDirProvider    A directory provider for the application. This
   1.220 + *                           provider will be aggregated by a libxul provider
   1.221 + *                           which will provide the base required GRE keys.
   1.222 + *
   1.223 + * @note This function must be called from the "main" thread.
   1.224 + *
   1.225 + * @note At the present time, this function may only be called once in
   1.226 + * a given process. Use XRE_TermEmbedding to clean up and free
   1.227 + * resources allocated by XRE_InitEmbedding.
   1.228 + */
   1.229 +
   1.230 +XRE_API(nsresult,
   1.231 +        XRE_InitEmbedding2, (nsIFile *aLibXULDirectory,
   1.232 +                             nsIFile *aAppDirectory,
   1.233 +                             nsIDirectoryServiceProvider *aAppDirProvider))
   1.234 +
   1.235 +/**
   1.236 + * Register static XPCOM component information.
   1.237 + * This method may be called at any time before or after XRE_main or
   1.238 + * XRE_InitEmbedding.
   1.239 + */
   1.240 +XRE_API(nsresult,
   1.241 +        XRE_AddStaticComponent, (const mozilla::Module* aComponent))
   1.242 +
   1.243 +/**
   1.244 + * Register XPCOM components found in an array of files/directories.
   1.245 + * This method may be called at any time before or after XRE_main or
   1.246 + * XRE_InitEmbedding.
   1.247 + *
   1.248 + * @param aFiles An array of files or directories.
   1.249 + * @param aFileCount the number of items in the aFiles array.
   1.250 + * @note appdir/components is registered automatically.
   1.251 + *
   1.252 + * NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
   1.253 + * components as well as component/chrome manifest files.
   1.254 + *
   1.255 + * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
   1.256 + * which are only allowed to register only skin packages and style overlays.
   1.257 + */
   1.258 +enum NSLocationType
   1.259 +{
   1.260 +  NS_COMPONENT_LOCATION,
   1.261 +  NS_SKIN_LOCATION,
   1.262 +  NS_BOOTSTRAPPED_LOCATION
   1.263 +};
   1.264 +
   1.265 +XRE_API(nsresult,
   1.266 +        XRE_AddManifestLocation, (NSLocationType aType,
   1.267 +                                  nsIFile* aLocation))
   1.268 +
   1.269 +/**
   1.270 + * Register XPCOM components found in a JAR.
   1.271 + * This is similar to XRE_AddManifestLocation except the file specified
   1.272 + * must be a zip archive with a manifest named chrome.manifest
   1.273 + * This method may be called at any time before or after XRE_main or
   1.274 + * XRE_InitEmbedding.
   1.275 + *
   1.276 + * @param aFiles An array of files or directories.
   1.277 + * @param aFileCount the number of items in the aFiles array.
   1.278 + * @note appdir/components is registered automatically.
   1.279 + *
   1.280 + * NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
   1.281 + * components as well as component/chrome manifest files.
   1.282 + *
   1.283 + * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
   1.284 + * which are only allowed to register only skin packages and style overlays.
   1.285 + */
   1.286 +XRE_API(nsresult,
   1.287 +        XRE_AddJarManifestLocation, (NSLocationType aType,
   1.288 +                                     nsIFile* aLocation))
   1.289 +
   1.290 +/**
   1.291 + * Fire notifications to inform the toolkit about a new profile. This
   1.292 + * method should be called after XRE_InitEmbedding if the embedder
   1.293 + * wishes to run with a profile. Normally the embedder should call
   1.294 + * XRE_LockProfileDirectory to lock the directory before calling this
   1.295 + * method.
   1.296 + *
   1.297 + * @note There are two possibilities for selecting a profile:
   1.298 + *
   1.299 + * 1) Select the profile before calling XRE_InitEmbedding. The aAppDirProvider
   1.300 + *    object passed to XRE_InitEmbedding should provide the
   1.301 + *    NS_APP_USER_PROFILE_50_DIR key, and may also provide the following keys:
   1.302 + *    - NS_APP_USER_PROFILE_LOCAL_50_DIR
   1.303 + *    - NS_APP_PROFILE_DIR_STARTUP
   1.304 + *    - NS_APP_PROFILE_LOCAL_DIR_STARTUP
   1.305 + *    In this scenario XRE_NotifyProfile should be called immediately after
   1.306 + *    XRE_InitEmbedding. Component registration information will be stored in
   1.307 + *    the profile and JS components may be stored in the fastload cache.
   1.308 + *
   1.309 + * 2) Select a profile some time after calling XRE_InitEmbedding. In this case
   1.310 + *    the embedder must install a directory service provider which provides
   1.311 + *    NS_APP_USER_PROFILE_50_DIR and optionally
   1.312 + *    NS_APP_USER_PROFILE_LOCAL_50_DIR. Component registration information
   1.313 + *    will be stored in the application directory and JS components will not
   1.314 + *    fastload.
   1.315 + */
   1.316 +XRE_API(void,
   1.317 +        XRE_NotifyProfile, ())
   1.318 +
   1.319 +/**
   1.320 + * Terminate embedding started with XRE_InitEmbedding or XRE_InitEmbedding2
   1.321 + */
   1.322 +XRE_API(void,
   1.323 +        XRE_TermEmbedding, ())
   1.324 +
   1.325 +/**
   1.326 + * Create a new nsXREAppData structure from an application.ini file.
   1.327 + *
   1.328 + * @param aINIFile The application.ini file to parse.
   1.329 + * @param aAppData A newly-allocated nsXREAppData structure. The caller is
   1.330 + *                 responsible for freeing this structure using
   1.331 + *                 XRE_FreeAppData.
   1.332 + */
   1.333 +XRE_API(nsresult,
   1.334 +        XRE_CreateAppData, (nsIFile* aINIFile,
   1.335 +                            nsXREAppData **aAppData))
   1.336 +
   1.337 +/**
   1.338 + * Parse an INI file (application.ini or override.ini) into an existing
   1.339 + * nsXREAppData structure.
   1.340 + *
   1.341 + * @param aINIFile The INI file to parse
   1.342 + * @param aAppData The nsXREAppData structure to fill.
   1.343 + */
   1.344 +XRE_API(nsresult,
   1.345 +        XRE_ParseAppData, (nsIFile* aINIFile,
   1.346 +                           nsXREAppData *aAppData))
   1.347 +
   1.348 +/**
   1.349 + * Free a nsXREAppData structure that was allocated with XRE_CreateAppData.
   1.350 + */
   1.351 +XRE_API(void,
   1.352 +        XRE_FreeAppData, (nsXREAppData *aAppData))
   1.353 +
   1.354 +enum GeckoProcessType {
   1.355 +  GeckoProcessType_Default = 0,
   1.356 +
   1.357 +  GeckoProcessType_Plugin,
   1.358 +  GeckoProcessType_Content,
   1.359 +
   1.360 +  GeckoProcessType_IPDLUnitTest,
   1.361 +
   1.362 +  GeckoProcessType_End,
   1.363 +  GeckoProcessType_Invalid = GeckoProcessType_End
   1.364 +};
   1.365 +
   1.366 +static const char* const kGeckoProcessTypeString[] = {
   1.367 +  "default",
   1.368 +  "plugin",
   1.369 +  "tab",
   1.370 +  "ipdlunittest"
   1.371 +};
   1.372 +
   1.373 +static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
   1.374 +              GeckoProcessType_End,
   1.375 +              "Array length mismatch");
   1.376 +
   1.377 +XRE_API(const char*,
   1.378 +        XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))
   1.379 +
   1.380 +XRE_API(GeckoProcessType,
   1.381 +        XRE_StringToChildProcessType, (const char* aProcessTypeString))
   1.382 +
   1.383 +#if defined(MOZ_CRASHREPORTER)
   1.384 +// Used in the "master" parent process hosting the crash server
   1.385 +XRE_API(bool,
   1.386 +        XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump,
   1.387 +                                   uint32_t* aSequence))
   1.388 +
   1.389 +// Used in child processes.
   1.390 +XRE_API(bool,
   1.391 +        XRE_SetRemoteExceptionHandler, (const char* aPipe))
   1.392 +#endif
   1.393 +
   1.394 +XRE_API(nsresult,
   1.395 +        XRE_InitChildProcess, (int aArgc,
   1.396 +                               char* aArgv[],
   1.397 +                               GeckoProcessType aProcess))
   1.398 +
   1.399 +XRE_API(GeckoProcessType,
   1.400 +        XRE_GetProcessType, ())
   1.401 +
   1.402 +typedef void (*MainFunction)(void* aData);
   1.403 +
   1.404 +XRE_API(nsresult,
   1.405 +        XRE_InitParentProcess, (int aArgc,
   1.406 +                                char* aArgv[],
   1.407 +                                MainFunction aMainFunction,
   1.408 +                                void* aMainFunctionExtraData))
   1.409 +
   1.410 +XRE_API(int,
   1.411 +        XRE_RunIPDLTest, (int aArgc,
   1.412 +                          char* aArgv[]))
   1.413 +
   1.414 +XRE_API(nsresult,
   1.415 +        XRE_RunAppShell, ())
   1.416 +
   1.417 +XRE_API(nsresult,
   1.418 +        XRE_InitCommandLine, (int aArgc, char* aArgv[]))
   1.419 +
   1.420 +XRE_API(nsresult,
   1.421 +        XRE_DeinitCommandLine, ())
   1.422 +
   1.423 +class MessageLoop;
   1.424 +
   1.425 +XRE_API(void,
   1.426 +        XRE_ShutdownChildProcess, ())
   1.427 +
   1.428 +XRE_API(MessageLoop*,
   1.429 +        XRE_GetIOMessageLoop, ())
   1.430 +
   1.431 +XRE_API(bool,
   1.432 +        XRE_SendTestShellCommand, (JSContext* aCx,
   1.433 +                                   JSString* aCommand,
   1.434 +                                   void* aCallback))
   1.435 +XRE_API(bool,
   1.436 +        XRE_ShutdownTestShell, ())
   1.437 +
   1.438 +XRE_API(void,
   1.439 +        XRE_InstallX11ErrorHandler, ())
   1.440 +
   1.441 +XRE_API(void,
   1.442 +        XRE_TelemetryAccumulate, (int aID, uint32_t aSample))
   1.443 +
   1.444 +XRE_API(void,
   1.445 +        XRE_StartupTimelineRecord, (int aEvent, PRTime aWhen))
   1.446 +
   1.447 +XRE_API(void,
   1.448 +        XRE_InitOmnijar, (nsIFile* greOmni,
   1.449 +                          nsIFile* appOmni))
   1.450 +XRE_API(void,
   1.451 +        XRE_StopLateWriteChecks, (void))
   1.452 +
   1.453 +#ifdef XP_WIN
   1.454 +/**
   1.455 + * Valid environment types for XRE_GetWindowsEnvironment.
   1.456 + */
   1.457 +enum WindowsEnvironmentType {
   1.458 +  WindowsEnvironmentType_Desktop = 0,
   1.459 +  WindowsEnvironmentType_Metro = 1
   1.460 +};
   1.461 +
   1.462 +/**
   1.463 + * Retrieve the Windows desktop environment libXUL is running
   1.464 + * under. Valid after a call to XRE_main.
   1.465 + */
   1.466 +XRE_API(WindowsEnvironmentType,
   1.467 +        XRE_GetWindowsEnvironment, ())
   1.468 +#endif // XP_WIN
   1.469 +
   1.470 +XRE_API(int,
   1.471 +        XRE_XPCShellMain, (int argc, char** argv, char** envp))
   1.472 +
   1.473 +#endif // _nsXULAppAPI_h__

mercurial