| 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 #include "chrome/test/mini_installer_test/installer_test_util.h" | 5 #include "chrome/test/mini_installer_test/installer_test_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 namespace installer_test { | 51 namespace installer_test { |
| 52 | 52 |
| 53 bool DeleteInstallDirectory(bool system_level, | 53 bool DeleteInstallDirectory(bool system_level, |
| 54 InstallationValidator::InstallationType type) { | 54 InstallationValidator::InstallationType type) { |
| 55 std::string version = GetVersion(type); | 55 std::string version = GetVersion(type); |
| 56 if (version.empty()) | 56 if (version.empty()) |
| 57 return false; | 57 return false; |
| 58 FilePath path; | 58 FilePath path; |
| 59 if (!GetInstallDirectory(system_level, | 59 bool has_install_dir = GetInstallDirectory(system_level, |
| 60 ToBrowserDistributionType(type), &path) || | 60 ToBrowserDistributionType(type), |
| 61 !file_util::PathExists(path)) | 61 &path); |
| 62 if (!has_install_dir || !file_util::PathExists(path)) |
| 62 return false; | 63 return false; |
| 63 path = path.AppendASCII(version); | 64 path = path.AppendASCII(version); |
| 64 if (!file_util::Delete(path, true)) | 65 return file_util::Delete(path, true); |
| 65 return false; | |
| 66 return true; | |
| 67 } | 66 } |
| 68 | 67 |
| 69 bool DeleteRegistryKey(bool system_level, | 68 bool DeleteRegistryKey(bool system_level, |
| 70 InstallationValidator::InstallationType type) { | 69 InstallationValidator::InstallationType type) { |
| 71 FilePath::StringType key(google_update::kRegPathClients); | |
| 72 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 70 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
| 73 ToBrowserDistributionType(type)); | 71 ToBrowserDistributionType(type)); |
| 74 file_util::AppendToPath(&key, dist->GetAppGuid()); | 72 FilePath::StringType key(google_update::kRegPathClients); |
| 75 HKEY root = HKEY_CURRENT_USER; | 73 key.push_back(FilePath::kSeparators[0]); |
| 76 if (system_level) | 74 key.append(dist->GetAppGuid()); |
| 77 root = HKEY_LOCAL_MACHINE; | 75 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 78 if (InstallUtil::DeleteRegistryKey(root, key)) | 76 return InstallUtil::DeleteRegistryKey(root, key); |
| 79 return true; | |
| 80 return false; | |
| 81 } | 77 } |
| 82 | 78 |
| 83 bool GetChromeInstallDirectory(bool system_level, FilePath* path) { | 79 bool GetChromeInstallDirectory(bool system_level, FilePath* path) { |
| 84 return GetInstallDirectory(system_level, | 80 return GetInstallDirectory(system_level, |
| 85 BrowserDistribution::CHROME_BROWSER, path); | 81 BrowserDistribution::CHROME_BROWSER, path); |
| 86 } | 82 } |
| 87 | 83 |
| 88 bool GetInstallDirectory(bool system_level, | 84 bool GetInstallDirectory(bool system_level, |
| 89 BrowserDistribution::Type type, FilePath* path) { | 85 BrowserDistribution::Type type, FilePath* path) { |
| 90 BrowserDistribution* dist = | 86 BrowserDistribution* dist = |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 return false; | 292 return false; |
| 297 } | 293 } |
| 298 if (!base::WaitForSingleProcess(process, 60 * 1000)) { | 294 if (!base::WaitForSingleProcess(process, 60 * 1000)) { |
| 299 LOG(ERROR) << "Launched process did not complete."; | 295 LOG(ERROR) << "Launched process did not complete."; |
| 300 return false; | 296 return false; |
| 301 } | 297 } |
| 302 return true; | 298 return true; |
| 303 } | 299 } |
| 304 | 300 |
| 305 } // namespace | 301 } // namespace |
| 306 | |
| OLD | NEW |