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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 user_reg_root.Close(); | 830 user_reg_root.Close(); |
831 if (RegUnLoadKey(HKEY_USERS, profile_sid) == ERROR_SUCCESS) | 831 if (RegUnLoadKey(HKEY_USERS, profile_sid) == ERROR_SUCCESS) |
832 VLOG(1) << "Unloaded registry hive for " << profile_sid; | 832 VLOG(1) << "Unloaded registry hive for " << profile_sid; |
833 else | 833 else |
834 LOG(ERROR) << "Error unloading registry hive for " << profile_sid; | 834 LOG(ERROR) << "Error unloading registry hive for " << profile_sid; |
835 } | 835 } |
836 } | 836 } |
837 } | 837 } |
838 | 838 |
839 // Removes the persistent blacklist state for the current user. Note: this will | 839 // Removes the persistent blacklist state for the current user. Note: this will |
840 // not remove the state for users other than the one uninstalling chrome on a | 840 // not remove the state for users other than the one uninstalling Chrome on a |
841 // system-level install (http://crbug.com/388725). Doing so would require | 841 // system-level install (http://crbug.com/388725). Doing so would require |
842 // extracting the per-user registry hive iteration from | 842 // extracting the per-user registry hive iteration from |
843 // UninstallActiveSetupEntries so that it could service multiple tasks. | 843 // UninstallActiveSetupEntries so that it could service multiple tasks. |
844 void RemoveBlacklistState() { | 844 void RemoveBlacklistState() { |
845 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 845 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
846 blacklist::kRegistryBeaconPath, | 846 blacklist::kRegistryBeaconPath, |
847 0); // wow64_access | 847 0); // wow64_access |
848 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 848 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
849 blacklist::kRegistryFinchListPath, | 849 blacklist::kRegistryFinchListPath, |
850 0); // wow64_access | 850 0); // wow64_access |
851 } | 851 } |
852 | 852 |
| 853 // Removes the persistent state for |distribution| for the current user. Note: |
| 854 // this will not remove the state for users other than the one uninstalling |
| 855 // Chrome on a system-level install; see RemoveBlacklistState for details. |
| 856 void RemoveDistributionRegistryState(BrowserDistribution* distribution) { |
| 857 static const base::char16* const kKeysToPreserve[] = { |
| 858 L"Extensions", |
| 859 L"NativeMessagingHosts", |
| 860 }; |
| 861 base::string16 key_name(L"Software\\"); |
| 862 key_name += distribution->GetInstallSubDir(); |
| 863 // Delete the contents of the distribution key except for those parts used by |
| 864 // outsiders to configure Chrome. |
| 865 DeleteRegistryKeyPartial( |
| 866 HKEY_CURRENT_USER, key_name, |
| 867 std::vector<base::string16>( |
| 868 &kKeysToPreserve[0], |
| 869 &kKeysToPreserve[arraysize(kKeysToPreserve) - 1])); |
| 870 } |
| 871 |
853 } // namespace | 872 } // namespace |
854 | 873 |
855 DeleteResult DeleteChromeDirectoriesIfEmpty( | 874 DeleteResult DeleteChromeDirectoriesIfEmpty( |
856 const base::FilePath& application_directory) { | 875 const base::FilePath& application_directory) { |
857 DeleteResult result(DeleteEmptyDir(application_directory)); | 876 DeleteResult result(DeleteEmptyDir(application_directory)); |
858 if (result == DELETE_SUCCEEDED) { | 877 if (result == DELETE_SUCCEEDED) { |
859 // Now check and delete if the parent directories are empty | 878 // Now check and delete if the parent directories are empty |
860 // For example Google\Chrome or Chromium | 879 // For example Google\Chrome or Chromium |
861 const base::FilePath product_directory(application_directory.DirName()); | 880 const base::FilePath product_directory(application_directory.DirName()); |
862 if (!product_directory.empty()) { | 881 if (!product_directory.empty()) { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 if (!installer_state.is_multi_install() || product.is_chrome_binaries()) { | 1351 if (!installer_state.is_multi_install() || product.is_chrome_binaries()) { |
1333 DeleteResult delete_result = DeleteChromeFilesAndFolders( | 1352 DeleteResult delete_result = DeleteChromeFilesAndFolders( |
1334 installer_state, base::MakeAbsoluteFilePath(setup_exe)); | 1353 installer_state, base::MakeAbsoluteFilePath(setup_exe)); |
1335 if (delete_result == DELETE_FAILED) { | 1354 if (delete_result == DELETE_FAILED) { |
1336 ret = installer::UNINSTALL_FAILED; | 1355 ret = installer::UNINSTALL_FAILED; |
1337 } else if (delete_result == DELETE_REQUIRES_REBOOT) { | 1356 } else if (delete_result == DELETE_REQUIRES_REBOOT) { |
1338 ret = installer::UNINSTALL_REQUIRES_REBOOT; | 1357 ret = installer::UNINSTALL_REQUIRES_REBOOT; |
1339 } | 1358 } |
1340 } | 1359 } |
1341 | 1360 |
1342 if (delete_profile) | 1361 if (delete_profile) { |
1343 DeleteUserDataDir(user_data_dir, product.is_chrome_frame()); | 1362 DeleteUserDataDir(user_data_dir, product.is_chrome_frame()); |
| 1363 RemoveDistributionRegistryState(browser_dist); |
| 1364 } |
1344 | 1365 |
1345 if (!force_uninstall) { | 1366 if (!force_uninstall) { |
1346 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations."; | 1367 VLOG(1) << "Uninstallation complete. Launching post-uninstall operations."; |
1347 browser_dist->DoPostUninstallOperations(product_state->version(), | 1368 browser_dist->DoPostUninstallOperations(product_state->version(), |
1348 backup_state_file, distribution_data); | 1369 backup_state_file, distribution_data); |
1349 } | 1370 } |
1350 | 1371 |
1351 // Try and delete the preserved local state once the post-install | 1372 // Try and delete the preserved local state once the post-install |
1352 // operations are complete. | 1373 // operations are complete. |
1353 if (!backup_state_file.empty()) | 1374 if (!backup_state_file.empty()) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 // If we need a reboot to continue, schedule the parent directories for | 1440 // If we need a reboot to continue, schedule the parent directories for |
1420 // deletion unconditionally. If they are not empty, the session manager | 1441 // deletion unconditionally. If they are not empty, the session manager |
1421 // will not delete them on reboot. | 1442 // will not delete them on reboot. |
1422 ScheduleParentAndGrandparentForDeletion(target_path); | 1443 ScheduleParentAndGrandparentForDeletion(target_path); |
1423 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { | 1444 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { |
1424 *uninstall_status = UNINSTALL_FAILED; | 1445 *uninstall_status = UNINSTALL_FAILED; |
1425 } | 1446 } |
1426 } | 1447 } |
1427 | 1448 |
1428 } // namespace installer | 1449 } // namespace installer |
OLD | NEW |