Bug 1885602 - Part 4: Implement navigating to the settings from the menu header for...
[gecko.git] / toolkit / xre / nsAppRunner.h
blobb38a3dc34952fac5da2dfa0a02f42e4ca616e693
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__
9 #ifdef XP_WIN
10 # include <windows.h>
11 # include "mozilla/WindowsConsole.h"
12 #else
13 # include <limits.h>
14 #endif
16 #ifndef MAXPATHLEN
17 # ifdef PATH_MAX
18 # define MAXPATHLEN PATH_MAX
19 # elif defined(_MAX_PATH)
20 # define MAXPATHLEN _MAX_PATH
21 # elif defined(CCHMAXPATH)
22 # define MAXPATHLEN CCHMAXPATH
23 # else
24 # define MAXPATHLEN 1024
25 # endif
26 #endif
28 #include "nsCOMPtr.h"
29 #include "nsStringFwd.h"
30 #include "nsXULAppAPI.h"
32 class nsINativeAppSupport;
33 class nsXREDirProvider;
34 class nsIToolkitProfileService;
35 class nsIFile;
36 class nsIProfileLock;
37 class nsIProfileUnlocker;
38 class nsIFactory;
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;
47 extern int gArgc;
48 extern char** gArgv;
49 extern int gRestartArgc;
50 extern char** gRestartArgv;
51 extern bool gRestartedByOS;
52 extern bool gLogConsoleErrors;
53 extern nsString gAbsoluteArgv0Path;
55 extern bool gIsGtest;
57 extern bool gKioskMode;
58 extern int gKioskMonitor;
59 extern bool gAllowContentAnalysisArgPresent;
61 namespace mozilla {
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);
69 /**
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);
77 /**
78 * Create the nativeappsupport implementation.
80 * @note XPCOMInit has not happened yet.
82 nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aResult);
83 already_AddRefed<nsINativeAppSupport> NS_GetNativeAppSupport();
85 /**
86 * Try to acquire exclusive access to the specified profile directory.
88 * @param aPath
89 * The profile directory to lock.
90 * @param aTempPath
91 * The corresponding profile temporary directory.
92 * @param aUnlocker
93 * A callback interface used to attempt to unlock a profile that
94 * appears to be locked.
95 * @param aResult
96 * The resulting profile lock object (or null if the profile could
97 * not be locked).
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();
125 #ifdef XP_WIN
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)
141 #endif
143 namespace mozilla {
144 namespace startup {
145 Result<nsCOMPtr<nsIFile>, nsresult> GetIncompleteStartupFile(nsIFile* aProfLD);
147 void IncreaseDescriptorLimits();
148 } // namespace startup
150 const char* PlatformBuildID();
152 bool RunningGTest();
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
163 extern "C" {
164 void MOZ_EXPORT __sanitizer_set_report_path(const char* path);
166 void setASanReporterPath(nsIFile* aDir);
167 #endif
169 bool IsWaylandEnabled();
171 #endif // nsAppRunner_h__