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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 11255: * Invoke Google Update to do the exe rename. (Closed)
Patch Set: code review feedback Created 12 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <time.h> 5 #include <time.h>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/registry.h" 8 #include "base/registry.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // current version in old version key. 221 // current version in old version key.
222 // * If new_chrome.exe doesnt exist, then delete old version key. 222 // * If new_chrome.exe doesnt exist, then delete old version key.
223 if (success) { 223 if (success) {
224 if (file_util::PathExists(new_chrome_exe)) { 224 if (file_util::PathExists(new_chrome_exe)) {
225 if (current_version.empty()) { 225 if (current_version.empty()) {
226 LOG(ERROR) << "New chrome.exe exists but current version is empty!"; 226 LOG(ERROR) << "New chrome.exe exists but current version is empty!";
227 success = false; 227 success = false;
228 } else { 228 } else {
229 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); 229 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
230 inuse_list->AddSetRegValueWorkItem(reg_root, 230 inuse_list->AddSetRegValueWorkItem(reg_root,
231 version_key, 231 version_key,
232 google_update::kRegOldVersionField, 232 google_update::kRegOldVersionField,
233 current_version.c_str(), 233 current_version.c_str(),
234 true); 234 true);
235 std::wstring rename_cmd(installer::GetInstallerPathUnderChrome( 235 std::wstring rename_cmd(installer::GetInstallerPathUnderChrome(
236 install_path, new_version.GetString())); 236 install_path, new_version.GetString()));
237 file_util::AppendToPath(&rename_cmd, 237 file_util::AppendToPath(&rename_cmd,
238 file_util::GetFilenameFromPath(exe_path)); 238 file_util::GetFilenameFromPath(exe_path));
239 rename_cmd = L"\"" + rename_cmd + L"\" --" + 239 rename_cmd = L"\"" + rename_cmd +
240 installer_util::switches::kRenameChromeExe; 240 L"\" --" + installer_util::switches::kRenameChromeExe;
241 if (reg_root == HKEY_LOCAL_MACHINE) {
242 rename_cmd = rename_cmd + L" --" +
243 installer_util::switches::kSystemLevel;
244 }
241 inuse_list->AddSetRegValueWorkItem(reg_root, 245 inuse_list->AddSetRegValueWorkItem(reg_root,
242 version_key, 246 version_key,
243 google_update::kRegRenameCmdField, 247 google_update::kRegRenameCmdField,
244 rename_cmd.c_str(), 248 rename_cmd.c_str(),
245 true); 249 true);
246 if (!inuse_list->Do()) { 250 if (!inuse_list->Do()) {
247 LOG(ERROR) << "Couldn't write old version/rename value to registry."; 251 LOG(ERROR) << "Couldn't write old version/rename value to registry.";
248 success = false; 252 success = false;
249 inuse_list->Rollback(); 253 inuse_list->Rollback();
250 } 254 }
251 } 255 }
252 } else { 256 } else {
253 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); 257 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
254 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key, 258 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
255 google_update::kRegOldVersionField, 259 google_update::kRegOldVersionField,
256 true); 260 true);
257 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key, 261 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
258 google_update::kRegRenameCmdField, 262 google_update::kRegRenameCmdField,
259 true); 263 true);
260 if (!inuse_list->Do()) { 264 if (!inuse_list->Do()) {
261 LOG(ERROR) << "Couldn't write old version/rename value to registry."; 265 LOG(ERROR) << "Couldn't write old version/rename value to registry.";
262 success = false; 266 success = false;
263 inuse_list->Rollback(); 267 inuse_list->Rollback();
264 } 268 }
265 } 269 }
266 } 270 }
267 271
268 if (!success) { 272 if (!success) {
269 LOG(ERROR) << "Install failed, rolling back... "; 273 LOG(ERROR) << "Install failed, rolling back... ";
270 install_list->Rollback(); 274 install_list->Rollback();
271 LOG(ERROR) << "Rollback complete. "; 275 LOG(ERROR) << "Rollback complete. ";
272 } 276 }
273 return success; 277 return success;
274 } 278 }
275 279
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698