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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 if (kill) { | 252 if (kill) { |
253 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; | 253 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; |
254 base::CleanupProcesses(installer::kChromeFrameHelperExe, base::TimeDelta(), | 254 base::CleanupProcesses(installer::kChromeFrameHelperExe, base::TimeDelta(), |
255 content::RESULT_CODE_HUNG, NULL); | 255 content::RESULT_CODE_HUNG, NULL); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 // This method deletes Chrome shortcut folder from Windows Start menu. It | 259 // This method deletes shortcut from Windows Start menu, for the given |
260 // checks system_uninstall to see if the shortcut is in all users start menu | 260 // |install_level|. Either the standard desktop shortcut or the alternate |
261 // or current user start menu. | 261 // desktop shortcut are present. We don't know which one is present, so we |
262 // We try to remove the standard desktop shortcut but if that fails we try | 262 // delete both. Finally, we delete the quick lauch shortcut. |
263 // to remove the alternate desktop shortcut. Only one of them should be | 263 void DeleteShortcutsCommon(ShellUtil::ShellChange install_level, |
264 // present in a given install but at this point we don't know which one. | 264 BrowserDistribution* dist, |
265 // We remove all start screen secondary tiles by removing the folder Windows | |
266 // uses to store this installation's tiles. | |
267 void DeleteChromeShortcuts(const InstallerState& installer_state, | |
268 const Product& product, | |
269 const string16& chrome_exe) { | 265 const string16& chrome_exe) { |
270 if (!product.is_chrome()) { | |
271 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; | |
272 return; | |
273 } | |
274 | |
275 BrowserDistribution* dist = product.distribution(); | |
276 | |
277 // The per-user shortcut for this user, if present on a system-level install, | |
278 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). | |
279 ShellUtil::ShellChange install_level = installer_state.system_install() ? | |
280 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | |
281 | |
282 VLOG(1) << "Deleting Desktop shortcut."; | 266 VLOG(1) << "Deleting Desktop shortcut."; |
283 if (!ShellUtil::RemoveChromeShortcut( | 267 if (!ShellUtil::RemoveChromeShortcut( |
284 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, NULL)) { | 268 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, NULL)) { |
285 LOG(WARNING) << "Failed to delete Desktop shortcut."; | 269 LOG(WARNING) << "Failed to delete Desktop shortcut."; |
286 } | 270 } |
287 // Also try to delete the alternate desktop shortcut. It is not sufficient | 271 // Also try to delete the alternate desktop shortcut. It is not sufficient |
288 // to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on | 272 // to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on |
289 // delete is considered success. | 273 // delete is considered success. |
290 if (!ShellUtil::RemoveChromeShortcut( | 274 if (!ShellUtil::RemoveChromeShortcut( |
291 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, | 275 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, |
292 &dist->GetAlternateApplicationName())) { | 276 &dist->GetAlternateApplicationName())) { |
293 LOG(WARNING) << "Failed to delete alternate Desktop shortcut."; | 277 LOG(WARNING) << "Failed to delete alternate Desktop shortcut."; |
294 } | 278 } |
295 | 279 |
296 VLOG(1) << "Deleting Quick Launch shortcut."; | 280 VLOG(1) << "Deleting Quick Launch shortcut."; |
297 if (!ShellUtil::RemoveChromeShortcut( | 281 if (!ShellUtil::RemoveChromeShortcut( |
298 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, chrome_exe, install_level, | 282 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, chrome_exe, install_level, |
299 NULL)) { | 283 NULL)) { |
300 LOG(WARNING) << "Failed to delete Quick Launch shortcut."; | 284 LOG(WARNING) << "Failed to delete Quick Launch shortcut."; |
301 } | 285 } |
| 286 } |
| 287 |
| 288 // This method deletes App Host shortcuts. |
| 289 void DeleteAppHostShortcuts(const InstallerState& installer_state, |
| 290 const Product& product, |
| 291 const string16& chrome_exe) { |
| 292 if (!product.is_chrome_app_host()) { |
| 293 VLOG(1) << __FUNCTION__ " called for non-APP HOST distribution"; |
| 294 return; |
| 295 } |
| 296 |
| 297 // The per-user shortcut for this user, if present on a system-level install, |
| 298 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). |
| 299 ShellUtil::ShellChange install_level = installer_state.system_install() ? |
| 300 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| 301 |
| 302 DeleteShortcutsCommon(install_level, product.distribution(), chrome_exe); |
| 303 } |
| 304 |
| 305 // This method deletes Chrome shortcut folder from Windows Start menu. It |
| 306 // checks system_uninstall to see if the shortcut is in all users start menu |
| 307 // or current user start menu. After deleting individual shortcuts, we then |
| 308 // remove all start screen secondary tiles by removing the folder Windows |
| 309 // uses to store this installation's tiles. |
| 310 void DeleteChromeShortcuts(const InstallerState& installer_state, |
| 311 const Product& product, |
| 312 const string16& chrome_exe) { |
| 313 if (!product.is_chrome()) { |
| 314 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; |
| 315 return; |
| 316 } |
| 317 |
| 318 // The per-user shortcut for this user, if present on a system-level install, |
| 319 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). |
| 320 ShellUtil::ShellChange install_level = installer_state.system_install() ? |
| 321 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| 322 |
| 323 BrowserDistribution* dist = product.distribution(); |
| 324 DeleteShortcutsCommon(install_level, dist, chrome_exe); |
302 | 325 |
303 VLOG(1) << "Deleting Start Menu shortcuts."; | 326 VLOG(1) << "Deleting Start Menu shortcuts."; |
304 if (!ShellUtil::RemoveChromeShortcut( | 327 if (!ShellUtil::RemoveChromeShortcut( |
305 ShellUtil::SHORTCUT_START_MENU, dist, chrome_exe, install_level, | 328 ShellUtil::SHORTCUT_START_MENU, dist, chrome_exe, install_level, |
306 NULL)) { | 329 NULL)) { |
307 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; | 330 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; |
308 } | 331 } |
309 | 332 |
310 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(), | 333 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(), |
311 chrome_exe); | 334 chrome_exe); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 const CommandLine& cmd_line) { | 1024 const CommandLine& cmd_line) { |
1002 InstallStatus status = installer::UNINSTALL_CONFIRMED; | 1025 InstallStatus status = installer::UNINSTALL_CONFIRMED; |
1003 BrowserDistribution* browser_dist = product.distribution(); | 1026 BrowserDistribution* browser_dist = product.distribution(); |
1004 const string16 chrome_exe( | 1027 const string16 chrome_exe( |
1005 installer_state.target_path().Append(installer::kChromeExe).value()); | 1028 installer_state.target_path().Append(installer::kChromeExe).value()); |
1006 | 1029 |
1007 const string16 suffix(ShellUtil::GetCurrentInstallationSuffix(browser_dist, | 1030 const string16 suffix(ShellUtil::GetCurrentInstallationSuffix(browser_dist, |
1008 chrome_exe)); | 1031 chrome_exe)); |
1009 | 1032 |
1010 bool is_chrome = product.is_chrome(); | 1033 bool is_chrome = product.is_chrome(); |
| 1034 bool is_app_host = product.is_chrome_app_host(); |
1011 | 1035 |
1012 VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); | 1036 VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); |
1013 | 1037 |
1014 if (force_uninstall) { | 1038 if (force_uninstall) { |
1015 // Since --force-uninstall command line option is used, we are going to | 1039 // Since --force-uninstall command line option is used, we are going to |
1016 // do silent uninstall. Try to close all running Chrome instances. | 1040 // do silent uninstall. Try to close all running Chrome instances. |
1017 // NOTE: We don't do this for Chrome Frame. | 1041 // NOTE: We don't do this for Chrome Frame. |
1018 if (is_chrome) | 1042 if (is_chrome) |
1019 CloseAllChromeProcesses(); | 1043 CloseAllChromeProcesses(); |
1020 } else if (is_chrome) { | 1044 } else if (is_chrome) { |
(...skipping 27 matching lines...) Expand all Loading... |
1048 installer::switches::kRegisterChromeBrowserSuffix, suffix); | 1072 installer::switches::kRegisterChromeBrowserSuffix, suffix); |
1049 } | 1073 } |
1050 DWORD exit_code = installer::UNKNOWN_STATUS; | 1074 DWORD exit_code = installer::UNKNOWN_STATUS; |
1051 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 1075 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
1052 } | 1076 } |
1053 } | 1077 } |
1054 | 1078 |
1055 // Chrome is not in use so lets uninstall Chrome by deleting various files | 1079 // Chrome is not in use so lets uninstall Chrome by deleting various files |
1056 // and registry entries. Here we will just make best effort and keep going | 1080 // and registry entries. Here we will just make best effort and keep going |
1057 // in case of errors. | 1081 // in case of errors. |
| 1082 if (is_app_host) { |
| 1083 // First delete shortcuts from Start->Programs, Desktop & Quick Launch. |
| 1084 DeleteAppHostShortcuts(installer_state, product, chrome_exe); |
| 1085 } |
| 1086 |
1058 if (is_chrome) { | 1087 if (is_chrome) { |
1059 ClearRlzProductState(); | 1088 ClearRlzProductState(); |
1060 // Delete the key that delegate_execute might make. | 1089 // Delete the key that delegate_execute might make. |
1061 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 1090 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
1062 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 1091 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
1063 chrome::kMetroRegistryPath); | 1092 chrome::kMetroRegistryPath); |
1064 } | 1093 } |
1065 | 1094 |
1066 auto_launch_util::DisableAllAutoStartFeatures( | 1095 auto_launch_util::DisableAllAutoStartFeatures( |
1067 ASCIIToUTF16(chrome::kInitialProfile)); | 1096 ASCIIToUTF16(chrome::kInitialProfile)); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1297 |
1269 // Try and delete the preserved local state once the post-install | 1298 // Try and delete the preserved local state once the post-install |
1270 // operations are complete. | 1299 // operations are complete. |
1271 if (!backup_state_file.empty()) | 1300 if (!backup_state_file.empty()) |
1272 file_util::Delete(backup_state_file, false); | 1301 file_util::Delete(backup_state_file, false); |
1273 | 1302 |
1274 return ret; | 1303 return ret; |
1275 } | 1304 } |
1276 | 1305 |
1277 } // namespace installer | 1306 } // namespace installer |
OLD | NEW |