Bug 1753720 [wpt PR 32698] - [FedCM] Perform CSP checks on the provider URL, a=testonly
[gecko.git] / toolkit / xre / nsAppRunner.h
blobbbaca2e14d7395a9fc724ea0bda61762053cf5f0
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 namespace mozilla {
58 nsresult AppInfoConstructor(nsISupports* aOuter, const nsID& aIID,
59 void** aResult);
60 } // namespace mozilla
62 // Exported for gtests.
63 void BuildCompatVersion(const char* aAppVersion, const char* aAppBuildID,
64 const char* aToolkitBuildID, nsACString& aBuf);
66 /**
67 * Compares the provided compatibility versions. Returns 0 if they match,
68 * < 0 if the new version is considered an upgrade from the old version and
69 * > 0 if the new version is considered a downgrade from the old version.
71 int32_t CompareCompatVersions(const nsACString& aOldCompatVersion,
72 const nsACString& aNewCompatVersion);
74 /**
75 * Create the nativeappsupport implementation.
77 * @note XPCOMInit has not happened yet.
79 nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aResult);
80 already_AddRefed<nsINativeAppSupport> NS_GetNativeAppSupport();
82 nsresult NS_NewToolkitProfileService(nsIToolkitProfileService** aResult);
84 nsresult NS_NewToolkitProfileFactory(nsIFactory** aResult);
86 /**
87 * Try to acquire exclusive access to the specified profile directory.
89 * @param aPath
90 * The profile directory to lock.
91 * @param aTempPath
92 * The corresponding profile temporary directory.
93 * @param aUnlocker
94 * A callback interface used to attempt to unlock a profile that
95 * appears to be locked.
96 * @param aResult
97 * The resulting profile lock object (or null if the profile could
98 * not be locked).
100 * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile
101 * directory cannot be unlocked.
103 nsresult NS_LockProfilePath(nsIFile* aPath, nsIFile* aTempPath,
104 nsIProfileUnlocker** aUnlocker,
105 nsIProfileLock** aResult);
107 void WriteConsoleLog();
109 void OverrideDefaultLocaleIfNeeded();
112 * Allow exit() calls to complete. This should be done from a proper Gecko
113 * shutdown path. Otherwise we aim to catch improper shutdowns.
115 void MozExpectedExit();
117 class nsINativeAppSupport;
119 // If aBlankCommandLine is true, then the application will be launched with a
120 // blank command line instead of being launched with the same command line that
121 // it was initially started with.
122 // If aTryExec is true then we use exec on platforms that support it to
123 // remain in the foreground.
124 nsresult LaunchChild(bool aBlankCommandLine, bool aTryExec = false);
126 void UnlockProfile();
128 #ifdef XP_WIN
130 BOOL WinLaunchChild(const wchar_t* exePath, int argc, char** 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 extern GeckoProcessType sChildProcessType;
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 #ifdef MOZ_WAYLAND
170 bool IsWaylandEnabled();
171 #endif
173 #endif // nsAppRunner_h__