| 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> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <shlwapi.h> | 12 #include <shlwapi.h> |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "base/version.h" | 24 #include "base/version.h" |
| 25 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
| 26 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
| 27 #include "chrome/installer/util/browser_distribution.h" | 27 #include "chrome/installer/util/browser_distribution.h" |
| 28 #include "chrome/installer/util/google_update_constants.h" | 28 #include "chrome/installer/util/google_update_constants.h" |
| 29 #include "chrome/installer/util/helper.h" |
| 29 #include "chrome/installer/util/l10n_string_util.h" | 30 #include "chrome/installer/util/l10n_string_util.h" |
| 30 #include "chrome/installer/util/installation_state.h" | 31 #include "chrome/installer/util/installation_state.h" |
| 31 #include "chrome/installer/util/util_constants.h" | 32 #include "chrome/installer/util/util_constants.h" |
| 32 #include "chrome/installer/util/work_item_list.h" | 33 #include "chrome/installer/util/work_item_list.h" |
| 33 | 34 |
| 34 using base::win::RegKey; | 35 using base::win::RegKey; |
| 35 using installer::ProductState; | 36 using installer::ProductState; |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } else { | 352 } else { |
| 352 FilePath handler( | 353 FilePath handler( |
| 353 FilePath(chrome_exe).DirName() | 354 FilePath(chrome_exe).DirName() |
| 354 .AppendASCII(version.GetString()) | 355 .AppendASCII(version.GetString()) |
| 355 .Append(installer::kDelegateExecuteExe)); | 356 .Append(installer::kDelegateExecuteExe)); |
| 356 found = file_util::PathExists(handler); | 357 found = file_util::PathExists(handler); |
| 357 } | 358 } |
| 358 return found; | 359 return found; |
| 359 } | 360 } |
| 360 | 361 |
| 362 bool InstallUtil::GetSentinelFilePath(const char* file, |
| 363 BrowserDistribution* dist, |
| 364 FilePath* path) { |
| 365 FilePath exe_path; |
| 366 if (!PathService::Get(base::DIR_EXE, &exe_path)) |
| 367 return false; |
| 368 |
| 369 if (IsPerUserInstall(exe_path.value().c_str())) { |
| 370 *path = exe_path; |
| 371 } else { |
| 372 std::vector<FilePath> user_data_dir_paths; |
| 373 installer::GetChromeUserDataPaths(dist, &user_data_dir_paths); |
| 374 |
| 375 if (!user_data_dir_paths.empty()) |
| 376 *path = user_data_dir_paths[0]; |
| 377 else |
| 378 return false; |
| 379 } |
| 380 |
| 381 *path = path->AppendASCII(file); |
| 382 return true; |
| 383 } |
| 384 |
| 361 // This method tries to delete a registry key and logs an error message | 385 // This method tries to delete a registry key and logs an error message |
| 362 // in case of failure. It returns true if deletion is successful (or the key did | 386 // in case of failure. It returns true if deletion is successful (or the key did |
| 363 // not exist), otherwise false. | 387 // not exist), otherwise false. |
| 364 bool InstallUtil::DeleteRegistryKey(HKEY root_key, | 388 bool InstallUtil::DeleteRegistryKey(HKEY root_key, |
| 365 const string16& key_path) { | 389 const string16& key_path) { |
| 366 VLOG(1) << "Deleting registry key " << key_path; | 390 VLOG(1) << "Deleting registry key " << key_path; |
| 367 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); | 391 LONG result = ::SHDeleteKey(root_key, key_path.c_str()); |
| 368 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { | 392 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
| 369 LOG(ERROR) << "Failed to delete registry key: " << key_path | 393 LOG(ERROR) << "Failed to delete registry key: " << key_path |
| 370 << " error: " << result; | 394 << " error: " << result; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // Open the program and see if it references the expected file. | 565 // Open the program and see if it references the expected file. |
| 542 base::win::ScopedHandle handle; | 566 base::win::ScopedHandle handle; |
| 543 BY_HANDLE_FILE_INFORMATION info = {}; | 567 BY_HANDLE_FILE_INFORMATION info = {}; |
| 544 | 568 |
| 545 return (OpenForInfo(program, &handle) && | 569 return (OpenForInfo(program, &handle) && |
| 546 GetInfo(handle, &info) && | 570 GetInfo(handle, &info) && |
| 547 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 571 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 548 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 572 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 549 info.nFileIndexLow == file_info_.nFileIndexLow); | 573 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 550 } | 574 } |
| OLD | NEW |