1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
23 * Brian Ryner <bryner@brianryner.com>
24 * Benjamin Smedberg <bsmedberg@covad.net>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef _nsXULAppAPI_h__
41 #define _nsXULAppAPI_h__
47 #include "nsISupports.h"
50 * Application-specific data needed to start the apprunner.
52 * @status FROZEN - This API is stable. Additional fields may be added to the
53 * end of the structure in the future. Runtime detection
54 * of the version of nsXREAppData can be determined by
55 * examining the "size" field.
57 * @note When this structure is allocated and manipulated by XRE_CreateAppData,
58 * string fields will be allocated with NS_Alloc, and interface pointers
59 * are strong references.
64 * This should be set to sizeof(nsXREAppData). This structure may be
65 * extended in future releases, and this ensures that binary compatibility
71 * The directory of the application to be run. May be null if the
72 * xulrunner and the app are installed into the same directory.
74 nsILocalFile
* directory
;
77 * The name of the application vendor. This must be ASCII, and is normally
78 * mixed-case, e.g. "Mozilla". Optional (may be null), but highly
79 * recommended. Must not be the empty string.
84 * The name of the application. This must be ASCII, and is normally
85 * mixed-case, e.g. "Firefox". Required (must not be null or an empty
91 * The major version, e.g. "0.8.0+". Optional (may be null), but
92 * required for advanced application features such as the extension
93 * manager and update service. Must not be the empty string.
98 * The application's build identifier, e.g. "2004051604"
103 * The application's UUID. Used by the extension manager to determine
104 * compatible extensions. Optional, but required for advanced application
105 * features such as the extension manager and update service.
107 * This has traditionally been in the form
108 * "{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" but for new applications
109 * a more readable form is encouraged: "appname@vendor.tld". Only
110 * the following characters are allowed: a-z A-Z 0-9 - . @ _ { } *
115 * The copyright information to print for the -h commandline flag,
116 * e.g. "Copyright (c) 2003 mozilla.org".
118 const char *copyright
;
121 * Combination of NS_XRE_ prefixed flags (defined below).
126 * The location of the XRE. XRE_main may not be able to figure this out
129 nsILocalFile
* xreDirectory
;
132 * The minimum/maximum compatible XRE version.
134 const char *minVersion
;
135 const char *maxVersion
;
138 * The server URL to send crash reports to.
140 const char *crashReporterURL
;
143 * The profile directory that will be used. Optional (may be null). Must not
144 * be the empty string, must be ASCII. The path is split into components
145 * along the path separator characters '/' and '\'.
147 * The application data directory ("UAppData", see below) is normally
148 * composed as follows, where $HOME is platform-specific:
150 * UAppData = $HOME[/$vendor]/$name
152 * If present, the 'profile' string will be used instead of the combination of
153 * vendor and name as follows:
155 * UAppData = $HOME/$profile
161 * Indicates whether or not the profile migrator service may be
162 * invoked at startup when creating a profile.
164 #define NS_XRE_ENABLE_PROFILE_MIGRATOR (1 << 1)
167 * Indicates whether or not the extension manager service should be
168 * initialized at startup.
170 #define NS_XRE_ENABLE_EXTENSION_MANAGER (1 << 2)
173 * Indicates whether or not to use Breakpad crash reporting.
175 #define NS_XRE_ENABLE_CRASH_REPORTER (1 << 3)
178 * The contract id for the nsIXULAppInfo service.
180 #define XULAPPINFO_SERVICE_CONTRACTID \
181 "@mozilla.org/xre/app-info;1"
184 * A directory service key which provides the platform-correct "application
185 * data" directory as follows, where $name and $vendor are as defined above and
186 * $vendor is optional:
189 * HOME = Documents and Settings\$USER\Application Data
190 * UAppData = $HOME[\$vendor]\$name
194 * UAppData = $HOME/.[$vendor/]$name
198 * UAppData = $HOME/Library/Application Support/$name
200 * Note that the "profile" member above will change the value of UAppData as
204 * UAppData = $HOME\$profile
207 * UAppData = $HOME/.$profile
210 * UAppData = $HOME/Library/Application Support/$profile
212 #define XRE_USER_APP_DATA_DIR "UAppData"
215 * A directory service key which provides a list of all enabled extension
216 * directories. The list includes compatible platform-specific extension
219 * @note The directory list will have no members when the application is
220 * launched in safe mode.
222 #define XRE_EXTENSIONS_DIR_LIST "XREExtDL"
225 * A directory service key which provides the executable file used to
226 * launch the current process. This is the same value returned by the
227 * XRE_GetBinaryPath function defined below.
229 #define XRE_EXECUTABLE_FILE "XREExeF"
232 * A directory service key which specifies the profile
233 * directory. Unlike the NS_APP_USER_PROFILE_50_DIR key, this key may
234 * be available when the profile hasn't been "started", or after is
235 * has been shut down. If the application is running without a
236 * profile, such as when showing the profile manager UI, this key will
237 * not be available. This key is provided by the XUL apprunner or by
238 * the aAppDirProvider object passed to XRE_InitEmbedding.
240 #define NS_APP_PROFILE_DIR_STARTUP "ProfDS"
243 * A directory service key which specifies the profile
244 * directory. Unlike the NS_APP_USER_PROFILE_LOCAL_50_DIR key, this key may
245 * be available when the profile hasn't been "started", or after is
246 * has been shut down. If the application is running without a
247 * profile, such as when showing the profile manager UI, this key will
248 * not be available. This key is provided by the XUL apprunner or by
249 * the aAppDirProvider object passed to XRE_InitEmbedding.
251 #define NS_APP_PROFILE_LOCAL_DIR_STARTUP "ProfLDS"
254 * A directory service key which specifies the system extension
255 * parent directory containing platform-specific extensions.
256 * This key may not be available on all platforms.
258 #define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR "XRESysLExtPD"
261 * A directory service key which specifies the system extension
262 * parent directory containing platform-independent extensions.
263 * This key may not be available on all platforms.
264 * Additionally, the directory may be equal to that returned by
265 * XRE_SYS_LOCAL_EXTENSION_PARENT_DIR on some platforms.
267 #define XRE_SYS_SHARE_EXTENSION_PARENT_DIR "XRESysSExtPD"
270 * A directory service key which specifies the user system extension
273 #define XRE_USER_SYS_EXTENSION_DIR "XREUSysExt"
276 * Begin an XUL application. Does not return until the user exits the
279 * @param argc/argv Command-line parameters to pass to the application. On
280 * Windows, these should be in UTF8. On unix-like platforms
281 * these are in the "native" character set.
283 * @param aAppData Information about the application to be run.
285 * @return A native result code suitable for returning from main().
287 * @note If the binary is linked against the standalone XPCOM glue,
288 * XPCOMGlueStartup() should be called before this method.
292 XRE_main
, (int argc
, char* argv
[], const nsXREAppData
* sAppData
))
295 * Given a path relative to the current working directory (or an absolute
296 * path), return an appropriate nsILocalFile object.
298 * @note Pass UTF8 strings on Windows... native charset on other platforms.
301 XRE_GetFileFromPath
, (const char *aPath
, nsILocalFile
* *aResult
))
304 * Get the path of the running application binary and store it in aResult.
305 * @param argv0 The value passed as argv[0] of main(). This value is only
306 * used on *nix, and only when other methods of determining
307 * the binary path have failed.
310 XRE_GetBinaryPath
, (const char *argv0
, nsILocalFile
* *aResult
))
313 * Get the static components built in to libxul.
316 XRE_GetStaticComponents
, (nsStaticModuleInfo
const **aStaticComponents
,
317 PRUint32
*aComponentCount
))
320 * Lock a profile directory using platform-specific semantics.
322 * @param aDirectory The profile directory to lock.
323 * @param aLockObject An opaque lock object. The directory will remain locked
324 * as long as the XPCOM reference is held.
327 XRE_LockProfileDirectory
, (nsILocalFile
* aDirectory
,
328 nsISupports
* *aLockObject
))
331 * Initialize libXUL for embedding purposes.
333 * @param aLibXULDirectory The directory in which the libXUL shared library
335 * @param aAppDirectory The directory in which the application components
336 * and resources can be found. This will map to
337 * the NS_OS_CURRENT_PROCESS_DIR directory service
339 * @param aAppDirProvider A directory provider for the application. This
340 * provider will be aggregated by a libxul provider
341 * which will provide the base required GRE keys.
342 * @param aStaticComponents Static components provided by the embedding
343 * application. This should *not* include the
344 * components from XRE_GetStaticComponents. May be
345 * null if there are no static components.
346 * @param aStaticComponentCount the number of static components in
349 * @note This function must be called from the "main" thread.
351 * @note At the present time, this function may only be called once in
352 * a given process. Use XRE_TermEmbedding to clean up and free
353 * resources allocated by XRE_InitEmbedding.
357 XRE_InitEmbedding
, (nsILocalFile
*aLibXULDirectory
,
358 nsILocalFile
*aAppDirectory
,
359 nsIDirectoryServiceProvider
*aAppDirProvider
,
360 nsStaticModuleInfo
const *aStaticComponents
,
361 PRUint32 aStaticComponentCount
))
364 * Fire notifications to inform the toolkit about a new profile. This
365 * method should be called after XRE_InitEmbedding if the embedder
366 * wishes to run with a profile. Normally the embedder should call
367 * XRE_LockProfileDirectory to lock the directory before calling this
370 * @note There are two possibilities for selecting a profile:
372 * 1) Select the profile before calling XRE_InitEmbedding. The aAppDirProvider
373 * object passed to XRE_InitEmbedding should provide the
374 * NS_APP_USER_PROFILE_50_DIR key, and may also provide the following keys:
375 * - NS_APP_USER_PROFILE_LOCAL_50_DIR
376 * - NS_APP_PROFILE_DIR_STARTUP
377 * - NS_APP_PROFILE_LOCAL_DIR_STARTUP
378 * In this scenario XRE_NotifyProfile should be called immediately after
379 * XRE_InitEmbedding. Component registration information will be stored in
380 * the profile and JS components may be stored in the fastload cache.
382 * 2) Select a profile some time after calling XRE_InitEmbedding. In this case
383 * the embedder must install a directory service provider which provides
384 * NS_APP_USER_PROFILE_50_DIR and optionally
385 * NS_APP_USER_PROFILE_LOCAL_50_DIR. Component registration information
386 * will be stored in the application directory and JS components will not
390 XRE_NotifyProfile
, ())
393 * Terminate embedding started with XRE_InitEmbedding or XRE_InitEmbedding2
396 XRE_TermEmbedding
, ())
399 * Create a new nsXREAppData structure from an application.ini file.
401 * @param aINIFile The application.ini file to parse.
402 * @param aAppData A newly-allocated nsXREAppData structure. The caller is
403 * responsible for freeing this structure using
407 XRE_CreateAppData
, (nsILocalFile
* aINIFile
,
408 nsXREAppData
**aAppData
))
411 * Parse an INI file (application.ini or override.ini) into an existing
412 * nsXREAppData structure.
414 * @param aINIFile The INI file to parse
415 * @param aAppData The nsXREAppData structure to fill.
418 XRE_ParseAppData
, (nsILocalFile
* aINIFile
,
419 nsXREAppData
*aAppData
))
422 * Free a nsXREAppData structure that was allocated with XRE_CreateAppData.
425 XRE_FreeAppData
, (nsXREAppData
*aAppData
))
427 #endif // _nsXULAppAPI_h__