Chromium Code Reviews| Index: chrome/installer/setup/uninstall.cc |
| diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc |
| index 0eb961ad2379abb63251967f32bf3a34bd2a9b5c..d8a83625d3a49d968f1ad7e3ad2c0d32ab7da4fe 100644 |
| --- a/chrome/installer/setup/uninstall.cc |
| +++ b/chrome/installer/setup/uninstall.cc |
| @@ -26,6 +26,7 @@ |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_result_codes.h" |
| +#include "chrome/installer/setup/app_launcher_installer.h" |
| #include "chrome/installer/setup/install.h" |
| #include "chrome/installer/setup/install_worker.h" |
| #include "chrome/installer/setup/setup_constants.h" |
| @@ -185,20 +186,14 @@ void ClearRlzProductState() { |
| } |
| } |
| -// Decides whether setup.exe and the installer archive should be removed based |
| -// on the original and installer states: |
| -// * non-multi product being uninstalled: remove both |
| -// * any multi product left besides App Host: keep both |
| -// * only App Host left: keep setup.exe |
| -void CheckShouldRemoveSetupAndArchive(const InstallationState& original_state, |
| - const InstallerState& installer_state, |
| - bool* remove_setup, |
| - bool* remove_archive) { |
| - *remove_setup = true; |
| - *remove_archive = true; |
| - |
| - // If any multi-install product is left (other than App Host) we must leave |
| - // the installer and archive. For the App Host, we only leave the installer. |
| +// Returns whether setup.exe should be removed based on the original and |
| +// installer states: |
| +// * non-multi product being uninstalled: remove setup.exe |
| +// * any multi product left: keep setup.exe |
| +bool CheckShouldRemoveSetup(const InstallationState& original_state, |
| + const InstallerState& installer_state) { |
| + // If any multi-install product is left we must leave the installer and |
| + // archive. |
| if (!installer_state.is_multi_install()) { |
| VLOG(1) << "Removing all installer files for a non-multi installation."; |
| } else { |
| @@ -214,23 +209,14 @@ void CheckShouldRemoveSetupAndArchive(const InstallationState& original_state, |
| !installer_state.FindProduct(dist_type)) { |
| // setup.exe will not be removed as there is a remaining multi-install |
| // product. |
| - *remove_setup = false; |
| - // As a special case, we can still remove the actual archive if the |
| - // only remaining product is the App Host. |
| - if (dist_type != BrowserDistribution::CHROME_APP_HOST) { |
| - VLOG(1) << "Keeping all installer files due to a remaining " |
| - << "multi-install product."; |
| - *remove_archive = false; |
| - return; |
| - } |
| - VLOG(1) << "Keeping setup.exe due to a remaining " |
| - << "app-host installation."; |
| + VLOG(1) << "Keeping all installer files due to a remaining " |
| + << "multi-install product."; |
| + return false; |
| } |
| } |
| - VLOG(1) << "Removing the installer archive."; |
| - if (remove_setup) |
| - VLOG(1) << "Removing setup.exe."; |
| + VLOG(1) << "Removing all installer files."; |
| } |
| + return true; |
| } |
| // Removes all files from the installer directory, leaving setup.exe iff |
| @@ -513,28 +499,6 @@ bool MoveSetupOutOfInstallFolder(const InstallerState& installer_state, |
| return true; |
| } |
| -DeleteResult DeleteAppHostFilesAndFolders(const InstallerState& installer_state, |
| - const Version& installed_version) { |
| - const base::FilePath& target_path = installer_state.target_path(); |
| - if (target_path.empty()) { |
| - LOG(ERROR) << "DeleteAppHostFilesAndFolders: no installation destination " |
| - << "path."; |
| - return DELETE_FAILED; // Nothing else we can do to uninstall, so we return. |
| - } |
| - |
| - DeleteInstallTempDir(target_path); |
| - |
| - DeleteResult result = DELETE_SUCCEEDED; |
| - |
| - base::FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe)); |
| - if (!base::DeleteFile(app_host_exe, false)) { |
| - result = DELETE_FAILED; |
| - LOG(ERROR) << "Failed to delete path: " << app_host_exe.value(); |
| - } |
| - |
| - return result; |
| -} |
| - |
| DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, |
| const base::FilePath& setup_exe) { |
| const base::FilePath& target_path = installer_state.target_path(); |
| @@ -561,8 +525,6 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, |
| base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
| for (base::FilePath to_delete = file_enumerator.Next(); !to_delete.empty(); |
| to_delete = file_enumerator.Next()) { |
| - if (to_delete.BaseName().value() == installer::kChromeAppHostExe) |
| - continue; |
| if (!installer_directory.empty() && |
| (to_delete == installer_directory || |
| installer_directory.IsParent(to_delete) || |
| @@ -1148,6 +1110,8 @@ InstallStatus UninstallProduct(const InstallationState& original_state, |
| } |
| } |
| + HKEY reg_root = installer_state.root_key(); |
| + |
| if (is_chrome) { |
| // Chrome is not in use so lets uninstall Chrome by deleting various files |
| // and registry entries. Here we will just make best effort and keep going |
| @@ -1180,12 +1144,16 @@ InstallStatus UninstallProduct(const InstallationState& original_state, |
| } |
| } |
| +#if defined(GOOGLE_CHROME_BUILD) |
| + if (!InstallUtil::IsChromeSxSProcess()) { |
|
grt (UTC plus 2)
2015/01/09 18:57:04
nit: no braces
huangs
2015/01/18 01:18:24
Done.
|
| + app_launcher_installer::RemoveShadowKey(reg_root); |
|
grt (UTC plus 2)
2015/01/09 18:57:04
i think this belongs in the is_chrome block below
huangs
2015/01/18 01:18:24
Moved, but I don't understand the reason you state
grt (UTC plus 2)
2015/01/20 21:30:22
Doh! So it is! In any case, I think the block belo
huangs
2015/01/20 23:26:00
Okay. No additional change here.
|
| + } |
| +#endif |
| + |
| DeleteShortcuts(installer_state, product, chrome_exe); |
| } |
| // Delete the registry keys (Uninstall key and Version key). |
| - HKEY reg_root = installer_state.root_key(); |
| - |
| // Note that we must retrieve the distribution-specific data before deleting |
| // product.GetVersionKey(). |
| base::string16 distribution_data(browser_dist->GetDistributionData(reg_root)); |
| @@ -1276,22 +1244,6 @@ InstallStatus UninstallProduct(const InstallationState& original_state, |
| // Notify the shell that associations have changed since Chrome was likely |
| // unregistered. |
| SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); |
| - |
| - // TODO(huangs): Implement actual migration code and remove the hack below. |
| - // Remove the "shadow" App Launcher registry keys. |
| - // TODO(hunags): Management of this key should not be conditional on |
| - // multi-install since the app list feature is available regardless of how |
| - // chrome is installed. |
| - if (installer_state.is_multi_install()) { |
| - // Delete the "shadow" keys. |
| - BrowserDistribution* shadow_app_launcher_dist = |
| - BrowserDistribution::GetSpecificDistribution( |
| - BrowserDistribution::CHROME_APP_HOST); |
| - InstallUtil::DeleteRegistryKey( |
| - reg_root, |
| - shadow_app_launcher_dist->GetVersionKey(), |
| - KEY_WOW64_32KEY); |
| - } |
| } |
| if (installer_state.is_multi_install()) |
| @@ -1368,10 +1320,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state, |
| delete_profile = false; |
| } |
| - if (product.is_chrome_app_host()) { |
| - DeleteAppHostFilesAndFolders(installer_state, product_state->version()); |
| - } else if (!installer_state.is_multi_install() || |
| - product.is_chrome_binaries()) { |
| + if (!installer_state.is_multi_install() || product.is_chrome_binaries()) { |
| DeleteResult delete_result = DeleteChromeFilesAndFolders( |
| installer_state, base::MakeAbsoluteFilePath(setup_exe)); |
| if (delete_result == DELETE_FAILED) { |
| @@ -1419,12 +1368,7 @@ void CleanUpInstallationDirectoryAfterUninstall( |
| } |
| base::FilePath install_directory(setup_exe.DirName()); |
| - bool remove_setup = true; |
| - bool remove_archive = true; |
| - CheckShouldRemoveSetupAndArchive(original_state, installer_state, |
| - &remove_setup, &remove_archive); |
| - if (!remove_archive) |
| - return; |
| + bool remove_setup = CheckShouldRemoveSetup(original_state, installer_state); |
| if (remove_setup) { |
| // In order to be able to remove the folder in which we're running, we |