OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/installer/util/installation_state.h" | 5 #include "chrome/installer/util/installation_state.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/version.h" | 9 #include "base/version.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 // Clear the runway. | 54 // Clear the runway. |
55 Clear(); | 55 Clear(); |
56 | 56 |
57 // Read from the Clients key. | 57 // Read from the Clients key. |
58 if (key.Open(root_key, version_key.c_str(), | 58 if (key.Open(root_key, version_key.c_str(), |
59 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 59 KEY_QUERY_VALUE) == ERROR_SUCCESS) { |
60 std::wstring version_str; | 60 std::wstring version_str; |
61 if (key.ReadValue(google_update::kRegVersionField, | 61 if (key.ReadValue(google_update::kRegVersionField, |
62 &version_str) == ERROR_SUCCESS) { | 62 &version_str) == ERROR_SUCCESS) { |
63 version_.reset(new Version(WideToASCII(version_str))); | 63 version_.reset(new base::Version(WideToASCII(version_str))); |
64 if (!version_->IsValid()) | 64 if (!version_->IsValid()) |
65 version_.reset(); | 65 version_.reset(); |
66 } | 66 } |
67 | 67 |
68 // Attempt to read the other values even if the "pv" version value was | 68 // Attempt to read the other values even if the "pv" version value was |
69 // absent. Note that ProductState instances containing these values will | 69 // absent. Note that ProductState instances containing these values will |
70 // only be accessible via InstallationState::GetNonVersionedProductState. | 70 // only be accessible via InstallationState::GetNonVersionedProductState. |
71 if (key.ReadValue(google_update::kRegOldVersionField, | 71 if (key.ReadValue(google_update::kRegOldVersionField, |
72 &version_str) == ERROR_SUCCESS) { | 72 &version_str) == ERROR_SUCCESS) { |
73 old_version_.reset(new Version(WideToASCII(version_str))); | 73 old_version_.reset(new base::Version(WideToASCII(version_str))); |
74 if (!old_version_->IsValid()) | 74 if (!old_version_->IsValid()) |
75 old_version_.reset(); | 75 old_version_.reset(); |
76 } | 76 } |
77 | 77 |
78 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); | 78 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); |
79 if (!InitializeCommands(key, &commands_)) | 79 if (!InitializeCommands(key, &commands_)) |
80 commands_.Clear(); | 80 commands_.Clear(); |
81 } | 81 } |
82 | 82 |
83 // Read from the ClientState key. | 83 // Read from the ClientState key. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 return version_.get() != NULL; | 143 return version_.get() != NULL; |
144 } | 144 } |
145 | 145 |
146 base::FilePath ProductState::GetSetupPath() const { | 146 base::FilePath ProductState::GetSetupPath() const { |
147 return uninstall_command_.GetProgram(); | 147 return uninstall_command_.GetProgram(); |
148 } | 148 } |
149 | 149 |
150 const Version& ProductState::version() const { | 150 const base::Version& ProductState::version() const { |
151 DCHECK(version_.get() != NULL); | 151 DCHECK(version_.get() != NULL); |
152 return *version_; | 152 return *version_; |
153 } | 153 } |
154 | 154 |
155 ProductState& ProductState::CopyFrom(const ProductState& other) { | 155 ProductState& ProductState::CopyFrom(const ProductState& other) { |
156 channel_.set_value(other.channel_.value()); | 156 channel_.set_value(other.channel_.value()); |
157 version_.reset(other.version_.get() ? new Version(*other.version_) : NULL); | 157 version_.reset( |
| 158 other.version_.get() ? new base::Version(*other.version_) : NULL); |
158 old_version_.reset( | 159 old_version_.reset( |
159 other.old_version_.get() ? new Version(*other.old_version_) : NULL); | 160 other.old_version_.get() ? new base::Version(*other.old_version_) : NULL); |
160 brand_ = other.brand_; | 161 brand_ = other.brand_; |
161 rename_cmd_ = other.rename_cmd_; | 162 rename_cmd_ = other.rename_cmd_; |
162 uninstall_command_ = other.uninstall_command_; | 163 uninstall_command_ = other.uninstall_command_; |
163 oem_install_ = other.oem_install_; | 164 oem_install_ = other.oem_install_; |
164 commands_.CopyFrom(other.commands_); | 165 commands_.CopyFrom(other.commands_); |
165 eula_accepted_ = other.eula_accepted_; | 166 eula_accepted_ = other.eula_accepted_; |
166 usagestats_ = other.usagestats_; | 167 usagestats_ = other.usagestats_; |
167 msi_ = other.msi_; | 168 msi_ = other.msi_; |
168 multi_install_ = other.multi_install_; | 169 multi_install_ = other.multi_install_; |
169 has_eula_accepted_ = other.has_eula_accepted_; | 170 has_eula_accepted_ = other.has_eula_accepted_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 269 } |
269 | 270 |
270 const ProductState* InstallationState::GetProductState( | 271 const ProductState* InstallationState::GetProductState( |
271 bool system_install, | 272 bool system_install, |
272 BrowserDistribution::Type type) const { | 273 BrowserDistribution::Type type) const { |
273 const ProductState* product_state = | 274 const ProductState* product_state = |
274 GetNonVersionedProductState(system_install, type); | 275 GetNonVersionedProductState(system_install, type); |
275 return product_state->version_.get() == NULL ? NULL : product_state; | 276 return product_state->version_.get() == NULL ? NULL : product_state; |
276 } | 277 } |
277 } // namespace installer | 278 } // namespace installer |
OLD | NEW |