summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 23:13:54 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 23:13:54 +0000
commit32f720c5a051885d45b79533522c06870e7037ff (patch)
tree8f90984d1b613d347e6fca055509ddb9fc47a5c0 /chrome/installer/setup
parent87fe92e776cc3d2fa97a2c2c9ba2a450c30da816 (diff)
downloadchromium_src-32f720c5a051885d45b79533522c06870e7037ff.zip
chromium_src-32f720c5a051885d45b79533522c06870e7037ff.tar.gz
chromium_src-32f720c5a051885d45b79533522c06870e7037ff.tar.bz2
On silent uninstall (--force-uninstall) close all Chrome processes without prompting the user.
BUG=1445145 Review URL: http://codereview.chromium.org/8943 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup')
-rw-r--r--chrome/installer/setup/uninstall.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 5136f88..fe62e67 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -12,6 +12,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/process_util.h"
#include "base/registry.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
@@ -36,6 +37,34 @@
namespace {
+// This functions checks for any Chrome instances that are
+// running and first asks them to close politely by sending a Windows message.
+// If there is an error while sending message or if there are still Chrome
+// procesess active after the message has been sent, this function will try
+// to kill them.
+void CloseAllChromeProcesses() {
+ for (int j = 0; j < 4; ++j) {
+ std::wstring wnd_class(L"Chrome_ContainerWin_");
+ wnd_class.append(IntToWString(j));
+ HWND window = FindWindowEx(NULL, NULL, wnd_class.c_str(), NULL);
+ while (window) {
+ HWND tmpWnd = window;
+ window = FindWindowEx(NULL, window, wnd_class.c_str(), NULL);
+ if (!SendMessageTimeout(tmpWnd, WM_CLOSE, 0, 0, SMTO_BLOCK, 3000, NULL) &&
+ (GetLastError() == ERROR_TIMEOUT)) {
+ process_util::CleanupProcesses(installer_util::kChromeExe, 0,
+ ResultCodes::HUNG, NULL);
+ return;
+ }
+ }
+ }
+
+ // If asking politely didn't work, wait for 15 seconds and then kill all
+ // chrome.exe. This check is just in case Chrome is ignoring WM_CLOSE messages.
+ process_util::CleanupProcesses(installer_util::kChromeExe, 15000,
+ ResultCodes::HUNG, NULL);
+}
+
// This method deletes Chrome shortcut folder from Windows Start menu. It
// checks system_uninstall to see if the shortcut is in all users start menu
// or current user start menu.
@@ -183,6 +212,10 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
IsChromeActiveOrUserCancelled(system_uninstall);
if (status != installer_util::UNINSTALL_CONFIRMED)
return status;
+ } else {
+ // Since --force-uninstall command line option is used, we are going to
+ // do silent uninstall. Try to close all running Chrome instances.
+ CloseAllChromeProcesses();
}
#if defined(GOOGLE_CHROME_BUILD)