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/product.h" | 5 #include "chrome/installer/util/product.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 119 |
120 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); | 120 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); |
121 | 121 |
122 bool is_msi = false; | 122 bool is_msi = false; |
123 prefs.GetBool(installer::master_preferences::kMsi, &is_msi); | 123 prefs.GetBool(installer::master_preferences::kMsi, &is_msi); |
124 | 124 |
125 if (!is_msi) { | 125 if (!is_msi) { |
126 // We didn't find it in the preferences, try looking in the registry. | 126 // We didn't find it in the preferences, try looking in the registry. |
127 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 127 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
128 RegKey key; | 128 RegKey key; |
129 if (key.Open(reg_root, distribution_->GetStateKey().c_str(), KEY_READ)) { | 129 LONG result = key.Open(reg_root, distribution_->GetStateKey().c_str(), |
130 DWORD msi_value; | 130 KEY_READ); |
131 if (key.ReadValueDW(google_update::kRegMSIField, &msi_value) && | 131 if (result == ERROR_SUCCESS) { |
132 msi_value != 0) { | 132 DWORD msi_value = 0; |
133 msi_ = true; | 133 result = key.ReadValueDW(google_update::kRegMSIField, &msi_value); |
grt (UTC plus 2)
2011/01/11 03:51:30
I prefer an if (result == ERROR_SUCCESS) before re
| |
134 } | 134 msi_ = msi_value != 0; |
135 } | 135 } |
136 } else { | 136 } else { |
137 msi_ = true; | 137 msi_ = true; |
138 } | 138 } |
139 cache_state_ |= MSI_STATE; | 139 cache_state_ |= MSI_STATE; |
140 } | 140 } |
141 | 141 |
142 return msi_; | 142 return msi_; |
143 } | 143 } |
144 | 144 |
145 bool Product::SetMsiMarker(bool set) const { | 145 bool Product::SetMsiMarker(bool set) const { |
146 bool success = false; | |
147 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 146 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
148 RegKey client_state_key; | 147 RegKey client_state_key; |
149 if (client_state_key.Open(reg_root, distribution_->GetStateKey().c_str(), | 148 LONG result = client_state_key.Open(reg_root, |
150 KEY_READ | KEY_WRITE)) { | 149 distribution_->GetStateKey().c_str(), KEY_READ | KEY_WRITE); |
151 DWORD msi_value = set ? 1 : 0; | 150 if (result == ERROR_SUCCESS) { |
152 if (client_state_key.WriteValue(google_update::kRegMSIField, msi_value)) { | 151 result = client_state_key.WriteValue(google_update::kRegMSIField, |
153 success = true; | 152 set ? 1 : 0); |
154 } else { | |
155 LOG(ERROR) << "Could not write MSI value to client state key."; | |
156 } | |
157 } else { | |
158 LOG(ERROR) << "SetMsiMarker: Could not open client state key!"; | |
159 } | 153 } |
160 | 154 |
161 return success; | 155 if (result != ERROR_SUCCESS) { |
156 LOG(ERROR) << "Failed to Open or Write MSI value to client state key." | |
grt (UTC plus 2)
2011/01/11 03:51:30
LOG_IF(ERROR, result != ERROR_SUCCESS) << ...
amit
2011/01/12 04:11:23
Done.
| |
157 << " error: " << result; | |
grt (UTC plus 2)
2011/01/11 03:51:30
com::LogWe(result) (i love this!)
amit
2011/01/12 04:11:23
com::LogWe is cool and I have changed to it in CEE
grt (UTC plus 2)
2011/01/12 15:06:38
Yeah; I didn't notice that it was in a CEEE lib.
| |
158 } | |
159 | |
160 return (result == ERROR_SUCCESS); | |
162 } | 161 } |
163 | 162 |
164 const Version* Product::GetInstalledVersion() const { | 163 const Version* Product::GetInstalledVersion() const { |
165 if ((cache_state_ & VERSION) == 0) { | 164 if ((cache_state_ & VERSION) == 0) { |
166 DCHECK(installed_version_.get() == NULL); | 165 DCHECK(installed_version_.get() == NULL); |
167 installed_version_.reset(InstallUtil::GetChromeVersion(distribution_, | 166 installed_version_.reset(InstallUtil::GetChromeVersion(distribution_, |
168 system_level())); | 167 system_level())); |
169 cache_state_ |= VERSION; | 168 cache_state_ |= VERSION; |
170 } | 169 } |
171 | 170 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 if (!distribution) { | 262 if (!distribution) { |
264 NOTREACHED(); | 263 NOTREACHED(); |
265 return false; | 264 return false; |
266 } | 265 } |
267 | 266 |
268 return AddDistribution(distribution); | 267 return AddDistribution(distribution); |
269 } | 268 } |
270 | 269 |
271 } // namespace installer | 270 } // namespace installer |
272 | 271 |
OLD | NEW |