| 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. An empty value is interpreted as a failure to |
| 67 // determine the user data directory. |
| 68 const wchar_t* user_data_dir; |
| 69 |
| 70 // An invalid user data directory that was provided by the user, or the |
| 71 // empty string. |
| 72 const wchar_t* invalid_user_data_dir; |
| 62 }; | 73 }; |
| 63 | 74 |
| 64 InstallDetails(const InstallDetails&) = delete; | 75 InstallDetails(const InstallDetails&) = delete; |
| 65 InstallDetails(InstallDetails&&) = delete; | 76 InstallDetails(InstallDetails&&) = delete; |
| 66 InstallDetails& operator=(const InstallDetails&) = delete; | 77 InstallDetails& operator=(const InstallDetails&) = delete; |
| 67 virtual ~InstallDetails() = default; | 78 virtual ~InstallDetails() = default; |
| 68 | 79 |
| 69 // Returns the instance for this module. | 80 // Returns the instance for this module. |
| 70 static const InstallDetails& Get(); | 81 static const InstallDetails& Get(); |
| 71 | 82 |
| (...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 | 156 // Returns the "name" value read from Chrome's ClientState\cohort key during |
| 146 // process startup. | 157 // process startup. |
| 147 std::wstring update_cohort_name() const { | 158 std::wstring update_cohort_name() const { |
| 148 return payload_->update_cohort_name | 159 return payload_->update_cohort_name |
| 149 ? std::wstring(payload_->update_cohort_name) | 160 ? std::wstring(payload_->update_cohort_name) |
| 150 : std::wstring(); | 161 : std::wstring(); |
| 151 } | 162 } |
| 152 | 163 |
| 153 bool system_level() const { return payload_->system_level; } | 164 bool system_level() const { return payload_->system_level; } |
| 154 | 165 |
| 166 std::wstring user_data_dir() const { |
| 167 assert(CurrentProcessNeedsProfileDir()); |
| 168 return payload_->user_data_dir ? std::wstring(payload_->user_data_dir) |
| 169 : std::wstring(); |
| 170 } |
| 171 |
| 172 std::wstring invalid_user_data_dir() const { |
| 173 assert(CurrentProcessNeedsProfileDir()); |
| 174 return payload_->invalid_user_data_dir |
| 175 ? std::wstring(payload_->invalid_user_data_dir) |
| 176 : std::wstring(); |
| 177 } |
| 178 |
| 155 // Returns the path to the installation's ClientState registry key. This | 179 // Returns the path to the installation's ClientState registry key. This |
| 156 // registry key is used to hold various installation-related values, including | 180 // registry key is used to hold various installation-related values, including |
| 157 // an indication of consent for usage stats. | 181 // an indication of consent for usage stats. |
| 158 std::wstring GetClientStateKeyPath() const; | 182 std::wstring GetClientStateKeyPath() const; |
| 159 | 183 |
| 160 // Returns the path to the installation's ClientStateMedium registry key. This | 184 // Returns the path to the installation's ClientStateMedium registry key. This |
| 161 // registry key is used to hold various installation-related values, including | 185 // registry key is used to hold various installation-related values, including |
| 162 // an indication of consent for usage stats for a system-level install. | 186 // an indication of consent for usage stats for a system-level install. |
| 163 std::wstring GetClientStateMediumKeyPath() const; | 187 std::wstring GetClientStateMediumKeyPath() const; |
| 164 | 188 |
| (...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 | 223 // class is initialized early on in process startup (e.g., in chrome_elf for the |
| 200 // case of chrome.exe; see InitializeProductDetailsForPrimaryModule). Its | 224 // case of chrome.exe; see InitializeProductDetailsForPrimaryModule). Its |
| 201 // underlying data (its "payload") is shared with other interested modules in | 225 // underlying data (its "payload") is shared with other interested modules in |
| 202 // the process. | 226 // the process. |
| 203 class PrimaryInstallDetails : public InstallDetails { | 227 class PrimaryInstallDetails : public InstallDetails { |
| 204 public: | 228 public: |
| 205 PrimaryInstallDetails(); | 229 PrimaryInstallDetails(); |
| 206 PrimaryInstallDetails(const PrimaryInstallDetails&) = delete; | 230 PrimaryInstallDetails(const PrimaryInstallDetails&) = delete; |
| 207 PrimaryInstallDetails(PrimaryInstallDetails&&) = delete; | 231 PrimaryInstallDetails(PrimaryInstallDetails&&) = delete; |
| 208 PrimaryInstallDetails& operator=(const PrimaryInstallDetails&) = delete; | 232 PrimaryInstallDetails& operator=(const PrimaryInstallDetails&) = delete; |
| 233 ~PrimaryInstallDetails() override; |
| 209 | 234 |
| 210 void set_mode(const InstallConstants* mode) { payload_.mode = mode; } | 235 void set_mode(const InstallConstants* mode) { payload_.mode = mode; } |
| 211 void set_channel(const std::wstring& channel) { | 236 void set_channel(const std::wstring& channel) { |
| 212 channel_ = channel; | 237 channel_ = channel; |
| 213 payload_.channel = channel_.c_str(); | 238 payload_.channel = channel_.c_str(); |
| 214 payload_.channel_length = channel_.size(); | 239 payload_.channel_length = channel_.size(); |
| 215 } | 240 } |
| 216 void set_update_ap(const std::wstring& update_ap) { | 241 void set_update_ap(const std::wstring& update_ap) { |
| 217 update_ap_ = update_ap; | 242 update_ap_ = update_ap; |
| 218 payload_.update_ap = update_ap_.c_str(); | 243 payload_.update_ap = update_ap_.c_str(); |
| 219 } | 244 } |
| 220 void set_update_cohort_name(const std::wstring& update_cohort_name) { | 245 void set_update_cohort_name(const std::wstring& update_cohort_name) { |
| 221 update_cohort_name_ = update_cohort_name; | 246 update_cohort_name_ = update_cohort_name; |
| 222 payload_.update_cohort_name = update_cohort_name_.c_str(); | 247 payload_.update_cohort_name = update_cohort_name_.c_str(); |
| 223 } | 248 } |
| 224 void set_system_level(bool system_level) { | 249 void set_system_level(bool system_level) { |
| 225 payload_.system_level = system_level; | 250 payload_.system_level = system_level; |
| 226 } | 251 } |
| 252 void set_user_data_dir(const std::wstring& user_data_dir) { |
| 253 user_data_dir_ = user_data_dir; |
| 254 payload_.user_data_dir = user_data_dir_.c_str(); |
| 255 } |
| 256 void set_invalid_user_data_dir(const std::wstring& invalid_user_data_dir) { |
| 257 invalid_user_data_dir_ = invalid_user_data_dir; |
| 258 payload_.invalid_user_data_dir = invalid_user_data_dir_.c_str(); |
| 259 } |
| 227 | 260 |
| 228 private: | 261 private: |
| 229 std::wstring channel_; | 262 std::wstring channel_; |
| 230 std::wstring update_ap_; | 263 std::wstring update_ap_; |
| 231 std::wstring update_cohort_name_; | 264 std::wstring update_cohort_name_; |
| 265 std::wstring user_data_dir_; |
| 266 std::wstring invalid_user_data_dir_; |
| 232 Payload payload_ = Payload(); | 267 Payload payload_ = Payload(); |
| 233 }; | 268 }; |
| 234 | 269 |
| 235 } // namespace install_static | 270 } // namespace install_static |
| 236 | 271 |
| 237 #endif // CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ | 272 #endif // CHROME_INSTALL_STATIC_INSTALL_DETAILS_H_ |
| OLD | NEW |