xpcom/build/nsXULAppAPI.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _nsXULAppAPI_h__
michael@0 7 #define _nsXULAppAPI_h__
michael@0 8
michael@0 9 #include "nsID.h"
michael@0 10 #include "xrecore.h"
michael@0 11 #include "nsXPCOM.h"
michael@0 12 #include "nsISupports.h"
michael@0 13 #include "prlog.h"
michael@0 14 #include "nsXREAppData.h"
michael@0 15 #include "js/TypeDecls.h"
michael@0 16
michael@0 17 #include "mozilla/ArrayUtils.h"
michael@0 18 #include "mozilla/Assertions.h"
michael@0 19
michael@0 20 /**
michael@0 21 * A directory service key which provides the platform-correct "application
michael@0 22 * data" directory as follows, where $name and $vendor are as defined above and
michael@0 23 * $vendor is optional:
michael@0 24 *
michael@0 25 * Windows:
michael@0 26 * HOME = Documents and Settings\$USER\Application Data
michael@0 27 * UAppData = $HOME[\$vendor]\$name
michael@0 28 *
michael@0 29 * Unix:
michael@0 30 * HOME = ~
michael@0 31 * UAppData = $HOME/.[$vendor/]$name
michael@0 32 *
michael@0 33 * Mac:
michael@0 34 * HOME = ~
michael@0 35 * UAppData = $HOME/Library/Application Support/$name
michael@0 36 *
michael@0 37 * Note that the "profile" member above will change the value of UAppData as
michael@0 38 * follows:
michael@0 39 *
michael@0 40 * Windows:
michael@0 41 * UAppData = $HOME\$profile
michael@0 42 *
michael@0 43 * Unix:
michael@0 44 * UAppData = $HOME/.$profile
michael@0 45 *
michael@0 46 * Mac:
michael@0 47 * UAppData = $HOME/Library/Application Support/$profile
michael@0 48 */
michael@0 49 #define XRE_USER_APP_DATA_DIR "UAppData"
michael@0 50
michael@0 51 /**
michael@0 52 * A directory service key which provides a list of all enabled extension
michael@0 53 * directories and files (packed XPIs). The list includes compatible
michael@0 54 * platform-specific extension subdirectories.
michael@0 55 *
michael@0 56 * @note The directory list will have no members when the application is
michael@0 57 * launched in safe mode.
michael@0 58 */
michael@0 59 #define XRE_EXTENSIONS_DIR_LIST "XREExtDL"
michael@0 60
michael@0 61 /**
michael@0 62 * A directory service key which provides the executable file used to
michael@0 63 * launch the current process. This is the same value returned by the
michael@0 64 * XRE_GetBinaryPath function defined below.
michael@0 65 */
michael@0 66 #define XRE_EXECUTABLE_FILE "XREExeF"
michael@0 67
michael@0 68 /**
michael@0 69 * A directory service key which specifies the profile
michael@0 70 * directory. Unlike the NS_APP_USER_PROFILE_50_DIR key, this key may
michael@0 71 * be available when the profile hasn't been "started", or after is
michael@0 72 * has been shut down. If the application is running without a
michael@0 73 * profile, such as when showing the profile manager UI, this key will
michael@0 74 * not be available. This key is provided by the XUL apprunner or by
michael@0 75 * the aAppDirProvider object passed to XRE_InitEmbedding.
michael@0 76 */
michael@0 77 #define NS_APP_PROFILE_DIR_STARTUP "ProfDS"
michael@0 78
michael@0 79 /**
michael@0 80 * A directory service key which specifies the profile
michael@0 81 * directory. Unlike the NS_APP_USER_PROFILE_LOCAL_50_DIR key, this key may
michael@0 82 * be available when the profile hasn't been "started", or after is
michael@0 83 * has been shut down. If the application is running without a
michael@0 84 * profile, such as when showing the profile manager UI, this key will
michael@0 85 * not be available. This key is provided by the XUL apprunner or by
michael@0 86 * the aAppDirProvider object passed to XRE_InitEmbedding.
michael@0 87 */
michael@0 88 #define NS_APP_PROFILE_LOCAL_DIR_STARTUP "ProfLDS"
michael@0 89
michael@0 90 /**
michael@0 91 * A directory service key which specifies the system extension
michael@0 92 * parent directory containing platform-specific extensions.
michael@0 93 * This key may not be available on all platforms.
michael@0 94 */
michael@0 95 #define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR "XRESysLExtPD"
michael@0 96
michael@0 97 /**
michael@0 98 * A directory service key which specifies the system extension
michael@0 99 * parent directory containing platform-independent extensions.
michael@0 100 * This key may not be available on all platforms.
michael@0 101 * Additionally, the directory may be equal to that returned by
michael@0 102 * XRE_SYS_LOCAL_EXTENSION_PARENT_DIR on some platforms.
michael@0 103 */
michael@0 104 #define XRE_SYS_SHARE_EXTENSION_PARENT_DIR "XRESysSExtPD"
michael@0 105
michael@0 106 /**
michael@0 107 * A directory service key which specifies the user system extension
michael@0 108 * parent directory.
michael@0 109 */
michael@0 110 #define XRE_USER_SYS_EXTENSION_DIR "XREUSysExt"
michael@0 111
michael@0 112 /**
michael@0 113 * A directory service key which specifies the distribution specific files for
michael@0 114 * the application.
michael@0 115 */
michael@0 116 #define XRE_APP_DISTRIBUTION_DIR "XREAppDist"
michael@0 117
michael@0 118 /**
michael@0 119 * A directory service key which provides the update directory.
michael@0 120 * At present this is supported only on Windows.
michael@0 121 * Windows: Documents and Settings\<User>\Local Settings\Application Data\
michael@0 122 * <Vendor>\<Application>\<relative path to app dir from Program Files>
michael@0 123 * If appDir is not under the Program Files, directory service will fail.
michael@0 124 * Callers should fallback to appDir.
michael@0 125 */
michael@0 126 #define XRE_UPDATE_ROOT_DIR "UpdRootD"
michael@0 127
michael@0 128 /**
michael@0 129 * A directory service key which provides an alternate location
michael@0 130 * to UpdRootD to to store large files. This key is currently
michael@0 131 * only implemented in the Gonk directory service provider.
michael@0 132 */
michael@0 133
michael@0 134 #define XRE_UPDATE_ARCHIVE_DIR "UpdArchD"
michael@0 135
michael@0 136 /**
michael@0 137 * A directory service key which provides the directory where an OS update is
michael@0 138 * applied.
michael@0 139 * At present this is supported only in Gonk.
michael@0 140 */
michael@0 141 #define XRE_OS_UPDATE_APPLY_TO_DIR "OSUpdApplyToD"
michael@0 142
michael@0 143 /**
michael@0 144 * Platform flag values for XRE_main.
michael@0 145 *
michael@0 146 * XRE_MAIN_FLAG_USE_METRO - On Windows, use the winrt backend. Defaults
michael@0 147 * to win32 backend.
michael@0 148 */
michael@0 149 #define XRE_MAIN_FLAG_USE_METRO 0x01
michael@0 150
michael@0 151 /**
michael@0 152 * Begin an XUL application. Does not return until the user exits the
michael@0 153 * application.
michael@0 154 *
michael@0 155 * @param argc/argv Command-line parameters to pass to the application. On
michael@0 156 * Windows, these should be in UTF8. On unix-like platforms
michael@0 157 * these are in the "native" character set.
michael@0 158 *
michael@0 159 * @param aAppData Information about the application to be run.
michael@0 160 *
michael@0 161 * @param aFlags Platform specific flags.
michael@0 162 *
michael@0 163 * @return A native result code suitable for returning from main().
michael@0 164 *
michael@0 165 * @note If the binary is linked against the standalone XPCOM glue,
michael@0 166 * XPCOMGlueStartup() should be called before this method.
michael@0 167 */
michael@0 168 XRE_API(int,
michael@0 169 XRE_main, (int argc, char* argv[], const nsXREAppData* aAppData,
michael@0 170 uint32_t aFlags))
michael@0 171
michael@0 172 /**
michael@0 173 * Given a path relative to the current working directory (or an absolute
michael@0 174 * path), return an appropriate nsIFile object.
michael@0 175 *
michael@0 176 * @note Pass UTF8 strings on Windows... native charset on other platforms.
michael@0 177 */
michael@0 178 XRE_API(nsresult,
michael@0 179 XRE_GetFileFromPath, (const char *aPath, nsIFile* *aResult))
michael@0 180
michael@0 181 /**
michael@0 182 * Get the path of the running application binary and store it in aResult.
michael@0 183 * @param argv0 The value passed as argv[0] of main(). This value is only
michael@0 184 * used on *nix, and only when other methods of determining
michael@0 185 * the binary path have failed.
michael@0 186 */
michael@0 187 XRE_API(nsresult,
michael@0 188 XRE_GetBinaryPath, (const char *argv0, nsIFile* *aResult))
michael@0 189
michael@0 190 /**
michael@0 191 * Get the static module built in to libxul.
michael@0 192 */
michael@0 193 XRE_API(const mozilla::Module*,
michael@0 194 XRE_GetStaticModule, ())
michael@0 195
michael@0 196 /**
michael@0 197 * Lock a profile directory using platform-specific semantics.
michael@0 198 *
michael@0 199 * @param aDirectory The profile directory to lock.
michael@0 200 * @param aLockObject An opaque lock object. The directory will remain locked
michael@0 201 * as long as the XPCOM reference is held.
michael@0 202 */
michael@0 203 XRE_API(nsresult,
michael@0 204 XRE_LockProfileDirectory, (nsIFile* aDirectory,
michael@0 205 nsISupports* *aLockObject))
michael@0 206
michael@0 207 /**
michael@0 208 * Initialize libXUL for embedding purposes.
michael@0 209 *
michael@0 210 * @param aLibXULDirectory The directory in which the libXUL shared library
michael@0 211 * was found.
michael@0 212 * @param aAppDirectory The directory in which the application components
michael@0 213 * and resources can be found. This will map to
michael@0 214 * the NS_OS_CURRENT_PROCESS_DIR directory service
michael@0 215 * key.
michael@0 216 * @param aAppDirProvider A directory provider for the application. This
michael@0 217 * provider will be aggregated by a libxul provider
michael@0 218 * which will provide the base required GRE keys.
michael@0 219 *
michael@0 220 * @note This function must be called from the "main" thread.
michael@0 221 *
michael@0 222 * @note At the present time, this function may only be called once in
michael@0 223 * a given process. Use XRE_TermEmbedding to clean up and free
michael@0 224 * resources allocated by XRE_InitEmbedding.
michael@0 225 */
michael@0 226
michael@0 227 XRE_API(nsresult,
michael@0 228 XRE_InitEmbedding2, (nsIFile *aLibXULDirectory,
michael@0 229 nsIFile *aAppDirectory,
michael@0 230 nsIDirectoryServiceProvider *aAppDirProvider))
michael@0 231
michael@0 232 /**
michael@0 233 * Register static XPCOM component information.
michael@0 234 * This method may be called at any time before or after XRE_main or
michael@0 235 * XRE_InitEmbedding.
michael@0 236 */
michael@0 237 XRE_API(nsresult,
michael@0 238 XRE_AddStaticComponent, (const mozilla::Module* aComponent))
michael@0 239
michael@0 240 /**
michael@0 241 * Register XPCOM components found in an array of files/directories.
michael@0 242 * This method may be called at any time before or after XRE_main or
michael@0 243 * XRE_InitEmbedding.
michael@0 244 *
michael@0 245 * @param aFiles An array of files or directories.
michael@0 246 * @param aFileCount the number of items in the aFiles array.
michael@0 247 * @note appdir/components is registered automatically.
michael@0 248 *
michael@0 249 * NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
michael@0 250 * components as well as component/chrome manifest files.
michael@0 251 *
michael@0 252 * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
michael@0 253 * which are only allowed to register only skin packages and style overlays.
michael@0 254 */
michael@0 255 enum NSLocationType
michael@0 256 {
michael@0 257 NS_COMPONENT_LOCATION,
michael@0 258 NS_SKIN_LOCATION,
michael@0 259 NS_BOOTSTRAPPED_LOCATION
michael@0 260 };
michael@0 261
michael@0 262 XRE_API(nsresult,
michael@0 263 XRE_AddManifestLocation, (NSLocationType aType,
michael@0 264 nsIFile* aLocation))
michael@0 265
michael@0 266 /**
michael@0 267 * Register XPCOM components found in a JAR.
michael@0 268 * This is similar to XRE_AddManifestLocation except the file specified
michael@0 269 * must be a zip archive with a manifest named chrome.manifest
michael@0 270 * This method may be called at any time before or after XRE_main or
michael@0 271 * XRE_InitEmbedding.
michael@0 272 *
michael@0 273 * @param aFiles An array of files or directories.
michael@0 274 * @param aFileCount the number of items in the aFiles array.
michael@0 275 * @note appdir/components is registered automatically.
michael@0 276 *
michael@0 277 * NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
michael@0 278 * components as well as component/chrome manifest files.
michael@0 279 *
michael@0 280 * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
michael@0 281 * which are only allowed to register only skin packages and style overlays.
michael@0 282 */
michael@0 283 XRE_API(nsresult,
michael@0 284 XRE_AddJarManifestLocation, (NSLocationType aType,
michael@0 285 nsIFile* aLocation))
michael@0 286
michael@0 287 /**
michael@0 288 * Fire notifications to inform the toolkit about a new profile. This
michael@0 289 * method should be called after XRE_InitEmbedding if the embedder
michael@0 290 * wishes to run with a profile. Normally the embedder should call
michael@0 291 * XRE_LockProfileDirectory to lock the directory before calling this
michael@0 292 * method.
michael@0 293 *
michael@0 294 * @note There are two possibilities for selecting a profile:
michael@0 295 *
michael@0 296 * 1) Select the profile before calling XRE_InitEmbedding. The aAppDirProvider
michael@0 297 * object passed to XRE_InitEmbedding should provide the
michael@0 298 * NS_APP_USER_PROFILE_50_DIR key, and may also provide the following keys:
michael@0 299 * - NS_APP_USER_PROFILE_LOCAL_50_DIR
michael@0 300 * - NS_APP_PROFILE_DIR_STARTUP
michael@0 301 * - NS_APP_PROFILE_LOCAL_DIR_STARTUP
michael@0 302 * In this scenario XRE_NotifyProfile should be called immediately after
michael@0 303 * XRE_InitEmbedding. Component registration information will be stored in
michael@0 304 * the profile and JS components may be stored in the fastload cache.
michael@0 305 *
michael@0 306 * 2) Select a profile some time after calling XRE_InitEmbedding. In this case
michael@0 307 * the embedder must install a directory service provider which provides
michael@0 308 * NS_APP_USER_PROFILE_50_DIR and optionally
michael@0 309 * NS_APP_USER_PROFILE_LOCAL_50_DIR. Component registration information
michael@0 310 * will be stored in the application directory and JS components will not
michael@0 311 * fastload.
michael@0 312 */
michael@0 313 XRE_API(void,
michael@0 314 XRE_NotifyProfile, ())
michael@0 315
michael@0 316 /**
michael@0 317 * Terminate embedding started with XRE_InitEmbedding or XRE_InitEmbedding2
michael@0 318 */
michael@0 319 XRE_API(void,
michael@0 320 XRE_TermEmbedding, ())
michael@0 321
michael@0 322 /**
michael@0 323 * Create a new nsXREAppData structure from an application.ini file.
michael@0 324 *
michael@0 325 * @param aINIFile The application.ini file to parse.
michael@0 326 * @param aAppData A newly-allocated nsXREAppData structure. The caller is
michael@0 327 * responsible for freeing this structure using
michael@0 328 * XRE_FreeAppData.
michael@0 329 */
michael@0 330 XRE_API(nsresult,
michael@0 331 XRE_CreateAppData, (nsIFile* aINIFile,
michael@0 332 nsXREAppData **aAppData))
michael@0 333
michael@0 334 /**
michael@0 335 * Parse an INI file (application.ini or override.ini) into an existing
michael@0 336 * nsXREAppData structure.
michael@0 337 *
michael@0 338 * @param aINIFile The INI file to parse
michael@0 339 * @param aAppData The nsXREAppData structure to fill.
michael@0 340 */
michael@0 341 XRE_API(nsresult,
michael@0 342 XRE_ParseAppData, (nsIFile* aINIFile,
michael@0 343 nsXREAppData *aAppData))
michael@0 344
michael@0 345 /**
michael@0 346 * Free a nsXREAppData structure that was allocated with XRE_CreateAppData.
michael@0 347 */
michael@0 348 XRE_API(void,
michael@0 349 XRE_FreeAppData, (nsXREAppData *aAppData))
michael@0 350
michael@0 351 enum GeckoProcessType {
michael@0 352 GeckoProcessType_Default = 0,
michael@0 353
michael@0 354 GeckoProcessType_Plugin,
michael@0 355 GeckoProcessType_Content,
michael@0 356
michael@0 357 GeckoProcessType_IPDLUnitTest,
michael@0 358
michael@0 359 GeckoProcessType_End,
michael@0 360 GeckoProcessType_Invalid = GeckoProcessType_End
michael@0 361 };
michael@0 362
michael@0 363 static const char* const kGeckoProcessTypeString[] = {
michael@0 364 "default",
michael@0 365 "plugin",
michael@0 366 "tab",
michael@0 367 "ipdlunittest"
michael@0 368 };
michael@0 369
michael@0 370 static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
michael@0 371 GeckoProcessType_End,
michael@0 372 "Array length mismatch");
michael@0 373
michael@0 374 XRE_API(const char*,
michael@0 375 XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))
michael@0 376
michael@0 377 XRE_API(GeckoProcessType,
michael@0 378 XRE_StringToChildProcessType, (const char* aProcessTypeString))
michael@0 379
michael@0 380 #if defined(MOZ_CRASHREPORTER)
michael@0 381 // Used in the "master" parent process hosting the crash server
michael@0 382 XRE_API(bool,
michael@0 383 XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump,
michael@0 384 uint32_t* aSequence))
michael@0 385
michael@0 386 // Used in child processes.
michael@0 387 XRE_API(bool,
michael@0 388 XRE_SetRemoteExceptionHandler, (const char* aPipe))
michael@0 389 #endif
michael@0 390
michael@0 391 XRE_API(nsresult,
michael@0 392 XRE_InitChildProcess, (int aArgc,
michael@0 393 char* aArgv[],
michael@0 394 GeckoProcessType aProcess))
michael@0 395
michael@0 396 XRE_API(GeckoProcessType,
michael@0 397 XRE_GetProcessType, ())
michael@0 398
michael@0 399 typedef void (*MainFunction)(void* aData);
michael@0 400
michael@0 401 XRE_API(nsresult,
michael@0 402 XRE_InitParentProcess, (int aArgc,
michael@0 403 char* aArgv[],
michael@0 404 MainFunction aMainFunction,
michael@0 405 void* aMainFunctionExtraData))
michael@0 406
michael@0 407 XRE_API(int,
michael@0 408 XRE_RunIPDLTest, (int aArgc,
michael@0 409 char* aArgv[]))
michael@0 410
michael@0 411 XRE_API(nsresult,
michael@0 412 XRE_RunAppShell, ())
michael@0 413
michael@0 414 XRE_API(nsresult,
michael@0 415 XRE_InitCommandLine, (int aArgc, char* aArgv[]))
michael@0 416
michael@0 417 XRE_API(nsresult,
michael@0 418 XRE_DeinitCommandLine, ())
michael@0 419
michael@0 420 class MessageLoop;
michael@0 421
michael@0 422 XRE_API(void,
michael@0 423 XRE_ShutdownChildProcess, ())
michael@0 424
michael@0 425 XRE_API(MessageLoop*,
michael@0 426 XRE_GetIOMessageLoop, ())
michael@0 427
michael@0 428 XRE_API(bool,
michael@0 429 XRE_SendTestShellCommand, (JSContext* aCx,
michael@0 430 JSString* aCommand,
michael@0 431 void* aCallback))
michael@0 432 XRE_API(bool,
michael@0 433 XRE_ShutdownTestShell, ())
michael@0 434
michael@0 435 XRE_API(void,
michael@0 436 XRE_InstallX11ErrorHandler, ())
michael@0 437
michael@0 438 XRE_API(void,
michael@0 439 XRE_TelemetryAccumulate, (int aID, uint32_t aSample))
michael@0 440
michael@0 441 XRE_API(void,
michael@0 442 XRE_StartupTimelineRecord, (int aEvent, PRTime aWhen))
michael@0 443
michael@0 444 XRE_API(void,
michael@0 445 XRE_InitOmnijar, (nsIFile* greOmni,
michael@0 446 nsIFile* appOmni))
michael@0 447 XRE_API(void,
michael@0 448 XRE_StopLateWriteChecks, (void))
michael@0 449
michael@0 450 #ifdef XP_WIN
michael@0 451 /**
michael@0 452 * Valid environment types for XRE_GetWindowsEnvironment.
michael@0 453 */
michael@0 454 enum WindowsEnvironmentType {
michael@0 455 WindowsEnvironmentType_Desktop = 0,
michael@0 456 WindowsEnvironmentType_Metro = 1
michael@0 457 };
michael@0 458
michael@0 459 /**
michael@0 460 * Retrieve the Windows desktop environment libXUL is running
michael@0 461 * under. Valid after a call to XRE_main.
michael@0 462 */
michael@0 463 XRE_API(WindowsEnvironmentType,
michael@0 464 XRE_GetWindowsEnvironment, ())
michael@0 465 #endif // XP_WIN
michael@0 466
michael@0 467 XRE_API(int,
michael@0 468 XRE_XPCShellMain, (int argc, char** argv, char** envp))
michael@0 469
michael@0 470 #endif // _nsXULAppAPI_h__

mercurial