| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file defines the methods useful for uninstalling Chrome. | 5 // This file defines the methods useful for uninstalling Chrome. |
| 6 | 6 |
| 7 #include "chrome/installer/setup/uninstall.h" | 7 #include "chrome/installer/setup/uninstall.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::string reactivation_brand(WideToASCII(reactivation_brand_wide)); | 178 std::string reactivation_brand(WideToASCII(reactivation_brand_wide)); |
| 179 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); | 179 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); |
| 180 rlz_lib::ClearProductState(rlz_lib::CHROME, points); | 180 rlz_lib::ClearProductState(rlz_lib::CHROME, points); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace | 184 } // namespace |
| 185 | 185 |
| 186 namespace installer { | 186 namespace installer { |
| 187 | 187 |
| 188 // This functions checks for any Chrome instances that are | 188 // Kills all Chrome processes, immediately. |
| 189 // running and first asks them to close politely by sending a Windows message. | |
| 190 // If there is an error while sending message or if there are still Chrome | |
| 191 // procesess active after the message has been sent, this function will try | |
| 192 // to kill them. | |
| 193 void CloseAllChromeProcesses() { | 189 void CloseAllChromeProcesses() { |
| 194 for (int j = 0; j < 4; ++j) { | 190 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), |
| 195 string16 wnd_class(L"Chrome_WidgetWin_"); | |
| 196 wnd_class.append(base::IntToString16(j)); | |
| 197 HWND window = FindWindowEx(NULL, NULL, wnd_class.c_str(), NULL); | |
| 198 while (window) { | |
| 199 HWND tmpWnd = window; | |
| 200 window = FindWindowEx(NULL, window, wnd_class.c_str(), NULL); | |
| 201 if (!SendMessageTimeout(tmpWnd, WM_CLOSE, 0, 0, SMTO_BLOCK, 3000, NULL) && | |
| 202 (GetLastError() == ERROR_TIMEOUT)) { | |
| 203 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), | |
| 204 content::RESULT_CODE_HUNG, NULL); | |
| 205 base::CleanupProcesses(installer::kNaClExe, base::TimeDelta(), | |
| 206 content::RESULT_CODE_HUNG, NULL); | |
| 207 return; | |
| 208 } | |
| 209 } | |
| 210 } | |
| 211 | |
| 212 // If asking politely didn't work, wait for 15 seconds and then kill all | |
| 213 // chrome.exe. This check is just in case Chrome is ignoring WM_CLOSE | |
| 214 // messages. | |
| 215 base::CleanupProcesses(installer::kChromeExe, | |
| 216 base::TimeDelta::FromSeconds(15), | |
| 217 content::RESULT_CODE_HUNG, NULL); | 191 content::RESULT_CODE_HUNG, NULL); |
| 218 base::CleanupProcesses(installer::kNaClExe, | 192 base::CleanupProcesses(installer::kNaClExe, base::TimeDelta(), |
| 219 base::TimeDelta::FromSeconds(15), | |
| 220 content::RESULT_CODE_HUNG, NULL); | 193 content::RESULT_CODE_HUNG, NULL); |
| 221 } | 194 } |
| 222 | 195 |
| 223 // Attempts to close the Chrome Frame helper process by sending WM_CLOSE | 196 // Attempts to close the Chrome Frame helper process by sending WM_CLOSE |
| 224 // messages to its window, or just killing it if that doesn't work. | 197 // messages to its window, or just killing it if that doesn't work. |
| 225 void CloseChromeFrameHelperProcess() { | 198 void CloseChromeFrameHelperProcess() { |
| 226 HWND window = FindWindow(installer::kChromeFrameHelperWndClass, NULL); | 199 HWND window = FindWindow(installer::kChromeFrameHelperWndClass, NULL); |
| 227 if (!::IsWindow(window)) | 200 if (!::IsWindow(window)) |
| 228 return; | 201 return; |
| 229 | 202 |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 | 1248 |
| 1276 // Try and delete the preserved local state once the post-install | 1249 // Try and delete the preserved local state once the post-install |
| 1277 // operations are complete. | 1250 // operations are complete. |
| 1278 if (!backup_state_file.empty()) | 1251 if (!backup_state_file.empty()) |
| 1279 file_util::Delete(backup_state_file, false); | 1252 file_util::Delete(backup_state_file, false); |
| 1280 | 1253 |
| 1281 return ret; | 1254 return ret; |
| 1282 } | 1255 } |
| 1283 | 1256 |
| 1284 } // namespace installer | 1257 } // namespace installer |
| OLD | NEW |