OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/win/registry.h" | 14 #include "base/win/registry.h" |
15 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
16 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths_internal.h" | 18 #include "chrome/common/chrome_paths_internal.h" |
| 19 #include "chrome/common/chrome_result_codes.h" |
19 #include "chrome/installer/setup/install.h" | 20 #include "chrome/installer/setup/install.h" |
20 #include "chrome/installer/setup/install_worker.h" | 21 #include "chrome/installer/setup/install_worker.h" |
21 #include "chrome/installer/setup/setup_constants.h" | 22 #include "chrome/installer/setup/setup_constants.h" |
22 #include "chrome/installer/setup/setup_util.h" | 23 #include "chrome/installer/setup/setup_util.h" |
23 #include "chrome/installer/util/browser_distribution.h" | 24 #include "chrome/installer/util/browser_distribution.h" |
24 #include "chrome/installer/util/channel_info.h" | 25 #include "chrome/installer/util/channel_info.h" |
25 #include "chrome/installer/util/delete_after_reboot_helper.h" | 26 #include "chrome/installer/util/delete_after_reboot_helper.h" |
26 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
27 #include "chrome/installer/util/helper.h" | 28 #include "chrome/installer/util/helper.h" |
28 #include "chrome/installer/util/install_util.h" | 29 #include "chrome/installer/util/install_util.h" |
29 #include "chrome/installer/util/installation_state.h" | 30 #include "chrome/installer/util/installation_state.h" |
30 #include "chrome/installer/util/installer_state.h" | 31 #include "chrome/installer/util/installer_state.h" |
31 #include "chrome/installer/util/logging_installer.h" | 32 #include "chrome/installer/util/logging_installer.h" |
32 #include "chrome/installer/util/self_cleaning_temp_dir.h" | 33 #include "chrome/installer/util/self_cleaning_temp_dir.h" |
33 #include "chrome/installer/util/shell_util.h" | 34 #include "chrome/installer/util/shell_util.h" |
34 #include "chrome/installer/util/util_constants.h" | 35 #include "chrome/installer/util/util_constants.h" |
35 #include "content/common/result_codes.h" | |
36 #include "rlz/win/lib/rlz_lib.h" | 36 #include "rlz/win/lib/rlz_lib.h" |
37 | 37 |
38 // Build-time generated include file. | 38 // Build-time generated include file. |
39 #include "registered_dlls.h" // NOLINT | 39 #include "registered_dlls.h" // NOLINT |
40 | 40 |
41 using base::win::RegKey; | 41 using base::win::RegKey; |
42 using installer::InstallStatus; | 42 using installer::InstallStatus; |
43 using installer::MasterPreferences; | 43 using installer::MasterPreferences; |
44 | 44 |
45 namespace { | 45 namespace { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 for (int j = 0; j < 4; ++j) { | 131 for (int j = 0; j < 4; ++j) { |
132 std::wstring wnd_class(L"Chrome_WidgetWin_"); | 132 std::wstring wnd_class(L"Chrome_WidgetWin_"); |
133 wnd_class.append(base::IntToString16(j)); | 133 wnd_class.append(base::IntToString16(j)); |
134 HWND window = FindWindowEx(NULL, NULL, wnd_class.c_str(), NULL); | 134 HWND window = FindWindowEx(NULL, NULL, wnd_class.c_str(), NULL); |
135 while (window) { | 135 while (window) { |
136 HWND tmpWnd = window; | 136 HWND tmpWnd = window; |
137 window = FindWindowEx(NULL, window, wnd_class.c_str(), NULL); | 137 window = FindWindowEx(NULL, window, wnd_class.c_str(), NULL); |
138 if (!SendMessageTimeout(tmpWnd, WM_CLOSE, 0, 0, SMTO_BLOCK, 3000, NULL) && | 138 if (!SendMessageTimeout(tmpWnd, WM_CLOSE, 0, 0, SMTO_BLOCK, 3000, NULL) && |
139 (GetLastError() == ERROR_TIMEOUT)) { | 139 (GetLastError() == ERROR_TIMEOUT)) { |
140 base::CleanupProcesses(installer::kChromeExe, 0, | 140 base::CleanupProcesses(installer::kChromeExe, 0, |
141 ResultCodes::HUNG, NULL); | 141 content::RESULT_CODE_HUNG, NULL); |
142 base::CleanupProcesses(installer::kNaClExe, 0, | 142 base::CleanupProcesses(installer::kNaClExe, 0, |
143 ResultCodes::HUNG, NULL); | 143 content::RESULT_CODE_HUNG, NULL); |
144 return; | 144 return; |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 // If asking politely didn't work, wait for 15 seconds and then kill all | 149 // If asking politely didn't work, wait for 15 seconds and then kill all |
150 // chrome.exe. This check is just in case Chrome is ignoring WM_CLOSE | 150 // chrome.exe. This check is just in case Chrome is ignoring WM_CLOSE |
151 // messages. | 151 // messages. |
152 base::CleanupProcesses(installer::kChromeExe, 15000, | 152 base::CleanupProcesses(installer::kChromeExe, 15000, |
153 ResultCodes::HUNG, NULL); | 153 content::RESULT_CODE_HUNG, NULL); |
154 base::CleanupProcesses(installer::kNaClExe, 15000, | 154 base::CleanupProcesses(installer::kNaClExe, 15000, |
155 ResultCodes::HUNG, NULL); | 155 content::RESULT_CODE_HUNG, NULL); |
156 } | 156 } |
157 | 157 |
158 // Attempts to close the Chrome Frame helper process by sending WM_CLOSE | 158 // Attempts to close the Chrome Frame helper process by sending WM_CLOSE |
159 // messages to its window, or just killing it if that doesn't work. | 159 // messages to its window, or just killing it if that doesn't work. |
160 void CloseChromeFrameHelperProcess() { | 160 void CloseChromeFrameHelperProcess() { |
161 HWND window = FindWindow(installer::kChromeFrameHelperWndClass, NULL); | 161 HWND window = FindWindow(installer::kChromeFrameHelperWndClass, NULL); |
162 if (!::IsWindow(window)) | 162 if (!::IsWindow(window)) |
163 return; | 163 return; |
164 | 164 |
165 const DWORD kWaitMs = 3000; | 165 const DWORD kWaitMs = 3000; |
(...skipping 14 matching lines...) Expand all Loading... |
180 << " to exit failed or timed out."; | 180 << " to exit failed or timed out."; |
181 } else { | 181 } else { |
182 kill = false; | 182 kill = false; |
183 VLOG(1) << installer::kChromeFrameHelperExe << " exited normally."; | 183 VLOG(1) << installer::kChromeFrameHelperExe << " exited normally."; |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 if (kill) { | 187 if (kill) { |
188 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; | 188 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; |
189 base::CleanupProcesses(installer::kChromeFrameHelperExe, 0, | 189 base::CleanupProcesses(installer::kChromeFrameHelperExe, 0, |
190 ResultCodes::HUNG, NULL); | 190 content::RESULT_CODE_HUNG, NULL); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 // This method tries to figure out if current user has registered Chrome. | 194 // This method tries to figure out if current user has registered Chrome. |
195 // It returns true iff: | 195 // It returns true iff: |
196 // - Software\Clients\StartMenuInternet\Chromium\"" key has a valid value. | 196 // - Software\Clients\StartMenuInternet\Chromium\"" key has a valid value. |
197 // - The value is same as chrome.exe path for the current installation. | 197 // - The value is same as chrome.exe path for the current installation. |
198 bool CurrentUserHasDefaultBrowser(const InstallerState& installer_state, | 198 bool CurrentUserHasDefaultBrowser(const InstallerState& installer_state, |
199 const Product& product) { | 199 const Product& product) { |
200 std::wstring reg_key(ShellUtil::kRegStartMenuInternet); | 200 std::wstring reg_key(ShellUtil::kRegStartMenuInternet); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 433 } |
434 return result; | 434 return result; |
435 } | 435 } |
436 | 436 |
437 // This method checks if Chrome is currently running or if the user has | 437 // This method checks if Chrome is currently running or if the user has |
438 // cancelled the uninstall operation by clicking Cancel on the confirmation | 438 // cancelled the uninstall operation by clicking Cancel on the confirmation |
439 // box that Chrome pops up. | 439 // box that Chrome pops up. |
440 InstallStatus IsChromeActiveOrUserCancelled( | 440 InstallStatus IsChromeActiveOrUserCancelled( |
441 const InstallerState& installer_state, | 441 const InstallerState& installer_state, |
442 const Product& product) { | 442 const Product& product) { |
443 int32 exit_code = ResultCodes::NORMAL_EXIT; | 443 int32 exit_code = content::RESULT_CODE_NORMAL_EXIT; |
444 CommandLine options(CommandLine::NO_PROGRAM); | 444 CommandLine options(CommandLine::NO_PROGRAM); |
445 options.AppendSwitch(installer::switches::kUninstall); | 445 options.AppendSwitch(installer::switches::kUninstall); |
446 | 446 |
447 // Here we want to save user from frustration (in case of Chrome crashes) | 447 // Here we want to save user from frustration (in case of Chrome crashes) |
448 // and continue with the uninstallation as long as chrome.exe process exit | 448 // and continue with the uninstallation as long as chrome.exe process exit |
449 // code is NOT one of the following: | 449 // code is NOT one of the following: |
450 // - UNINSTALL_CHROME_ALIVE - chrome.exe is currently running | 450 // - UNINSTALL_CHROME_ALIVE - chrome.exe is currently running |
451 // - UNINSTALL_USER_CANCEL - User cancelled uninstallation | 451 // - UNINSTALL_USER_CANCEL - User cancelled uninstallation |
452 // - HUNG - chrome.exe was killed by HuntForZombieProcesses() (until we can | 452 // - HUNG - chrome.exe was killed by HuntForZombieProcesses() (until we can |
453 // give this method some brains and not kill chrome.exe launched | 453 // give this method some brains and not kill chrome.exe launched |
454 // by us, we will not uninstall if we get this return code). | 454 // by us, we will not uninstall if we get this return code). |
455 VLOG(1) << "Launching Chrome to do uninstall tasks."; | 455 VLOG(1) << "Launching Chrome to do uninstall tasks."; |
456 if (product.LaunchChromeAndWait(installer_state.target_path(), options, | 456 if (product.LaunchChromeAndWait(installer_state.target_path(), options, |
457 &exit_code)) { | 457 &exit_code)) { |
458 VLOG(1) << "chrome.exe launched for uninstall confirmation returned: " | 458 VLOG(1) << "chrome.exe launched for uninstall confirmation returned: " |
459 << exit_code; | 459 << exit_code; |
460 if ((exit_code == ResultCodes::UNINSTALL_CHROME_ALIVE) || | 460 if ((exit_code == chrome::RESULT_CODE_UNINSTALL_CHROME_ALIVE) || |
461 (exit_code == ResultCodes::UNINSTALL_USER_CANCEL) || | 461 (exit_code == chrome::RESULT_CODE_UNINSTALL_USER_CANCEL) || |
462 (exit_code == ResultCodes::HUNG)) | 462 (exit_code == chrome::RESULT_CODE_HUNG)) |
463 return installer::UNINSTALL_CANCELLED; | 463 return installer::UNINSTALL_CANCELLED; |
464 | 464 |
465 if (exit_code == ResultCodes::UNINSTALL_DELETE_PROFILE) | 465 if (exit_code == chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE) |
466 return installer::UNINSTALL_DELETE_PROFILE; | 466 return installer::UNINSTALL_DELETE_PROFILE; |
467 } else { | 467 } else { |
468 PLOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation."; | 468 PLOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation."; |
469 } | 469 } |
470 | 470 |
471 return installer::UNINSTALL_CONFIRMED; | 471 return installer::UNINSTALL_CONFIRMED; |
472 } | 472 } |
473 | 473 |
474 bool ShouldDeleteProfile(const InstallerState& installer_state, | 474 bool ShouldDeleteProfile(const InstallerState& installer_state, |
475 const CommandLine& cmd_line, InstallStatus status, | 475 const CommandLine& cmd_line, InstallStatus status, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 858 |
859 // Try and delete the preserved local state once the post-install | 859 // Try and delete the preserved local state once the post-install |
860 // operations are complete. | 860 // operations are complete. |
861 if (!backup_state_file.empty()) | 861 if (!backup_state_file.empty()) |
862 file_util::Delete(backup_state_file, false); | 862 file_util::Delete(backup_state_file, false); |
863 | 863 |
864 return ret; | 864 return ret; |
865 } | 865 } |
866 | 866 |
867 } // namespace installer | 867 } // namespace installer |
OLD | NEW |