Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / xpcom / build / nsXULAppAPI.h
blobd15944f8e431bc94b754cb47e1c1d1137bb5e91e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _nsXULAppAPI_h__
8 #define _nsXULAppAPI_h__
10 #include "js/TypeDecls.h"
11 #include "mozilla/ArrayUtils.h"
12 #include "mozilla/ProcessType.h"
13 #include "mozilla/TimeStamp.h"
14 #include "nscore.h"
16 #if defined(MOZ_WIDGET_ANDROID)
17 # include <jni.h>
18 #endif
20 class JSString;
21 class MessageLoop;
22 class nsIDirectoryServiceProvider;
23 class nsIFile;
24 class nsISupports;
25 struct JSContext;
26 struct XREChildData;
27 struct XREShellData;
29 namespace mozilla {
30 class XREAppData;
31 struct BootstrapConfig;
32 } // namespace mozilla
34 /**
35 * A directory service key which provides the platform-correct "application
36 * data" directory as follows, where $name and $vendor are as defined above and
37 * $vendor is optional:
39 * Windows:
40 * HOME = Documents and Settings\$USER\Application Data
41 * UAppData = $HOME[\$vendor]\$name
43 * Unix:
44 * HOME = ~
45 * UAppData = $HOME/.[$vendor/]$name
47 * Mac:
48 * HOME = ~
49 * UAppData = $HOME/Library/Application Support/$name
51 * Note that the "profile" member above will change the value of UAppData as
52 * follows:
54 * Windows:
55 * UAppData = $HOME\$profile
57 * Unix:
58 * UAppData = $HOME/.$profile
60 * Mac:
61 * UAppData = $HOME/Library/Application Support/$profile
63 #define XRE_USER_APP_DATA_DIR "UAppData"
65 /**
66 * A directory service key which provides the executable file used to
67 * launch the current process. This is the same value returned by the
68 * XRE_GetBinaryPath function defined below.
70 #define XRE_EXECUTABLE_FILE "XREExeF"
72 /**
73 * A directory service key which specifies the profile
74 * directory. Unlike the NS_APP_USER_PROFILE_50_DIR key, this key may
75 * be available when the profile hasn't been "started", or after is
76 * has been shut down. If the application is running without a
77 * profile, such as when showing the profile manager UI, this key will
78 * not be available. This key is provided by the XUL apprunner or by
79 * the aAppDirProvider object passed to XRE_InitEmbedding.
81 #define NS_APP_PROFILE_DIR_STARTUP "ProfDS"
83 /**
84 * A directory service key which specifies the profile
85 * directory. Unlike the NS_APP_USER_PROFILE_LOCAL_50_DIR key, this key may
86 * be available when the profile hasn't been "started", or after is
87 * has been shut down. If the application is running without a
88 * profile, such as when showing the profile manager UI, this key will
89 * not be available. This key is provided by the XUL apprunner or by
90 * the aAppDirProvider object passed to XRE_InitEmbedding.
92 #define NS_APP_PROFILE_LOCAL_DIR_STARTUP "ProfLDS"
94 /**
95 * A directory service key which specifies the system extension
96 * parent directory containing platform-specific extensions.
97 * This key may not be available on all platforms.
99 #define XRE_SYS_LOCAL_EXTENSION_PARENT_DIR "XRESysLExtPD"
102 * A directory service key which specifies the system extension
103 * parent directory containing platform-independent extensions.
104 * This key may not be available on all platforms.
105 * Additionally, the directory may be equal to that returned by
106 * XRE_SYS_LOCAL_EXTENSION_PARENT_DIR on some platforms.
108 #define XRE_SYS_SHARE_EXTENSION_PARENT_DIR "XRESysSExtPD"
110 #if defined(XP_UNIX) || defined(XP_MACOSX)
112 * Directory service keys for the system-wide and user-specific
113 * directories where native manifests used by the WebExtensions
114 * native messaging and managed storage features are found.
116 # define XRE_SYS_NATIVE_MANIFESTS "XRESysNativeManifests"
117 # define XRE_USER_NATIVE_MANIFESTS "XREUserNativeManifests"
118 #endif
121 * A directory service key which specifies the user system extension
122 * parent directory.
124 #define XRE_USER_SYS_EXTENSION_DIR "XREUSysExt"
127 * A directory service key which specifies the distribution specific files for
128 * the application.
130 #define XRE_APP_DISTRIBUTION_DIR "XREAppDist"
133 * A directory service key which specifies the location for system add-ons.
135 #define XRE_APP_FEATURES_DIR "XREAppFeat"
138 * A directory service key which specifies the location for app dir add-ons.
139 * Should be a synonym for XCurProcD everywhere except in tests.
141 #define XRE_ADDON_APP_DIR "XREAddonAppDir"
144 * A directory service key which specifies the distribution specific files for
145 * the application unique for each user.
146 * It's located at /run/user/$UID/<product name>/
148 #define XRE_USER_RUNTIME_DIR "XREUserRunTimeDir"
151 * A directory service key which provides the update directory. Callers should
152 * fall back to appDir.
153 * Windows: If vendor name exists:
154 * ProgramData\<vendor name>\updates\
155 * <hash of the path to XRE_EXECUTABLE_FILE's parent directory>
157 * If vendor name doesn't exist, but product name exists:
158 * ProgramData\<product name>\updates\
159 * <hash of the path to XRE_EXECUTABLE_FILE's parent directory>
161 * If neither vendor nor product name exists:
162 * ProgramData\Mozilla\updates
164 * Mac: ~/Library/Caches/Mozilla/updates/<absolute path to app dir>
166 * All others: Parent directory of XRE_EXECUTABLE_FILE.
168 #define XRE_UPDATE_ROOT_DIR "UpdRootD"
171 * A directory service key which provides the *old* update directory. This
172 * path should only be used when data needs to be migrated from the old update
173 * directory.
174 * Windows: If vendor name exists:
175 * Documents and Settings\<User>\Local Settings\Application Data\
176 * <vendor name>\updates\
177 * <hash of the path to XRE_EXECUTABLE_FILE's parent directory>
179 * If vendor name doesn't exist, but product name exists:
180 * Documents and Settings\<User>\Local Settings\Application Data\
181 * <product name>\updates\
182 * <hash of the path to XRE_EXECUTABLE_FILE's parent directory>
184 * If neither vendor nor product name exists:
185 * Documents and Settings\<User>\Local Settings\Application Data\
186 * Mozilla\updates
188 * This path does not exist on other operating systems
190 #define XRE_OLD_UPDATE_ROOT_DIR "OldUpdRootD"
193 * Begin an XUL application. Does not return until the user exits the
194 * application.
196 * @param argc/argv Command-line parameters to pass to the application. On
197 * Windows, these should be in UTF8. On unix-like platforms
198 * these are in the "native" character set.
200 * @param aConfig Information about the application to be run.
202 * @return A native result code suitable for returning from main().
204 * @note If the binary is linked against the standalone XPCOM glue,
205 * XPCOMGlueStartup() should be called before this method.
207 int XRE_main(int argc, char* argv[], const mozilla::BootstrapConfig& aConfig);
210 * Given a path relative to the current working directory (or an absolute
211 * path), return an appropriate nsIFile object.
213 * @note Pass UTF8 strings on Windows... native charset on other platforms.
215 nsresult XRE_GetFileFromPath(const char* aPath, nsIFile** aResult);
218 * Get the path of the running application binary and store it in aResult.
220 nsresult XRE_GetBinaryPath(nsIFile** aResult);
223 * Register XPCOM components found in an array of files/directories.
224 * This method may be called at any time before or after XRE_main or
225 * XRE_InitEmbedding.
227 * @param aFiles An array of files or directories.
228 * @param aFileCount the number of items in the aFiles array.
229 * @note appdir/components is registered automatically.
231 * NS_APP_LOCATION specifies a location to search for binary XPCOM
232 * components as well as component/chrome manifest files.
234 * NS_EXTENSION_LOCATION excludes binary XPCOM components but allows other
235 * manifest instructions.
237 * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
238 * which are only allowed to register skin packages.
240 enum NSLocationType {
241 NS_APP_LOCATION,
242 NS_EXTENSION_LOCATION,
243 NS_SKIN_LOCATION,
244 NS_BOOTSTRAPPED_LOCATION
247 nsresult XRE_AddManifestLocation(NSLocationType aType, nsIFile* aLocation);
250 * Register XPCOM components found in a JAR.
251 * This is similar to XRE_AddManifestLocation except the file specified
252 * must be a zip archive with a manifest named chrome.manifest
253 * This method may be called at any time before or after XRE_main or
254 * XRE_InitEmbedding.
256 * @param aFiles An array of files or directories.
257 * @param aFileCount the number of items in the aFiles array.
258 * @note appdir/components is registered automatically.
260 * NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
261 * components as well as component/chrome manifest files.
263 * NS_SKIN_LOCATION specifies a location to search for chrome manifest files
264 * which are only allowed to register skin packages.
266 nsresult XRE_AddJarManifestLocation(NSLocationType aType, nsIFile* aLocation);
269 * Parse an INI file (application.ini or override.ini) into an existing
270 * nsXREAppData structure.
272 * @param aINIFile The INI file to parse
273 * @param aAppData The nsXREAppData structure to fill.
275 nsresult XRE_ParseAppData(nsIFile* aINIFile, mozilla::XREAppData& aAppData);
277 const char* XRE_GeckoProcessTypeToString(GeckoProcessType aProcessType);
278 const char* XRE_ChildProcessTypeToAnnotation(GeckoProcessType aProcessType);
280 #if defined(MOZ_WIDGET_ANDROID)
281 struct XRE_AndroidChildFds {
282 int mPrefsFd;
283 int mPrefMapFd;
284 int mIpcFd;
285 int mCrashFd;
288 void XRE_SetAndroidChildFds(JNIEnv* env, const XRE_AndroidChildFds& fds);
289 #endif // defined(MOZ_WIDGET_ANDROID)
291 void XRE_SetProcessType(const char* aProcessTypeString);
293 nsresult XRE_InitChildProcess(int aArgc, char* aArgv[],
294 const XREChildData* aChildData);
297 * Return the GeckoProcessType of the current process.
299 GeckoProcessType XRE_GetProcessType();
302 * Return the string representation of the GeckoProcessType of the current
303 * process.
305 const char* XRE_GetProcessTypeString();
308 * Returns true when called in the e10s parent process. Does *NOT* return true
309 * when called in the main process if e10s is disabled.
311 bool XRE_IsE10sParentProcess();
314 * Defines XRE_IsParentProcess, XRE_IsContentProcess, etc.
316 * XRE_IsParentProcess is unique in that it returns true when called in
317 * the e10s parent process or called in the main process when e10s is
318 * disabled.
320 #define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
321 process_bin_type, procinfo_typename, \
322 webidl_typename, allcaps_name) \
323 bool XRE_Is##proc_typename##Process();
324 #include "mozilla/GeckoProcessTypes.h"
325 #undef GECKO_PROCESS_TYPE
327 bool XRE_IsSocketProcess();
330 * Returns true if the appshell should run its own native event loop. Returns
331 * false if we should rely solely on the Gecko event loop.
333 bool XRE_UseNativeEventProcessing();
335 typedef void (*MainFunction)(void* aData);
337 int XRE_RunIPDLTest(int aArgc, char* aArgv[]);
339 nsresult XRE_RunAppShell();
341 nsresult XRE_InitCommandLine(int aArgc, char* aArgv[]);
343 nsresult XRE_DeinitCommandLine();
345 void XRE_ShutdownChildProcess();
347 MessageLoop* XRE_GetIOMessageLoop();
349 bool XRE_SendTestShellCommand(JSContext* aCx, JSString* aCommand,
350 JS::Value* aCallback);
351 bool XRE_ShutdownTestShell();
353 void XRE_InstallX11ErrorHandler();
354 void XRE_CleanupX11ErrorHandler();
356 void XRE_TelemetryAccumulate(int aID, uint32_t aSample);
358 void XRE_StartupTimelineRecord(int aEvent, mozilla::TimeStamp aWhen);
360 void XRE_InitOmnijar(nsIFile* aGreOmni, nsIFile* aAppOmni);
361 void XRE_StopLateWriteChecks(void);
363 void XRE_EnableSameExecutableForContentProc();
365 namespace mozilla {
366 enum class BinPathType { Self, PluginContainer };
368 mozilla::BinPathType XRE_GetChildProcBinPathType(GeckoProcessType aProcessType);
370 int XRE_XPCShellMain(int argc, char** argv, char** envp,
371 const XREShellData* aShellData);
373 #ifdef LIBFUZZER
374 # include "FuzzerRegistry.h"
376 void XRE_LibFuzzerSetDriver(LibFuzzerDriver);
378 #endif // LIBFUZZER
380 #ifdef MOZ_ENABLE_FORKSERVER
382 int XRE_ForkServer(int* aArgc, char*** aArgv);
384 #endif // MOZ_ENABLE_FORKSERVER
386 #endif // _nsXULAppAPI_h__