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 3 // found in the LICENSE file. 4 // 5 // This file declares Chrome uninstall related functions. 6 7 #ifndef CHROME_INSTALLER_SETUP_UNINSTALL_H_ 8 #define CHROME_INSTALLER_SETUP_UNINSTALL_H_ 9 10 #include <shlobj.h> 11 12 #include "base/strings/string16.h" 13 #include "chrome/installer/util/util_constants.h" 14 15 class BrowserDistribution; 16 17 namespace base { 18 class CommandLine; 19 class FilePath; 20 } 21 22 namespace installer { 23 24 class InstallationState; 25 class InstallerState; 26 class Product; 27 28 enum DeleteResult { 29 DELETE_SUCCEEDED, 30 DELETE_NOT_EMPTY, 31 DELETE_FAILED, 32 DELETE_REQUIRES_REBOOT, 33 }; 34 35 // Deletes |target_directory| (".../Application") and the vendor directories 36 // (e.g., ".../Google/Chrome") if they are empty. Returns DELETE_SUCCEEDED if 37 // either the directories were deleted or if they were not empty. Returns 38 // DELETE_FAILED if any could not be deleted due to an error. 39 DeleteResult DeleteChromeDirectoriesIfEmpty( 40 const base::FilePath& application_directory); 41 42 // This function removes all Chrome registration related keys. It returns true 43 // if successful, otherwise false. The error code is set in |exit_code|. 44 // |root| is the registry root (HKLM|HKCU) and |browser_entry_suffix| is the 45 // suffix for default browser entry name in the registry (optional). 46 bool DeleteChromeRegistrationKeys(const InstallerState& installer_state, 47 BrowserDistribution* dist, 48 HKEY root, 49 const base::string16& browser_entry_suffix, 50 InstallStatus* exit_code); 51 52 // Removes any legacy registry keys from earlier versions of Chrome that are no 53 // longer needed. This is used during autoupdate since we don't do full 54 // uninstalls/reinstalls to update. 55 void RemoveChromeLegacyRegistryKeys(BrowserDistribution* dist, 56 const base::string16& chrome_exe); 57 58 // This function uninstalls a product. Hence we came up with this awesome 59 // name for it. 60 // 61 // original_state: The installation state of all products on the system. 62 // installer_state: State associated with this operation. 63 // setup_exe: The path to the currently running setup.exe. It and its containing 64 // directories are left in-place if it is within the target directory of 65 // the product being uninstalled. 66 // dist: Represents the distribution to be uninstalled. 67 // remove_all: Remove all shared files, registry entries as well. 68 // force_uninstall: Uninstall without prompting for user confirmation or 69 // any checks for Chrome running. 70 // cmd_line: CommandLine that contains information about the command that 71 // was used to launch current uninstaller. 72 installer::InstallStatus UninstallProduct( 73 const InstallationState& original_state, 74 const InstallerState& installer_state, 75 const base::FilePath& setup_exe, 76 const Product& dist, 77 bool remove_all, 78 bool force_uninstall, 79 const base::CommandLine& cmd_line); 80 81 // Cleans up the installation directory after all uninstall operations have 82 // completed. Depending on what products are remaining, setup.exe and the 83 // installer archive may be deleted. Empty directories will be pruned (or 84 // scheduled for pruning after reboot, if necessary). 85 // 86 // original_state: The installation state of all products on the system. 87 // installer_state: State associated with this operation. 88 // setup_exe: The path to the currently running setup.exe, which will be moved 89 // into a temporary directory to allow for deletion of the installation 90 // directory. 91 // uninstall_status: the uninstall status so far (may change during invocation). 92 void CleanUpInstallationDirectoryAfterUninstall( 93 const InstallationState& original_state, 94 const InstallerState& installer_state, 95 const base::FilePath& setup_exe, 96 InstallStatus* uninstall_status); 97 98 } // namespace installer 99 100 #endif // CHROME_INSTALLER_SETUP_UNINSTALL_H_ 101