Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / xpcom / build / XREAppData.h
blob61572dfc762ae2990f01470cde56d4ddfdac273a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsXREAppData_h
8 #define nsXREAppData_h
10 #include <stdint.h>
11 #include "mozilla/Attributes.h"
12 #include "mozilla/UniquePtrExtensions.h"
13 #include "nsCOMPtr.h"
14 #include "nsCRTGlue.h"
15 #include "nsStringFwd.h"
16 #include "nsIFile.h"
18 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
19 namespace sandbox {
20 class BrokerServices;
22 #endif
24 namespace mozilla {
26 struct StaticXREAppData;
28 /**
29 * Application-specific data needed to start the apprunner.
31 class XREAppData {
32 public:
33 XREAppData() = default;
34 ~XREAppData() = default;
35 XREAppData(const XREAppData& aOther) { *this = aOther; }
37 explicit XREAppData(const StaticXREAppData& aOther) { *this = aOther; }
39 XREAppData& operator=(const StaticXREAppData& aOther);
40 XREAppData& operator=(const XREAppData& aOther);
41 XREAppData& operator=(XREAppData&& aOther) = default;
43 // Lots of code reads these fields directly like a struct, so rather
44 // than using UniquePtr directly, use an auto-converting wrapper.
45 class CharPtr {
46 public:
47 explicit CharPtr() = default;
48 explicit CharPtr(const char* v) { *this = v; }
49 CharPtr(CharPtr&&) = default;
50 ~CharPtr() = default;
52 CharPtr& operator=(const char* v) {
53 if (v) {
54 mValue.reset(NS_xstrdup(v));
55 } else {
56 mValue = nullptr;
58 return *this;
60 CharPtr& operator=(const CharPtr& v) {
61 *this = (const char*)v;
62 return *this;
65 operator const char*() const { return mValue.get(); }
67 private:
68 UniqueFreePtr<const char> mValue;
71 /**
72 * The directory of the application to be run. May be null if the
73 * xulrunner and the app are installed into the same directory.
75 nsCOMPtr<nsIFile> directory;
77 /**
78 * The name of the application vendor. This must be ASCII, and is normally
79 * mixed-case, e.g. "Mozilla". Optional (may be null), but highly
80 * recommended. Must not be the empty string.
82 CharPtr vendor;
84 /**
85 * The name of the application. This must be ASCII, and is normally
86 * mixed-case, e.g. "Firefox". Required (must not be null or an empty
87 * string).
89 CharPtr name;
91 /**
92 * The internal name of the application for remoting purposes. When left
93 * unspecified, "name" is used instead. This must be ASCII, and is normally
94 * lowercase, e.g. "firefox". Optional (may be null but not an empty string).
96 CharPtr remotingName;
98 /**
99 * The major version, e.g. "0.8.0+". Optional (may be null), but
100 * required for advanced application features such as the extension
101 * manager and update service. Must not be the empty string.
103 CharPtr version;
106 * The application's build identifier, e.g. "2004051604"
108 CharPtr buildID;
111 * The application's UUID. Used by the extension manager to determine
112 * compatible extensions. Optional, but required for advanced application
113 * features such as the extension manager and update service.
115 * This has traditionally been in the form
116 * "{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" but for new applications
117 * a more readable form is encouraged: "appname@vendor.tld". Only
118 * the following characters are allowed: a-z A-Z 0-9 - . @ _ { } *
120 CharPtr ID;
123 * The copyright information to print for the -h commandline flag,
124 * e.g. "Copyright (c) 2003 mozilla.org".
126 CharPtr copyright;
129 * Combination of NS_XRE_ prefixed flags (defined below).
131 uint32_t flags = 0;
134 * The location of the XRE. XRE_main may not be able to figure this out
135 * programatically.
137 nsCOMPtr<nsIFile> xreDirectory;
140 * The minimum/maximum compatible XRE version.
142 CharPtr minVersion;
143 CharPtr maxVersion;
146 * The server URL to send crash reports to.
148 CharPtr crashReporterURL;
151 * The profile directory that will be used. Optional (may be null). Must not
152 * be the empty string, must be ASCII. The path is split into components
153 * along the path separator characters '/' and '\'.
155 * The application data directory ("UAppData", see below) is normally
156 * composed as follows, where $HOME is platform-specific:
158 * UAppData = $HOME[/$vendor]/$name
160 * If present, the 'profile' string will be used instead of the combination of
161 * vendor and name as follows:
163 * UAppData = $HOME/$profile
165 CharPtr profile;
168 * The application name to use in the User Agent string.
170 CharPtr UAName;
173 * The URL to the source revision for this build of the application.
175 CharPtr sourceURL;
178 * The URL to use to check for updates.
180 CharPtr updateURL;
182 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
184 * Chromium sandbox BrokerServices.
186 sandbox::BrokerServices* sandboxBrokerServices = nullptr;
187 #endif
189 // Returns a name suitable for DBUS services.
190 static void SanitizeNameForDBus(nsACString&);
191 void GetDBusAppName(nsACString&) const;
195 * Indicates whether or not the profile migrator service may be
196 * invoked at startup when creating a profile.
198 #define NS_XRE_ENABLE_PROFILE_MIGRATOR (1 << 1)
201 * Indicates whether or not to use Breakpad crash reporting.
203 #define NS_XRE_ENABLE_CRASH_REPORTER (1 << 3)
206 * A static version of the XRE app data is compiled into the application
207 * so that it is not necessary to read application.ini at startup.
209 * This structure is initialized into and matches nsXREAppData
211 struct StaticXREAppData {
212 const char* vendor;
213 const char* name;
214 const char* remotingName;
215 const char* version;
216 const char* buildID;
217 const char* ID;
218 const char* copyright;
219 uint32_t flags;
220 const char* minVersion;
221 const char* maxVersion;
222 const char* crashReporterURL;
223 const char* profile;
224 const char* UAName;
225 const char* sourceURL;
226 const char* updateURL;
229 } // namespace mozilla
231 #endif // XREAppData_h