Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: chrome/installer/util/product.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/package_unittest.cc ('k') | chrome/installer/util/product_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (key.Open(reg_root, distribution_->GetStateKey().c_str(),
130 DWORD msi_value; 130 KEY_READ) == ERROR_SUCCESS) {
131 if (key.ReadValueDW(google_update::kRegMSIField, &msi_value) && 131 DWORD msi_value = 0;
132 msi_value != 0) { 132 key.ReadValueDW(google_update::kRegMSIField, &msi_value);
133 msi_ = true; 133 msi_ = msi_value != 0;
134 }
135 } 134 }
136 } else { 135 } else {
137 msi_ = true; 136 msi_ = true;
138 } 137 }
139 cache_state_ |= MSI_STATE; 138 cache_state_ |= MSI_STATE;
140 } 139 }
141 140
142 return msi_; 141 return msi_;
143 } 142 }
144 143
145 bool Product::SetMsiMarker(bool set) const { 144 bool Product::SetMsiMarker(bool set) const {
146 bool success = false;
147 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 145 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
148 RegKey client_state_key; 146 RegKey client_state_key;
149 if (client_state_key.Open(reg_root, distribution_->GetStateKey().c_str(), 147 LONG result = client_state_key.Open(reg_root,
150 KEY_READ | KEY_WRITE)) { 148 distribution_->GetStateKey().c_str(), KEY_READ | KEY_WRITE);
151 DWORD msi_value = set ? 1 : 0; 149 if (result == ERROR_SUCCESS) {
152 if (client_state_key.WriteValue(google_update::kRegMSIField, msi_value)) { 150 result = client_state_key.WriteValue(google_update::kRegMSIField,
153 success = true; 151 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 } 152 }
160 153
161 return success; 154 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed to Open or Write MSI value"
155 "to client state key. error: " << result;
156
157 return (result == ERROR_SUCCESS);
162 } 158 }
163 159
164 bool Product::ShouldCreateUninstallEntry() const { 160 bool Product::ShouldCreateUninstallEntry() const {
165 if (IsMsi()) { 161 if (IsMsi()) {
166 // MSI installations will manage their own uninstall shortcuts. 162 // MSI installations will manage their own uninstall shortcuts.
167 return false; 163 return false;
168 } 164 }
169 165
170 return distribution_->ShouldCreateUninstallEntry(); 166 return distribution_->ShouldCreateUninstallEntry();
171 } 167 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (!distribution) { 240 if (!distribution) {
245 NOTREACHED(); 241 NOTREACHED();
246 return false; 242 return false;
247 } 243 }
248 244
249 return AddDistribution(distribution); 245 return AddDistribution(distribution);
250 } 246 }
251 247
252 } // namespace installer 248 } // namespace installer
253 249
OLDNEW
« no previous file with comments | « chrome/installer/util/package_unittest.cc ('k') | chrome/installer/util/product_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698