OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ | 5 #ifndef CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ |
6 #define CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ | 6 #define CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ |
7 | 7 |
| 8 #include <assert.h> |
| 9 |
8 #include <memory> | 10 #include <memory> |
9 #include <string> | 11 #include <string> |
10 | 12 |
11 #include "chrome/install_static/install_constants.h" | 13 #include "chrome/install_static/install_constants.h" |
12 #include "chrome/install_static/install_modes.h" | 14 #include "chrome/install_static/install_modes.h" |
| 15 #include "chrome/install_static/install_util.h" |
13 | 16 |
14 namespace install_static { | 17 namespace install_static { |
15 | 18 |
16 class PrimaryInstallDetails; | 19 class PrimaryInstallDetails; |
17 class ScopedInstallDetails; | 20 class ScopedInstallDetails; |
18 | 21 |
19 // Details relating to how Chrome is installed. This class and | 22 // Details relating to how Chrome is installed or being run. This class and |
20 // PrimaryInstallDetails (below) are used in tandem so that one instance of the | 23 // PrimaryInstallDetails (below) are used in tandem so that one instance of the |
21 // latter may be initialized early during process startup and then shared with | 24 // latter may be initialized early during process startup and then shared with |
22 // other modules in the process. For example, chrome_elf creates the instance | 25 // other modules in the process. For example, chrome_elf creates the instance |
23 // for a Chrome process and exports a GetInstallDetailsPayload function used by | 26 // for a Chrome process and exports a GetInstallDetailsPayload function used by |
24 // chrome.exe and chrome.dll to create their own module-specific instances | 27 // chrome.exe and chrome.dll to create their own module-specific instances |
25 // referring to the same underlying payload. See install_modes.h for a gentle | 28 // referring to the same underlying payload. See install_modes.h for a gentle |
26 // introduction to such terms as "brand" and "mode". | 29 // introduction to such terms as "brand" and "mode". |
27 class InstallDetails { | 30 class InstallDetails { |
28 public: | 31 public: |
29 // A POD-struct containing the underlying data for an InstallDetails | 32 // A POD-struct containing the underlying data for an InstallDetails |
(...skipping 22 matching lines...) Expand all Loading... |
52 // The "ap" (additional parameters) value read from Chrome's ClientState key | 55 // The "ap" (additional parameters) value read from Chrome's ClientState key |
53 // during process startup. | 56 // during process startup. |
54 const wchar_t* update_ap; | 57 const wchar_t* update_ap; |
55 | 58 |
56 // The "name" value read from Chrome's ClientState\cohort key during process | 59 // The "name" value read from Chrome's ClientState\cohort key during process |
57 // startup. | 60 // startup. |
58 const wchar_t* update_cohort_name; | 61 const wchar_t* update_cohort_name; |
59 | 62 |
60 // True if installed in C:\Program Files{, {x86)}; otherwise, false. | 63 // True if installed in C:\Program Files{, {x86)}; otherwise, false. |
61 bool system_level; | 64 bool system_level; |
| 65 |
| 66 // The user data directory. |
| 67 const wchar_t* user_data_dir; |
62 }; | 68 }; |
63 | 69 |
64 InstallDetails(const InstallDetails&) = delete; | 70 InstallDetails(const InstallDetails&) = delete; |
65 InstallDetails(InstallDetails&&) = delete; | 71 InstallDetails(InstallDetails&&) = delete; |
66 InstallDetails& operator=(const InstallDetails&) = delete; | 72 InstallDetails& operator=(const InstallDetails&) = delete; |
67 virtual ~InstallDetails() = default; | 73 virtual ~InstallDetails() = default; |
68 | 74 |
69 // Returns the instance for this module. | 75 // Returns the instance for this module. |
70 static const InstallDetails& Get(); | 76 static const InstallDetails& Get(); |
71 | 77 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Returns the "name" value read from Chrome's ClientState\cohort key during | 151 // Returns the "name" value read from Chrome's ClientState\cohort key during |
146 // process startup. | 152 // process startup. |
147 std::wstring update_cohort_name() const { | 153 std::wstring update_cohort_name() const { |
148 return payload_->update_cohort_name | 154 return payload_->update_cohort_name |
149 ? std::wstring(payload_->update_cohort_name) | 155 ? std::wstring(payload_->update_cohort_name) |
150 : std::wstring(); | 156 : std::wstring(); |
151 } | 157 } |
152 | 158 |
153 bool system_level() const { return payload_->system_level; } | 159 bool system_level() const { return payload_->system_level; } |
154 | 160 |
| 161 std::wstring user_data_dir() const { |
| 162 assert(CurrentProcessNeedsProfileDir()); |
| 163 return payload_->user_data_dir ? std::wstring(payload_->user_data_dir) |
| 164 : std::wstring(); |
| 165 } |
| 166 |
155 // Returns the path to the installation's ClientState registry key. This | 167 // Returns the path to the installation's ClientState registry key. This |
156 // registry key is used to hold various installation-related values, including | 168 // registry key is used to hold various installation-related values, including |
157 // an indication of consent for usage stats. | 169 // an indication of consent for usage stats. |
158 std::wstring GetClientStateKeyPath() const; | 170 std::wstring GetClientStateKeyPath() const; |
159 | 171 |
160 // Returns the path to the installation's ClientStateMedium registry key. This | 172 // Returns the path to the installation's ClientStateMedium registry key. This |
161 // registry key is used to hold various installation-related values, including | 173 // registry key is used to hold various installation-related values, including |
162 // an indication of consent for usage stats for a system-level install. | 174 // an indication of consent for usage stats for a system-level install. |
163 std::wstring GetClientStateMediumKeyPath() const; | 175 std::wstring GetClientStateMediumKeyPath() const; |
164 | 176 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // class is initialized early on in process startup (e.g., in chrome_elf for the | 211 // class is initialized early on in process startup (e.g., in chrome_elf for the |
200 // case of chrome.exe; see InitializeProductDetailsForPrimaryModule). Its | 212 // case of chrome.exe; see InitializeProductDetailsForPrimaryModule). Its |
201 // underlying data (its "payload") is shared with other interested modules in | 213 // underlying data (its "payload") is shared with other interested modules in |
202 // the process. | 214 // the process. |
203 class PrimaryInstallDetails : public InstallDetails { | 215 class PrimaryInstallDetails : public InstallDetails { |
204 public: | 216 public: |
205 PrimaryInstallDetails(); | 217 PrimaryInstallDetails(); |
206 PrimaryInstallDetails(const PrimaryInstallDetails&) = delete; | 218 PrimaryInstallDetails(const PrimaryInstallDetails&) = delete; |
207 PrimaryInstallDetails(PrimaryInstallDetails&&) = delete; | 219 PrimaryInstallDetails(PrimaryInstallDetails&&) = delete; |
208 PrimaryInstallDetails& operator=(const PrimaryInstallDetails&) = delete; | 220 PrimaryInstallDetails& operator=(const PrimaryInstallDetails&) = delete; |
| 221 ~PrimaryInstallDetails() override; |
209 | 222 |
210 void set_mode(const InstallConstants* mode) { payload_.mode = mode; } | 223 void set_mode(const InstallConstants* mode) { payload_.mode = mode; } |
211 void set_channel(const std::wstring& channel) { | 224 void set_channel(const std::wstring& channel) { |
212 channel_ = channel; | 225 channel_ = channel; |
213 payload_.channel = channel_.c_str(); | 226 payload_.channel = channel_.c_str(); |
214 payload_.channel_length = channel_.size(); | 227 payload_.channel_length = channel_.size(); |
215 } | 228 } |
216 void set_update_ap(const std::wstring& update_ap) { | 229 void set_update_ap(const std::wstring& update_ap) { |
217 update_ap_ = update_ap; | 230 update_ap_ = update_ap; |
218 payload_.update_ap = update_ap_.c_str(); | 231 payload_.update_ap = update_ap_.c_str(); |
219 } | 232 } |
220 void set_update_cohort_name(const std::wstring& update_cohort_name) { | 233 void set_update_cohort_name(const std::wstring& update_cohort_name) { |
221 update_cohort_name_ = update_cohort_name; | 234 update_cohort_name_ = update_cohort_name; |
222 payload_.update_cohort_name = update_cohort_name_.c_str(); | 235 payload_.update_cohort_name = update_cohort_name_.c_str(); |
223 } | 236 } |
224 void set_system_level(bool system_level) { | 237 void set_system_level(bool system_level) { |
225 payload_.system_level = system_level; | 238 payload_.system_level = system_level; |
226 } | 239 } |
| 240 void set_user_data_dir(const std::wstring& user_data_dir) { |
| 241 user_data_dir_ = user_data_dir; |
| 242 payload_.user_data_dir = user_data_dir_.c_str(); |
| 243 } |
227 | 244 |
228 private: | 245 private: |
229 std::wstring channel_; | 246 std::wstring channel_; |
230 std::wstring update_ap_; | 247 std::wstring update_ap_; |
231 std::wstring update_cohort_name_; | 248 std::wstring update_cohort_name_; |
| 249 std::wstring user_data_dir_; |
232 Payload payload_ = Payload(); | 250 Payload payload_ = Payload(); |
233 }; | 251 }; |
234 | 252 |
235 } // namespace install_static | 253 } // namespace install_static |
236 | 254 |
237 #endif // CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ | 255 #endif // CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ |
OLD | NEW |