uninstall.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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
15class BrowserDistribution;
16class CommandLine;
17
18namespace base {
19class FilePath;
20}
21
22namespace installer {
23
24class InstallationState;
25class InstallerState;
26class Product;
27
28enum 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.
39DeleteResult 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).
46bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
47                                  BrowserDistribution* dist,
48                                  HKEY root,
49                                  const 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.
55void RemoveChromeLegacyRegistryKeys(BrowserDistribution* dist,
56                                    const 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_path: Path to the executable (setup.exe) as it will be copied
64//           to temp folder before deleting Chrome folder.
65// dist: Represents the distribution to be uninstalled.
66// remove_all: Remove all shared files, registry entries as well.
67// force_uninstall: Uninstall without prompting for user confirmation or
68//                  any checks for Chrome running.
69// cmd_line: CommandLine that contains information about the command that
70//           was used to launch current uninstaller.
71installer::InstallStatus UninstallProduct(
72    const InstallationState& original_state,
73    const InstallerState& installer_state,
74    const base::FilePath& setup_path,
75    const Product& dist,
76    bool remove_all,
77    bool force_uninstall,
78    const CommandLine& cmd_line);
79
80// Cleans up the installation directory after all uninstall operations have
81// completed. Depending on what products are remaining, setup.exe and the
82// installer archive may be deleted. Empty directories will be pruned (or
83// scheduled for pruning after reboot, if necessary).
84//
85// original_state: The installation state of all products on the system.
86// installer_state: State associated with this operation.
87// cmd_line: CommandLine that contains information about the command that
88//           was used to launch current uninstaller.
89// uninstall_status: the uninstall status so far (may change during invocation).
90void CleanUpInstallationDirectoryAfterUninstall(
91    const InstallationState& original_state,
92    const InstallerState& installer_state,
93    const CommandLine& cmd_line,
94    InstallStatus* uninstall_status);
95
96}  // namespace installer
97
98#endif  // CHROME_INSTALLER_SETUP_UNINSTALL_H_
99