/work/obj-fuzz/dist/include/mozilla/XREAppData.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef nsXREAppData_h |
8 | | #define nsXREAppData_h |
9 | | |
10 | | #include <stdint.h> |
11 | | #include "mozilla/Attributes.h" |
12 | | #include "mozilla/UniquePtrExtensions.h" |
13 | | #include "nsCOMPtr.h" |
14 | | #include "nsCRTGlue.h" |
15 | | #include "nsIFile.h" |
16 | | |
17 | | #if defined(XP_WIN) && defined(MOZ_SANDBOX) |
18 | | namespace sandbox { |
19 | | class BrokerServices; |
20 | | } |
21 | | namespace mozilla { |
22 | | namespace sandboxing { |
23 | | class PermissionsService; |
24 | | } |
25 | | } |
26 | | #endif |
27 | | |
28 | | namespace mozilla { |
29 | | |
30 | | struct StaticXREAppData; |
31 | | |
32 | | /** |
33 | | * Application-specific data needed to start the apprunner. |
34 | | */ |
35 | | class XREAppData |
36 | | { |
37 | | public: |
38 | 0 | XREAppData() { } |
39 | 0 | ~XREAppData() { } |
40 | | XREAppData(const XREAppData& aOther) |
41 | 0 | { |
42 | 0 | *this = aOther; |
43 | 0 | } |
44 | | |
45 | | explicit XREAppData(const StaticXREAppData& aOther) |
46 | 0 | { |
47 | 0 | *this = aOther; |
48 | 0 | } |
49 | | |
50 | | XREAppData& operator=(const StaticXREAppData& aOther); |
51 | | XREAppData& operator=(const XREAppData& aOther); |
52 | | XREAppData& operator=(XREAppData&& aOther) = default; |
53 | | |
54 | | // Lots of code reads these fields directly like a struct, so rather |
55 | | // than using UniquePtr directly, use an auto-converting wrapper. |
56 | | class CharPtr |
57 | | { |
58 | | public: |
59 | 39 | explicit CharPtr() = default; |
60 | | explicit CharPtr(const char* v) |
61 | 0 | { |
62 | 0 | *this = v; |
63 | 0 | } |
64 | | CharPtr(CharPtr&&) = default; |
65 | 0 | ~CharPtr() = default; |
66 | | |
67 | | CharPtr& operator=(const char* v) |
68 | | { |
69 | | if (v) { |
70 | | mValue.reset(NS_xstrdup(v)); |
71 | | } else { |
72 | | mValue = nullptr; |
73 | | } |
74 | | return *this; |
75 | | } |
76 | | CharPtr& operator=(const CharPtr& v) |
77 | 0 | { |
78 | 0 | *this = (const char*) v; |
79 | 0 | return *this; |
80 | 0 | } |
81 | | |
82 | | operator const char*() const { |
83 | | return mValue.get(); |
84 | | } |
85 | | |
86 | | private: |
87 | | UniqueFreePtr<const char> mValue; |
88 | | }; |
89 | | |
90 | | /** |
91 | | * The directory of the application to be run. May be null if the |
92 | | * xulrunner and the app are installed into the same directory. |
93 | | */ |
94 | | nsCOMPtr<nsIFile> directory; |
95 | | |
96 | | /** |
97 | | * The name of the application vendor. This must be ASCII, and is normally |
98 | | * mixed-case, e.g. "Mozilla". Optional (may be null), but highly |
99 | | * recommended. Must not be the empty string. |
100 | | */ |
101 | | CharPtr vendor; |
102 | | |
103 | | /** |
104 | | * The name of the application. This must be ASCII, and is normally |
105 | | * mixed-case, e.g. "Firefox". Required (must not be null or an empty |
106 | | * string). |
107 | | */ |
108 | | CharPtr name; |
109 | | |
110 | | /** |
111 | | * The internal name of the application for remoting purposes. When left |
112 | | * unspecified, "name" is used instead. This must be ASCII, and is normally |
113 | | * lowercase, e.g. "firefox". Optional (may be null but not an empty string). |
114 | | */ |
115 | | CharPtr remotingName; |
116 | | |
117 | | /** |
118 | | * The major version, e.g. "0.8.0+". Optional (may be null), but |
119 | | * required for advanced application features such as the extension |
120 | | * manager and update service. Must not be the empty string. |
121 | | */ |
122 | | CharPtr version; |
123 | | |
124 | | /** |
125 | | * The application's build identifier, e.g. "2004051604" |
126 | | */ |
127 | | CharPtr buildID; |
128 | | |
129 | | /** |
130 | | * The application's UUID. Used by the extension manager to determine |
131 | | * compatible extensions. Optional, but required for advanced application |
132 | | * features such as the extension manager and update service. |
133 | | * |
134 | | * This has traditionally been in the form |
135 | | * "{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" but for new applications |
136 | | * a more readable form is encouraged: "appname@vendor.tld". Only |
137 | | * the following characters are allowed: a-z A-Z 0-9 - . @ _ { } * |
138 | | */ |
139 | | CharPtr ID; |
140 | | |
141 | | /** |
142 | | * The copyright information to print for the -h commandline flag, |
143 | | * e.g. "Copyright (c) 2003 mozilla.org". |
144 | | */ |
145 | | CharPtr copyright; |
146 | | |
147 | | /** |
148 | | * Combination of NS_XRE_ prefixed flags (defined below). |
149 | | */ |
150 | | uint32_t flags = 0; |
151 | | |
152 | | /** |
153 | | * The location of the XRE. XRE_main may not be able to figure this out |
154 | | * programatically. |
155 | | */ |
156 | | nsCOMPtr<nsIFile> xreDirectory; |
157 | | |
158 | | /** |
159 | | * The minimum/maximum compatible XRE version. |
160 | | */ |
161 | | CharPtr minVersion; |
162 | | CharPtr maxVersion; |
163 | | |
164 | | /** |
165 | | * The server URL to send crash reports to. |
166 | | */ |
167 | | CharPtr crashReporterURL; |
168 | | |
169 | | /** |
170 | | * The profile directory that will be used. Optional (may be null). Must not |
171 | | * be the empty string, must be ASCII. The path is split into components |
172 | | * along the path separator characters '/' and '\'. |
173 | | * |
174 | | * The application data directory ("UAppData", see below) is normally |
175 | | * composed as follows, where $HOME is platform-specific: |
176 | | * |
177 | | * UAppData = $HOME[/$vendor]/$name |
178 | | * |
179 | | * If present, the 'profile' string will be used instead of the combination of |
180 | | * vendor and name as follows: |
181 | | * |
182 | | * UAppData = $HOME/$profile |
183 | | */ |
184 | | CharPtr profile; |
185 | | |
186 | | /** |
187 | | * The application name to use in the User Agent string. |
188 | | */ |
189 | | CharPtr UAName; |
190 | | |
191 | | /** |
192 | | * The URL to the source revision for this build of the application. |
193 | | */ |
194 | | CharPtr sourceURL; |
195 | | |
196 | | #if defined(XP_WIN) && defined(MOZ_SANDBOX) |
197 | | /** |
198 | | * Chromium sandbox BrokerServices. |
199 | | */ |
200 | | sandbox::BrokerServices* sandboxBrokerServices = nullptr; |
201 | | mozilla::sandboxing::PermissionsService* sandboxPermissionsService; |
202 | | #endif |
203 | | }; |
204 | | |
205 | | /** |
206 | | * Indicates whether or not the profile migrator service may be |
207 | | * invoked at startup when creating a profile. |
208 | | */ |
209 | 0 | #define NS_XRE_ENABLE_PROFILE_MIGRATOR (1 << 1) |
210 | | |
211 | | /** |
212 | | * Indicates whether or not to use Breakpad crash reporting. |
213 | | */ |
214 | 6 | #define NS_XRE_ENABLE_CRASH_REPORTER (1 << 3) |
215 | | |
216 | | /** |
217 | | * A static version of the XRE app data is compiled into the application |
218 | | * so that it is not necessary to read application.ini at startup. |
219 | | * |
220 | | * This structure is initialized into and matches nsXREAppData |
221 | | */ |
222 | | struct StaticXREAppData |
223 | | { |
224 | | const char* vendor; |
225 | | const char* name; |
226 | | const char* remotingName; |
227 | | const char* version; |
228 | | const char* buildID; |
229 | | const char* ID; |
230 | | const char* copyright; |
231 | | uint32_t flags; |
232 | | const char* minVersion; |
233 | | const char* maxVersion; |
234 | | const char* crashReporterURL; |
235 | | const char* profile; |
236 | | const char* UAName; |
237 | | const char* sourceURL; |
238 | | }; |
239 | | |
240 | | } // namespace mozilla |
241 | | |
242 | | #endif // XREAppData_h |