Fixed virtual driver uninstall.

Main uninstall should be done in parent process. Child process should only delete program directory. Otherwise Windows sees that uninstall reg path still exists and shows error.


Review URL: https://chromiumcodereview.appspot.com/12211125

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182025 0039d316-1c4b-4281-b951-d872f2087c98
parent ea0dab33
...@@ -41,7 +41,7 @@ const wchar_t kUninstallRegistry[] = ...@@ -41,7 +41,7 @@ const wchar_t kUninstallRegistry[] =
const wchar_t kInstallerName[] = L"virtual_driver_setup.exe"; const wchar_t kInstallerName[] = L"virtual_driver_setup.exe";
const wchar_t kGcpUrl[] = L"http://www.google.com/cloudprint"; const wchar_t kGcpUrl[] = L"http://www.google.com/cloudprint";
const char kDoUninstallSwitch[] = "douninstall"; const char kDelete[] = "delete";
const char kInstallSwitch[] = "install"; const char kInstallSwitch[] = "install";
const char kRegisterSwitch[] = "register"; const char kRegisterSwitch[] = "register";
const char kUninstallSwitch[] = "uninstall"; const char kUninstallSwitch[] = "uninstall";
...@@ -516,13 +516,13 @@ HRESULT UnregisterVirtualDriver() { ...@@ -516,13 +516,13 @@ HRESULT UnregisterVirtualDriver() {
return hr; return hr;
} }
HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) { HRESULT DeleteProgramDir(const FilePath& installer_source, bool wait) {
FilePath temp_path; FilePath temp_path;
if (file_util::CreateTemporaryFile(&temp_path)) { if (file_util::CreateTemporaryFile(&temp_path)) {
file_util::CopyFile(installer_source, temp_path); file_util::CopyFile(installer_source, temp_path);
file_util::DeleteAfterReboot(temp_path); file_util::DeleteAfterReboot(temp_path);
CommandLine command_line(temp_path); CommandLine command_line(temp_path);
command_line.AppendArg(kDoUninstallSwitch); command_line.AppendSwitchPath(kDelete, installer_source.DirName());
base::LaunchOptions options; base::LaunchOptions options;
options.wait = wait; options.wait = wait;
base::ProcessHandle process_handle; base::ProcessHandle process_handle;
...@@ -545,11 +545,15 @@ HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) { ...@@ -545,11 +545,15 @@ HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) {
return S_OK; return S_OK;
} }
HRESULT LaunchChildForUninstall() { HRESULT DoUninstall() {
DeleteGoogleUpdateKeys();
HRESULT result = UnregisterVirtualDriver();
if (FAILED(result))
return result;
CleanupUninstall();
FilePath installer_source; FilePath installer_source;
if (PathService::Get(base::FILE_EXE, &installer_source)) { if (PathService::Get(base::FILE_EXE, &installer_source))
return DoLaunchUninstall(installer_source, false); return DeleteProgramDir(installer_source, false);
}
return S_OK; return S_OK;
} }
...@@ -564,20 +568,13 @@ HRESULT DoRegister(const FilePath& install_path) { ...@@ -564,20 +568,13 @@ HRESULT DoRegister(const FilePath& install_path) {
return RegisterVirtualDriver(install_path); return RegisterVirtualDriver(install_path);
} }
HRESULT DoUninstall() { HRESULT DoDelete(const FilePath& install_path) {
FilePath install_path; if (install_path.value().empty())
GetCurrentInstallPath(&install_path); return E_INVALIDARG;
if (install_path.value().empty()) { if (!file_util::DirectoryExists(install_path))
return S_FALSE; return S_FALSE;
} Sleep(5000); // Give parent some time to exit.
HRESULT result = UnregisterVirtualDriver(); return file_util::Delete(install_path, true) ? S_OK : E_FAIL;
if (FAILED(result))
return result;
DeleteGoogleUpdateKeys();
if (file_util::DirectoryExists(install_path))
file_util::Delete(install_path, true);
CleanupUninstall();
return result;
} }
HRESULT DoInstall(const FilePath& install_path) { HRESULT DoInstall(const FilePath& install_path) {
...@@ -610,10 +607,10 @@ HRESULT ExecuteCommands() { ...@@ -610,10 +607,10 @@ HRESULT ExecuteCommands() {
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
} }
if (command_line.HasSwitch(kDoUninstallSwitch)) { if (command_line.HasSwitch(kDelete)) {
return DoUninstall(); return DoDelete(command_line.GetSwitchValuePath(kDelete));
} else if (command_line.HasSwitch(kUninstallSwitch)) { } else if (command_line.HasSwitch(kUninstallSwitch)) {
return LaunchChildForUninstall(); return DoUninstall();
} else if (command_line.HasSwitch(kInstallSwitch)) { } else if (command_line.HasSwitch(kInstallSwitch)) {
return DoInstall(exe_path); return DoInstall(exe_path);
} else if (command_line.HasSwitch(kUnregisterSwitch)) { } else if (command_line.HasSwitch(kUnregisterSwitch)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment