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
;
58 nsresult
AppInfoConstructor(const nsID
& aIID
, void** aResult
);
59 } // namespace mozilla
61 // Exported for gtests.
62 void BuildCompatVersion(const char* aAppVersion
, const char* aAppBuildID
,
63 const char* aToolkitBuildID
, nsACString
& aBuf
);
66 * Compares the provided compatibility versions. Returns 0 if they match,
67 * < 0 if the new version is considered an upgrade from the old version and
68 * > 0 if the new version is considered a downgrade from the old version.
70 int32_t CompareCompatVersions(const nsACString
& aOldCompatVersion
,
71 const nsACString
& aNewCompatVersion
);
74 * Create the nativeappsupport implementation.
76 * @note XPCOMInit has not happened yet.
78 nsresult
NS_CreateNativeAppSupport(nsINativeAppSupport
** aResult
);
79 already_AddRefed
<nsINativeAppSupport
> NS_GetNativeAppSupport();
82 * Try to acquire exclusive access to the specified profile directory.
85 * The profile directory to lock.
87 * The corresponding profile temporary directory.
89 * A callback interface used to attempt to unlock a profile that
90 * appears to be locked.
92 * The resulting profile lock object (or null if the profile could
95 * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile
96 * directory cannot be unlocked.
98 nsresult
NS_LockProfilePath(nsIFile
* aPath
, nsIFile
* aTempPath
,
99 nsIProfileUnlocker
** aUnlocker
,
100 nsIProfileLock
** aResult
);
102 void WriteConsoleLog();
104 void OverrideDefaultLocaleIfNeeded();
107 * Allow exit() calls to complete. This should be done from a proper Gecko
108 * shutdown path. Otherwise we aim to catch improper shutdowns.
110 void MozExpectedExit();
112 class nsINativeAppSupport
;
114 // If aBlankCommandLine is true, then the application will be launched with a
115 // blank command line instead of being launched with the same command line that
116 // it was initially started with.
117 // If aTryExec is true then we use exec on platforms that support it to
118 // remain in the foreground.
119 nsresult
LaunchChild(bool aBlankCommandLine
, bool aTryExec
= false);
121 void UnlockProfile();
125 BOOL
WinLaunchChild(const wchar_t* exePath
, int argc
, char** argv
,
126 HANDLE userToken
= nullptr, HANDLE
* hProcess
= nullptr);
128 # define PREF_WIN_REGISTER_APPLICATION_RESTART \
129 "toolkit.winRegisterApplicationRestart"
131 # define PREF_WIN_ALTERED_DLL_PREFETCH "startup.experiments.alteredDllPrefetch"
133 # if defined(MOZ_LAUNCHER_PROCESS)
134 # define PREF_WIN_LAUNCHER_PROCESS_ENABLED "browser.launcherProcess.enabled"
135 # endif // defined(MOZ_LAUNCHER_PROCESS)
140 Result
<nsCOMPtr
<nsIFile
>, nsresult
> GetIncompleteStartupFile(nsIFile
* aProfLD
);
142 void IncreaseDescriptorLimits();
143 } // namespace startup
145 const char* PlatformBuildID();
149 } // namespace mozilla
152 * Set up platform specific error handling such as suppressing DLL load dialog
153 * and the JIT debugger on Windows, and install unix signal handlers.
155 void SetupErrorHandling(const char* progname
);
157 #ifdef MOZ_ASAN_REPORTER
159 void MOZ_EXPORT
__sanitizer_set_report_path(const char* path
);
161 void setASanReporterPath(nsIFile
* aDir
);
164 bool IsWaylandEnabled();
166 #endif // nsAppRunner_h__