| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string_util.h" | 8 #include "base/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" |
| 11 #include "chrome/installer/util/google_update_constants.h" | 11 #include "chrome/installer/util/google_update_constants.h" |
| 12 #include "chrome/installer/util/package_properties.h" | 12 #include "chrome/installer/util/package_properties.h" |
| 13 | 13 |
| 14 namespace installer { | 14 namespace installer { |
| 15 | 15 |
| 16 ProductState::ProductState() { | 16 ProductState::ProductState() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 void ProductState::Initialize(bool system_install, | 19 void ProductState::Initialize(bool system_install, |
| 20 const std::wstring& version_key, | 20 const std::wstring& version_key, |
| 21 const std::wstring& state_key) { | 21 const std::wstring& state_key) { |
| 22 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 22 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 23 base::win::RegKey key(root_key, version_key.c_str(), KEY_QUERY_VALUE); | 23 base::win::RegKey key(root_key, version_key.c_str(), KEY_QUERY_VALUE); |
| 24 std::wstring version_str; | 24 std::wstring version_str; |
| 25 if (key.ReadValue(google_update::kRegVersionField, &version_str)) { | 25 LONG result = key.ReadValue(google_update::kRegVersionField, &version_str); |
| 26 if (result == ERROR_SUCCESS) { |
| 26 version_.reset(Version::GetVersionFromString(WideToASCII(version_str))); | 27 version_.reset(Version::GetVersionFromString(WideToASCII(version_str))); |
| 27 if (version_.get() != NULL) { | 28 if (version_.get() != NULL) { |
| 28 // The product is installed. Check for the channel value (absent if not | 29 // The product is installed. Check for the channel value (absent if not |
| 29 // installed/managed by Google Update). | 30 // installed/managed by Google Update). |
| 30 if (!key.Open(root_key, state_key.c_str(), KEY_QUERY_VALUE) || | 31 result = key.Open(root_key, state_key.c_str(), KEY_QUERY_VALUE); |
| 31 !channel_.Initialize(key)) { | 32 if (result != ERROR_SUCCESS || !channel_.Initialize(key)) { |
| 32 channel_.set_value(std::wstring()); | 33 channel_.set_value(std::wstring()); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 } else { | 36 } else { |
| 36 version_.reset(); | 37 version_.reset(); |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 const Version& ProductState::version() const { | 41 const Version& ProductState::version() const { |
| 41 DCHECK(version_.get() != NULL); | 42 DCHECK(version_.get() != NULL); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 // Included for testing. | 128 // Included for testing. |
| 128 void InstallationState::SetProductState(bool system_install, | 129 void InstallationState::SetProductState(bool system_install, |
| 129 BrowserDistribution::Type type, const ProductState& product_state) { | 130 BrowserDistribution::Type type, const ProductState& product_state) { |
| 130 ProductState& target = (system_install ? system_products_ : | 131 ProductState& target = (system_install ? system_products_ : |
| 131 user_products_)[IndexFromDistType(type)]; | 132 user_products_)[IndexFromDistType(type)]; |
| 132 target.CopyFrom(product_state); | 133 target.CopyFrom(product_state); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace installer | 136 } // namespace installer |
| OLD | NEW |