summaryrefslogtreecommitdiffstats
path: root/cloud_print/virtual_driver
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 21:42:10 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 21:42:10 +0000
commit48ef98e49cb27ca0eb4e6b97b16a25178b4957c3 (patch)
tree32dca1850caf866489396124b304d4d22210f157 /cloud_print/virtual_driver
parentea0dab33ebbe7c35e413f5ae04326d91b2764978 (diff)
downloadchromium_src-48ef98e49cb27ca0eb4e6b97b16a25178b4957c3.zip
chromium_src-48ef98e49cb27ca0eb4e6b97b16a25178b4957c3.tar.gz
chromium_src-48ef98e49cb27ca0eb4e6b97b16a25178b4957c3.tar.bz2
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
Diffstat (limited to 'cloud_print/virtual_driver')
-rw-r--r--cloud_print/virtual_driver/win/install/setup.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index 3bd88e5..3583132 100644
--- a/cloud_print/virtual_driver/win/install/setup.cc
+++ b/cloud_print/virtual_driver/win/install/setup.cc
@@ -41,7 +41,7 @@ const wchar_t kUninstallRegistry[] =
const wchar_t kInstallerName[] = L"virtual_driver_setup.exe";
const wchar_t kGcpUrl[] = L"http://www.google.com/cloudprint";
-const char kDoUninstallSwitch[] = "douninstall";
+const char kDelete[] = "delete";
const char kInstallSwitch[] = "install";
const char kRegisterSwitch[] = "register";
const char kUninstallSwitch[] = "uninstall";
@@ -516,13 +516,13 @@ HRESULT UnregisterVirtualDriver() {
return hr;
}
-HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) {
+HRESULT DeleteProgramDir(const FilePath& installer_source, bool wait) {
FilePath temp_path;
if (file_util::CreateTemporaryFile(&temp_path)) {
file_util::CopyFile(installer_source, temp_path);
file_util::DeleteAfterReboot(temp_path);
CommandLine command_line(temp_path);
- command_line.AppendArg(kDoUninstallSwitch);
+ command_line.AppendSwitchPath(kDelete, installer_source.DirName());
base::LaunchOptions options;
options.wait = wait;
base::ProcessHandle process_handle;
@@ -545,11 +545,15 @@ HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) {
return S_OK;
}
-HRESULT LaunchChildForUninstall() {
+HRESULT DoUninstall() {
+ DeleteGoogleUpdateKeys();
+ HRESULT result = UnregisterVirtualDriver();
+ if (FAILED(result))
+ return result;
+ CleanupUninstall();
FilePath installer_source;
- if (PathService::Get(base::FILE_EXE, &installer_source)) {
- return DoLaunchUninstall(installer_source, false);
- }
+ if (PathService::Get(base::FILE_EXE, &installer_source))
+ return DeleteProgramDir(installer_source, false);
return S_OK;
}
@@ -564,20 +568,13 @@ HRESULT DoRegister(const FilePath& install_path) {
return RegisterVirtualDriver(install_path);
}
-HRESULT DoUninstall() {
- FilePath install_path;
- GetCurrentInstallPath(&install_path);
- if (install_path.value().empty()) {
+HRESULT DoDelete(const FilePath& install_path) {
+ if (install_path.value().empty())
+ return E_INVALIDARG;
+ if (!file_util::DirectoryExists(install_path))
return S_FALSE;
- }
- HRESULT result = UnregisterVirtualDriver();
- if (FAILED(result))
- return result;
- DeleteGoogleUpdateKeys();
- if (file_util::DirectoryExists(install_path))
- file_util::Delete(install_path, true);
- CleanupUninstall();
- return result;
+ Sleep(5000); // Give parent some time to exit.
+ return file_util::Delete(install_path, true) ? S_OK : E_FAIL;
}
HRESULT DoInstall(const FilePath& install_path) {
@@ -610,10 +607,10 @@ HRESULT ExecuteCommands() {
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
}
- if (command_line.HasSwitch(kDoUninstallSwitch)) {
- return DoUninstall();
+ if (command_line.HasSwitch(kDelete)) {
+ return DoDelete(command_line.GetSwitchValuePath(kDelete));
} else if (command_line.HasSwitch(kUninstallSwitch)) {
- return LaunchChildForUninstall();
+ return DoUninstall();
} else if (command_line.HasSwitch(kInstallSwitch)) {
return DoInstall(exe_path);
} else if (command_line.HasSwitch(kUnregisterSwitch)) {