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 // This file defines the methods useful for uninstalling Chrome. | 5 // This file defines the methods useful for uninstalling Chrome. |
6 | 6 |
7 #include "chrome/installer/setup/uninstall.h" | 7 #include "chrome/installer/setup/uninstall.h" |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 if (RegUnLoadKey(HKEY_USERS, profile_sid) == ERROR_SUCCESS) | 1037 if (RegUnLoadKey(HKEY_USERS, profile_sid) == ERROR_SUCCESS) |
1038 VLOG(1) << "Unloaded registry hive for " << profile_sid; | 1038 VLOG(1) << "Unloaded registry hive for " << profile_sid; |
1039 else | 1039 else |
1040 LOG(ERROR) << "Error unloading registry hive for " << profile_sid; | 1040 LOG(ERROR) << "Error unloading registry hive for " << profile_sid; |
1041 } | 1041 } |
1042 } | 1042 } |
1043 } | 1043 } |
1044 | 1044 |
1045 InstallStatus UninstallProduct(const InstallationState& original_state, | 1045 InstallStatus UninstallProduct(const InstallationState& original_state, |
1046 const InstallerState& installer_state, | 1046 const InstallerState& installer_state, |
1047 const base::FilePath& setup_path, | 1047 const base::FilePath& setup_exe, |
1048 const Product& product, | 1048 const Product& product, |
1049 bool remove_all, | 1049 bool remove_all, |
1050 bool force_uninstall, | 1050 bool force_uninstall, |
1051 const CommandLine& cmd_line) { | 1051 const CommandLine& cmd_line) { |
1052 InstallStatus status = installer::UNINSTALL_CONFIRMED; | 1052 InstallStatus status = installer::UNINSTALL_CONFIRMED; |
1053 BrowserDistribution* browser_dist = product.distribution(); | 1053 BrowserDistribution* browser_dist = product.distribution(); |
1054 const base::string16 chrome_exe( | 1054 const base::string16 chrome_exe( |
1055 installer_state.target_path().Append(installer::kChromeExe).value()); | 1055 installer_state.target_path().Append(installer::kChromeExe).value()); |
1056 | 1056 |
1057 bool is_chrome = product.is_chrome(); | 1057 bool is_chrome = product.is_chrome(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 // (aka non-multi) installation or we are the Chrome Binaries. | 1311 // (aka non-multi) installation or we are the Chrome Binaries. |
1312 | 1312 |
1313 std::vector<base::FilePath> local_state_folders; | 1313 std::vector<base::FilePath> local_state_folders; |
1314 GetLocalStateFolders(product, &local_state_folders); | 1314 GetLocalStateFolders(product, &local_state_folders); |
1315 base::FilePath backup_state_file(BackupLocalStateFile(local_state_folders)); | 1315 base::FilePath backup_state_file(BackupLocalStateFile(local_state_folders)); |
1316 | 1316 |
1317 if (product.is_chrome_app_host()) { | 1317 if (product.is_chrome_app_host()) { |
1318 DeleteAppHostFilesAndFolders(installer_state, product_state->version()); | 1318 DeleteAppHostFilesAndFolders(installer_state, product_state->version()); |
1319 } else if (!installer_state.is_multi_install() || | 1319 } else if (!installer_state.is_multi_install() || |
1320 product.is_chrome_binaries()) { | 1320 product.is_chrome_binaries()) { |
1321 base::FilePath setup_exe(base::MakeAbsoluteFilePath(cmd_line.GetProgram())); | |
1322 DeleteResult delete_result = DeleteChromeFilesAndFolders( | 1321 DeleteResult delete_result = DeleteChromeFilesAndFolders( |
1323 installer_state, setup_exe); | 1322 installer_state, base::MakeAbsoluteFilePath(setup_exe)); |
1324 if (delete_result == DELETE_FAILED) { | 1323 if (delete_result == DELETE_FAILED) { |
1325 ret = installer::UNINSTALL_FAILED; | 1324 ret = installer::UNINSTALL_FAILED; |
1326 } else if (delete_result == DELETE_REQUIRES_REBOOT) { | 1325 } else if (delete_result == DELETE_REQUIRES_REBOOT) { |
1327 ret = installer::UNINSTALL_REQUIRES_REBOOT; | 1326 ret = installer::UNINSTALL_REQUIRES_REBOOT; |
1328 } | 1327 } |
1329 } | 1328 } |
1330 | 1329 |
1331 if (delete_profile) | 1330 if (delete_profile) |
1332 DeleteLocalState(local_state_folders, product.is_chrome_frame()); | 1331 DeleteLocalState(local_state_folders, product.is_chrome_frame()); |
1333 | 1332 |
1334 if (!force_uninstall) { | 1333 if (!force_uninstall) { |
1335 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations."; | 1334 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations."; |
1336 browser_dist->DoPostUninstallOperations(product_state->version(), | 1335 browser_dist->DoPostUninstallOperations(product_state->version(), |
1337 backup_state_file, distribution_data); | 1336 backup_state_file, distribution_data); |
1338 } | 1337 } |
1339 | 1338 |
1340 // Try and delete the preserved local state once the post-install | 1339 // Try and delete the preserved local state once the post-install |
1341 // operations are complete. | 1340 // operations are complete. |
1342 if (!backup_state_file.empty()) | 1341 if (!backup_state_file.empty()) |
1343 base::DeleteFile(backup_state_file, false); | 1342 base::DeleteFile(backup_state_file, false); |
1344 | 1343 |
1345 return ret; | 1344 return ret; |
1346 } | 1345 } |
1347 | 1346 |
1348 void CleanUpInstallationDirectoryAfterUninstall( | 1347 void CleanUpInstallationDirectoryAfterUninstall( |
1349 const InstallationState& original_state, | 1348 const InstallationState& original_state, |
1350 const InstallerState& installer_state, | 1349 const InstallerState& installer_state, |
1351 const CommandLine& cmd_line, | 1350 const base::FilePath& setup_exe, |
1352 InstallStatus* uninstall_status) { | 1351 InstallStatus* uninstall_status) { |
1353 if (*uninstall_status != UNINSTALL_SUCCESSFUL && | 1352 if (*uninstall_status != UNINSTALL_SUCCESSFUL && |
1354 *uninstall_status != UNINSTALL_REQUIRES_REBOOT) { | 1353 *uninstall_status != UNINSTALL_REQUIRES_REBOOT) { |
1355 return; | 1354 return; |
1356 } | 1355 } |
1357 const base::FilePath target_path(installer_state.target_path()); | 1356 const base::FilePath target_path(installer_state.target_path()); |
1358 if (target_path.empty()) { | 1357 if (target_path.empty()) { |
1359 LOG(ERROR) << "No installation destination path."; | 1358 LOG(ERROR) << "No installation destination path."; |
1360 *uninstall_status = UNINSTALL_FAILED; | 1359 *uninstall_status = UNINSTALL_FAILED; |
1361 return; | 1360 return; |
1362 } | 1361 } |
1363 base::FilePath setup_exe(base::MakeAbsoluteFilePath(cmd_line.GetProgram())); | 1362 if (!target_path.IsParent(base::MakeAbsoluteFilePath(setup_exe))) { |
1364 if (!target_path.IsParent(setup_exe)) { | |
1365 VLOG(1) << "setup.exe is not in target path. Skipping installer cleanup."; | 1363 VLOG(1) << "setup.exe is not in target path. Skipping installer cleanup."; |
1366 return; | 1364 return; |
1367 } | 1365 } |
1368 base::FilePath install_directory(setup_exe.DirName()); | 1366 base::FilePath install_directory(setup_exe.DirName()); |
1369 | 1367 |
1370 bool remove_setup = true; | 1368 bool remove_setup = true; |
1371 bool remove_archive = true; | 1369 bool remove_archive = true; |
1372 CheckShouldRemoveSetupAndArchive(original_state, installer_state, | 1370 CheckShouldRemoveSetupAndArchive(original_state, installer_state, |
1373 &remove_setup, &remove_archive); | 1371 &remove_setup, &remove_archive); |
1374 if (!remove_archive) | 1372 if (!remove_archive) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 // If we need a reboot to continue, schedule the parent directories for | 1412 // If we need a reboot to continue, schedule the parent directories for |
1415 // deletion unconditionally. If they are not empty, the session manager | 1413 // deletion unconditionally. If they are not empty, the session manager |
1416 // will not delete them on reboot. | 1414 // will not delete them on reboot. |
1417 ScheduleParentAndGrandparentForDeletion(target_path); | 1415 ScheduleParentAndGrandparentForDeletion(target_path); |
1418 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { | 1416 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { |
1419 *uninstall_status = UNINSTALL_FAILED; | 1417 *uninstall_status = UNINSTALL_FAILED; |
1420 } | 1418 } |
1421 } | 1419 } |
1422 | 1420 |
1423 } // namespace installer | 1421 } // namespace installer |
OLD | NEW |