| 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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
| 6 // file. | 6 // file. |
| 7 | 7 |
| 8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 FilePath handler( | 353 FilePath handler( |
| 354 FilePath(chrome_exe).DirName() | 354 FilePath(chrome_exe).DirName() |
| 355 .AppendASCII(version->GetString()) | 355 .AppendASCII(version->GetString()) |
| 356 .Append(installer::kDelegateExecuteExe)); | 356 .Append(installer::kDelegateExecuteExe)); |
| 357 found = file_util::PathExists(handler); | 357 found = file_util::PathExists(handler); |
| 358 } | 358 } |
| 359 return found; | 359 return found; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // This method tries to delete a registry key and logs an error message | 362 // This method tries to delete a registry key and logs an error message |
| 363 // in case of failure. It returns true if deletion is successful, | 363 // in case of failure. It returns true if deletion is successful (or the key did |
| 364 // otherwise false. | 364 // not exist), otherwise false. |
| 365 bool InstallUtil::DeleteRegistryKey(HKEY root_key, | 365 bool InstallUtil::DeleteRegistryKey(HKEY root_key, |
| 366 const string16& key_path) { | 366 const string16& key_path) { |
| 367 VLOG(1) << "Deleting registry key " << key_path; | 367 VLOG(1) << "Deleting registry key " << key_path; |
| 368 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); | 368 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); |
| 369 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { | 369 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
| 370 LOG(ERROR) << "Failed to delete registry key: " << key_path | 370 LOG(ERROR) << "Failed to delete registry key: " << key_path |
| 371 << " error: " << result; | 371 << " error: " << result; |
| 372 return false; | 372 return false; |
| 373 } | 373 } |
| 374 return true; | 374 return true; |
| 375 } | 375 } |
| 376 | 376 |
| 377 // This method tries to delete a registry value and logs an error message | 377 // This method tries to delete a registry value and logs an error message |
| 378 // in case of failure. It returns true if deletion is successful, | 378 // in case of failure. It returns true if deletion is successful (or the key did |
| 379 // otherwise false. | 379 // not exist), otherwise false. |
| 380 bool InstallUtil::DeleteRegistryValue(HKEY reg_root, | 380 bool InstallUtil::DeleteRegistryValue(HKEY reg_root, |
| 381 const string16& key_path, | 381 const string16& key_path, |
| 382 const string16& value_name) { | 382 const string16& value_name) { |
| 383 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); | 383 RegKey key; |
| 384 VLOG(1) << "Deleting registry value " << value_name; | 384 LONG result = key.Open(reg_root, key_path.c_str(), KEY_SET_VALUE); |
| 385 if (key.HasValue(value_name.c_str())) { | 385 if (result == ERROR_SUCCESS) |
| 386 LONG result = key.DeleteValue(value_name.c_str()); | 386 result = key.DeleteValue(value_name.c_str()); |
| 387 if (result != ERROR_SUCCESS) { | 387 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
| 388 LOG(ERROR) << "Failed to delete registry value: " << value_name | 388 LOG(ERROR) << "Failed to delete registry value: " << value_name |
| 389 << " error: " << result; | 389 << " error: " << result; |
| 390 return false; | 390 return false; |
| 391 } | |
| 392 } | 391 } |
| 393 return true; | 392 return true; |
| 394 } | 393 } |
| 395 | 394 |
| 396 // static | 395 // static |
| 397 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryKeyIf( | 396 InstallUtil::ConditionalDeleteResult InstallUtil::DeleteRegistryKeyIf( |
| 398 HKEY root_key, | 397 HKEY root_key, |
| 399 const string16& key_to_delete_path, | 398 const string16& key_to_delete_path, |
| 400 const string16& key_to_test_path, | 399 const string16& key_to_test_path, |
| 401 const wchar_t* value_name, | 400 const wchar_t* value_name, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // Open the program and see if it references the expected file. | 542 // Open the program and see if it references the expected file. |
| 544 base::win::ScopedHandle handle; | 543 base::win::ScopedHandle handle; |
| 545 BY_HANDLE_FILE_INFORMATION info = {}; | 544 BY_HANDLE_FILE_INFORMATION info = {}; |
| 546 | 545 |
| 547 return (OpenForInfo(program, &handle) && | 546 return (OpenForInfo(program, &handle) && |
| 548 GetInfo(handle, &info) && | 547 GetInfo(handle, &info) && |
| 549 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 548 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 550 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 549 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 551 info.nFileIndexLow == file_info_.nFileIndexLow); | 550 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 552 } | 551 } |
| OLD | NEW |