15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file declares Chrome uninstall related functions.
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_INSTALLER_SETUP_UNINSTALL_H_
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_INSTALLER_SETUP_UNINSTALL_H_
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <shlobj.h>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/util_constants.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserDistribution;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CommandLine;
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace base {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FilePath;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace installer {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InstallationState;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InstallerState;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Product;
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)enum DeleteResult {
294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  DELETE_SUCCEEDED,
304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  DELETE_NOT_EMPTY,
314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  DELETE_FAILED,
324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  DELETE_REQUIRES_REBOOT,
334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)};
344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Deletes |target_directory| (".../Application") and the vendor directories
364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// (e.g., ".../Google/Chrome") if they are empty. Returns DELETE_SUCCEEDED if
374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// either the directories were deleted or if they were not empty. Returns
384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// DELETE_FAILED if any could not be deleted due to an error.
394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)DeleteResult DeleteChromeDirectoriesIfEmpty(
404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    const base::FilePath& application_directory);
414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This function removes all Chrome registration related keys. It returns true
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// if successful, otherwise false. The error code is set in |exit_code|.
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |root| is the registry root (HKLM|HKCU) and |browser_entry_suffix| is the
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// suffix for default browser entry name in the registry (optional).
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  BrowserDistribution* dist,
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  HKEY root,
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  const string16& browser_entry_suffix,
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  InstallStatus* exit_code);
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Removes any legacy registry keys from earlier versions of Chrome that are no
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// longer needed. This is used during autoupdate since we don't do full
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// uninstalls/reinstalls to update.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RemoveChromeLegacyRegistryKeys(BrowserDistribution* dist,
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    const string16& chrome_exe);
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This function uninstalls a product.  Hence we came up with this awesome
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// name for it.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// original_state: The installation state of all products on the system.
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// installer_state: State associated with this operation.
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// setup_path: Path to the executable (setup.exe) as it will be copied
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//           to temp folder before deleting Chrome folder.
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// dist: Represents the distribution to be uninstalled.
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// remove_all: Remove all shared files, registry entries as well.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// force_uninstall: Uninstall without prompting for user confirmation or
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//                  any checks for Chrome running.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// cmd_line: CommandLine that contains information about the command that
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//           was used to launch current uninstaller.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)installer::InstallStatus UninstallProduct(
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const InstallationState& original_state,
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const InstallerState& installer_state,
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const base::FilePath& setup_path,
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const Product& dist,
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool remove_all,
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool force_uninstall,
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const CommandLine& cmd_line);
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Cleans up the installation directory after all uninstall operations have
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// completed. Depending on what products are remaining, setup.exe and the
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// installer archive may be deleted. Empty directories will be pruned (or
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// scheduled for pruning after reboot, if necessary).
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// original_state: The installation state of all products on the system.
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// installer_state: State associated with this operation.
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// cmd_line: CommandLine that contains information about the command that
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//           was used to launch current uninstaller.
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// uninstall_status: the uninstall status so far (may change during invocation).
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void CleanUpInstallationDirectoryAfterUninstall(
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const InstallationState& original_state,
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const InstallerState& installer_state,
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const CommandLine& cmd_line,
944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    InstallStatus* uninstall_status);
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace installer
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_INSTALLER_SETUP_UNINSTALL_H_
99