1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsAppRunner_h__
7 #define nsAppRunner_h__
11 # include "mozilla/WindowsConsole.h"
18 # define MAXPATHLEN PATH_MAX
19 # elif defined(_MAX_PATH)
20 # define MAXPATHLEN _MAX_PATH
21 # elif defined(CCHMAXPATH)
22 # define MAXPATHLEN CCHMAXPATH
24 # define MAXPATHLEN 1024
29 #include "nsStringFwd.h"
30 #include "nsXULAppAPI.h"
32 class nsINativeAppSupport
;
33 class nsXREDirProvider
;
34 class nsIToolkitProfileService
;
37 class nsIProfileUnlocker
;
40 extern nsXREDirProvider
* gDirServiceProvider
;
42 // NOTE: gAppData will be null in embedded contexts.
43 extern const mozilla::XREAppData
* gAppData
;
44 extern bool gSafeMode
;
45 extern bool gFxREmbedded
;
49 extern int gRestartArgc
;
50 extern char** gRestartArgv
;
51 extern bool gRestartedByOS
;
52 extern bool gLogConsoleErrors
;
53 extern nsString gAbsoluteArgv0Path
;
57 extern bool gKioskMode
;
58 extern int gKioskMonitor
;
59 extern bool gAllowContentAnalysisArgPresent
;
62 nsresult
AppInfoConstructor(const nsID
& aIID
, void** aResult
);
63 } // namespace mozilla
65 // Exported for gtests.
66 void BuildCompatVersion(const char* aAppVersion
, const char* aAppBuildID
,
67 const char* aToolkitBuildID
, nsACString
& aBuf
);
70 * Compares the provided compatibility versions. Returns 0 if they match,
71 * < 0 if the new version is considered an upgrade from the old version and
72 * > 0 if the new version is considered a downgrade from the old version.
74 int32_t CompareCompatVersions(const nsACString
& aOldCompatVersion
,
75 const nsACString
& aNewCompatVersion
);
78 * Create the nativeappsupport implementation.
80 * @note XPCOMInit has not happened yet.
82 nsresult
NS_CreateNativeAppSupport(nsINativeAppSupport
** aResult
);
83 already_AddRefed
<nsINativeAppSupport
> NS_GetNativeAppSupport();
86 * Try to acquire exclusive access to the specified profile directory.
89 * The profile directory to lock.
91 * The corresponding profile temporary directory.
93 * A callback interface used to attempt to unlock a profile that
94 * appears to be locked.
96 * The resulting profile lock object (or null if the profile could
99 * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile
100 * directory cannot be unlocked.
102 nsresult
NS_LockProfilePath(nsIFile
* aPath
, nsIFile
* aTempPath
,
103 nsIProfileUnlocker
** aUnlocker
,
104 nsIProfileLock
** aResult
);
106 void WriteConsoleLog();
109 * Allow exit() calls to complete. This should be done from a proper Gecko
110 * shutdown path. Otherwise we aim to catch improper shutdowns.
112 void MozExpectedExit();
114 class nsINativeAppSupport
;
116 // If aBlankCommandLine is true, then the application will be launched with a
117 // blank command line instead of being launched with the same command line that
118 // it was initially started with.
119 // If aTryExec is true then we use exec on platforms that support it to
120 // remain in the foreground.
121 nsresult
LaunchChild(bool aBlankCommandLine
, bool aTryExec
= false);
123 void UnlockProfile();
127 BOOL
WinLaunchChild(const wchar_t* exePath
, int argc
, char** argv
,
128 HANDLE userToken
= nullptr, HANDLE
* hProcess
= nullptr);
130 BOOL
WinLaunchChild(const wchar_t* exePath
, int argc
, wchar_t** argv
,
131 HANDLE userToken
= nullptr, HANDLE
* hProcess
= nullptr);
133 # define PREF_WIN_REGISTER_APPLICATION_RESTART \
134 "toolkit.winRegisterApplicationRestart"
136 # define PREF_WIN_ALTERED_DLL_PREFETCH "startup.experiments.alteredDllPrefetch"
138 # if defined(MOZ_LAUNCHER_PROCESS)
139 # define PREF_WIN_LAUNCHER_PROCESS_ENABLED "browser.launcherProcess.enabled"
140 # endif // defined(MOZ_LAUNCHER_PROCESS)
145 Result
<nsCOMPtr
<nsIFile
>, nsresult
> GetIncompleteStartupFile(nsIFile
* aProfLD
);
147 void IncreaseDescriptorLimits();
148 } // namespace startup
150 const char* PlatformBuildID();
154 } // namespace mozilla
157 * Set up platform specific error handling such as suppressing DLL load dialog
158 * and the JIT debugger on Windows, and install unix signal handlers.
160 void SetupErrorHandling(const char* progname
);
162 #ifdef MOZ_ASAN_REPORTER
164 void MOZ_EXPORT
__sanitizer_set_report_path(const char* path
);
166 void setASanReporterPath(nsIFile
* aDir
);
169 bool IsWaylandEnabled();
171 #endif // nsAppRunner_h__