|
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/. */ |
|
5 |
|
6 #ifndef nsAppRunner_h__ |
|
7 #define nsAppRunner_h__ |
|
8 |
|
9 #ifdef XP_WIN |
|
10 #include <windows.h> |
|
11 #else |
|
12 #include <limits.h> |
|
13 #endif |
|
14 |
|
15 #ifndef MAXPATHLEN |
|
16 #ifdef PATH_MAX |
|
17 #define MAXPATHLEN PATH_MAX |
|
18 #elif defined(_MAX_PATH) |
|
19 #define MAXPATHLEN _MAX_PATH |
|
20 #elif defined(CCHMAXPATH) |
|
21 #define MAXPATHLEN CCHMAXPATH |
|
22 #else |
|
23 #define MAXPATHLEN 1024 |
|
24 #endif |
|
25 #endif |
|
26 |
|
27 #include "nscore.h" |
|
28 #include "nsXULAppAPI.h" |
|
29 |
|
30 // This directory service key is a lot like NS_APP_LOCALSTORE_50_FILE, |
|
31 // but it is always the "main" localstore file, even when we're in safe mode |
|
32 // and we load localstore from somewhere else. |
|
33 #define NS_LOCALSTORE_UNSAFE_FILE "LStoreS" |
|
34 |
|
35 class nsACString; |
|
36 struct nsStaticModuleInfo; |
|
37 |
|
38 class nsINativeAppSupport; |
|
39 class nsICmdLineService; |
|
40 class nsXREDirProvider; |
|
41 class nsIToolkitProfileService; |
|
42 class nsIFile; |
|
43 class nsIProfileLock; |
|
44 class nsIProfileUnlocker; |
|
45 class nsIFactory; |
|
46 |
|
47 extern nsXREDirProvider* gDirServiceProvider; |
|
48 |
|
49 // NOTE: gAppData will be null in embedded contexts. The "size" parameter |
|
50 // will be the size of the original structure passed to XRE_main, but the |
|
51 // structure will have all of the members available. |
|
52 extern const nsXREAppData* gAppData; |
|
53 extern bool gSafeMode; |
|
54 |
|
55 extern int gArgc; |
|
56 extern char **gArgv; |
|
57 extern int gRestartArgc; |
|
58 extern char **gRestartArgv; |
|
59 extern bool gLogConsoleErrors; |
|
60 |
|
61 /** |
|
62 * Create the nativeappsupport implementation. |
|
63 * |
|
64 * @note XPCOMInit has not happened yet. |
|
65 */ |
|
66 nsresult NS_CreateNativeAppSupport(nsINativeAppSupport* *aResult); |
|
67 |
|
68 NS_HIDDEN_(nsresult) |
|
69 NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult); |
|
70 |
|
71 NS_HIDDEN_(nsresult) |
|
72 NS_NewToolkitProfileFactory(nsIFactory* *aResult); |
|
73 |
|
74 /** |
|
75 * Try to acquire exclusive access to the specified profile directory. |
|
76 * |
|
77 * @param aPath |
|
78 * The profile directory to lock. |
|
79 * @param aTempPath |
|
80 * The corresponding profile temporary directory. |
|
81 * @param aUnlocker |
|
82 * A callback interface used to attempt to unlock a profile that |
|
83 * appears to be locked. |
|
84 * @param aResult |
|
85 * The resulting profile lock object (or null if the profile could |
|
86 * not be locked). |
|
87 * |
|
88 * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile |
|
89 * directory cannot be unlocked. |
|
90 */ |
|
91 NS_HIDDEN_(nsresult) |
|
92 NS_LockProfilePath(nsIFile* aPath, nsIFile* aTempPath, |
|
93 nsIProfileUnlocker* *aUnlocker, nsIProfileLock* *aResult); |
|
94 |
|
95 NS_HIDDEN_(void) |
|
96 WriteConsoleLog(); |
|
97 |
|
98 #ifdef XP_WIN |
|
99 BOOL |
|
100 WinLaunchChild(const wchar_t *exePath, int argc, |
|
101 char **argv, HANDLE userToken = nullptr, |
|
102 HANDLE *hProcess = nullptr); |
|
103 BOOL |
|
104 WriteStatusPending(LPCWSTR updateDirPath); |
|
105 BOOL |
|
106 WriteStatusApplied(LPCWSTR updateDirPath); |
|
107 #endif |
|
108 |
|
109 #define NS_NATIVEAPPSUPPORT_CONTRACTID "@mozilla.org/toolkit/native-app-support;1" |
|
110 |
|
111 namespace mozilla { |
|
112 namespace startup { |
|
113 extern GeckoProcessType sChildProcessType; |
|
114 } |
|
115 } |
|
116 |
|
117 /** |
|
118 * Set up platform specific error handling such as suppressing DLL load dialog |
|
119 * and the JIT debugger on Windows, and install unix signal handlers. |
|
120 */ |
|
121 void SetupErrorHandling(const char* progname); |
|
122 |
|
123 #endif // nsAppRunner_h__ |