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 shortcut from Windows Start menu, for the given | |
260 // |install_level|. Either the standard desktop shortcut or the alternate | |
261 // desktop shortcut are present. We don't know which one is present, so we | |
262 // delete both. Finally, we delete the quick lauch shortcut. | |
gab
2012/11/01 04:46:19
This is overly wordy, details about why we do whic
huangs
2012/11/01 19:20:38
Done.
| |
263 void DeleteShortcutsCommon(ShellUtil::ShellChange install_level, | |
264 BrowserDistribution* dist, | |
265 const string16& target) { | |
266 VLOG(1) << "Deleting Desktop shortcut."; | |
267 if (!ShellUtil::RemoveChromeShortcut( | |
268 ShellUtil::SHORTCUT_DESKTOP, dist, target, install_level, NULL)) { | |
269 LOG(WARNING) << "Failed to delete Desktop shortcut."; | |
270 } | |
271 // Also try to delete the alternate desktop shortcut. It is not sufficient | |
272 // to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on | |
273 // delete is considered success. | |
274 if (!ShellUtil::RemoveChromeShortcut( | |
275 ShellUtil::SHORTCUT_DESKTOP, dist, target, install_level, | |
276 &dist->GetAlternateApplicationName())) { | |
277 LOG(WARNING) << "Failed to delete alternate Desktop shortcut."; | |
278 } | |
279 | |
280 VLOG(1) << "Deleting Quick Launch shortcut."; | |
281 if (!ShellUtil::RemoveChromeShortcut( | |
282 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, target, install_level, | |
283 NULL)) { | |
284 LOG(WARNING) << "Failed to delete Quick Launch shortcut."; | |
285 } | |
286 } | |
287 | |
288 | |
259 // This method deletes Chrome shortcut folder from Windows Start menu. It | 289 // This method deletes Chrome shortcut folder from Windows Start menu. It |
gab
2012/11/01 04:46:19
Can you also make this cleaner while you're at it
huangs
2012/11/01 19:20:38
Done.
| |
260 // checks system_uninstall to see if the shortcut is in all users start menu | 290 // checks system_uninstall to see if the shortcut is in all users start menu |
261 // or current user start menu. | 291 // or current user start menu. After deleting individual shortcuts, we then |
262 // We try to remove the standard desktop shortcut but if that fails we try | 292 // remove all start screen secondary tiles by removing the folder Windows |
263 // to remove the alternate desktop shortcut. Only one of them should be | |
264 // present in a given install but at this point we don't know which one. | |
265 // We remove all start screen secondary tiles by removing the folder Windows | |
266 // uses to store this installation's tiles. | 293 // uses to store this installation's tiles. |
267 void DeleteChromeShortcuts(const InstallerState& installer_state, | 294 void DeleteChromeShortcuts(const InstallerState& installer_state, |
268 const Product& product, | 295 const Product& product, |
269 const string16& chrome_exe) { | 296 const string16& chrome_exe) { |
270 if (!product.is_chrome()) { | 297 if (!product.is_chrome()) { |
271 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; | 298 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; |
272 return; | 299 return; |
273 } | 300 } |
274 | 301 |
275 BrowserDistribution* dist = product.distribution(); | |
276 | |
277 // The per-user shortcut for this user, if present on a system-level install, | 302 // 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(). | 303 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). |
279 ShellUtil::ShellChange install_level = installer_state.system_install() ? | 304 ShellUtil::ShellChange install_level = installer_state.system_install() ? |
280 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | 305 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
281 | 306 |
282 VLOG(1) << "Deleting Desktop shortcut."; | 307 BrowserDistribution* dist = product.distribution(); |
erikwright (departed)
2012/11/01 01:21:50
For a cleaner diff, move the declaration/assignmen
huangs
2012/11/01 19:20:38
Done.
| |
283 if (!ShellUtil::RemoveChromeShortcut( | 308 DeleteShortcutsCommon(install_level, dist, chrome_exe); |
erikwright (departed)
2012/11/01 01:21:50
Leave a log statement in DeleteChromeShortcuts lik
huangs
2012/11/01 19:20:38
Using method #1, in case there are more product-sp
| |
284 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, NULL)) { | |
285 LOG(WARNING) << "Failed to delete Desktop shortcut."; | |
286 } | |
287 // 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 | |
289 // delete is considered success. | |
290 if (!ShellUtil::RemoveChromeShortcut( | |
291 ShellUtil::SHORTCUT_DESKTOP, dist, chrome_exe, install_level, | |
292 &dist->GetAlternateApplicationName())) { | |
293 LOG(WARNING) << "Failed to delete alternate Desktop shortcut."; | |
294 } | |
295 | |
296 VLOG(1) << "Deleting Quick Launch shortcut."; | |
297 if (!ShellUtil::RemoveChromeShortcut( | |
298 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, chrome_exe, install_level, | |
299 NULL)) { | |
300 LOG(WARNING) << "Failed to delete Quick Launch shortcut."; | |
301 } | |
302 | 309 |
303 VLOG(1) << "Deleting Start Menu shortcuts."; | 310 VLOG(1) << "Deleting Start Menu shortcuts."; |
gab
2012/11/01 04:46:19
This wasn't moved to the Common method above as th
huangs
2012/11/01 19:20:38
Moving all these into common, along with
ShellUtil
gab
2012/11/02 04:19:58
Hmmm ShellUtil::RemoveChromeStartScreenShortcuts(
| |
304 if (!ShellUtil::RemoveChromeShortcut( | 311 if (!ShellUtil::RemoveChromeShortcut( |
305 ShellUtil::SHORTCUT_START_MENU, dist, chrome_exe, install_level, | 312 ShellUtil::SHORTCUT_START_MENU, dist, chrome_exe, install_level, |
306 NULL)) { | 313 NULL)) { |
307 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; | 314 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; |
308 } | 315 } |
309 | 316 |
310 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(), | 317 ShellUtil::RemoveChromeStartScreenShortcuts(dist, chrome_exe); |
311 chrome_exe); | |
312 } | 318 } |
313 | 319 |
320 // This method deletes App Host shortcuts. | |
gab
2012/11/01 04:46:19
// Deletes App Host shortcuts.
huangs
2012/11/01 19:20:38
Done (same style as DeleteChromeShortcuts()).
| |
321 void DeleteAppHostShortcuts(const InstallerState& installer_state, | |
322 const Product& product, | |
323 const string16& app_host_exe) { | |
324 if (!product.is_chrome_app_host()) { | |
325 VLOG(1) << __FUNCTION__ " called for non-APP HOST distribution"; | |
326 return; | |
327 } | |
328 | |
329 // The per-user shortcut for this user, if present on a system-level install, | |
330 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). | |
gab
2012/11/01 04:46:19
This comment doesn't apply to the app_host (it was
huangs
2012/11/01 19:20:38
Oops. Deleted!
| |
331 ShellUtil::ShellChange install_level = installer_state.system_install() ? | |
gab
2012/11/01 04:46:19
Aren't your shortcuts always user-level? At least
huangs
2012/11/01 19:20:38
For now it is, but we want to future-proof. If se
| |
332 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | |
333 | |
334 DeleteShortcutsCommon(install_level, product.distribution(), app_host_exe); | |
335 } | |
336 | |
337 | |
314 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) { | 338 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) { |
315 FilePath parent_dir = path.DirName(); | 339 FilePath parent_dir = path.DirName(); |
316 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); | 340 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); |
317 if (!ret) { | 341 if (!ret) { |
318 LOG(ERROR) << "Failed to schedule parent dir for deletion: " | 342 LOG(ERROR) << "Failed to schedule parent dir for deletion: " |
319 << parent_dir.value(); | 343 << parent_dir.value(); |
320 } else { | 344 } else { |
321 FilePath grandparent_dir(parent_dir.DirName()); | 345 FilePath grandparent_dir(parent_dir.DirName()); |
322 ret = ScheduleFileSystemEntityForDeletion(grandparent_dir.value().c_str()); | 346 ret = ScheduleFileSystemEntityForDeletion(grandparent_dir.value().c_str()); |
323 if (!ret) { | 347 if (!ret) { |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 const CommandLine& cmd_line) { | 1026 const CommandLine& cmd_line) { |
1003 InstallStatus status = installer::UNINSTALL_CONFIRMED; | 1027 InstallStatus status = installer::UNINSTALL_CONFIRMED; |
1004 BrowserDistribution* browser_dist = product.distribution(); | 1028 BrowserDistribution* browser_dist = product.distribution(); |
1005 const string16 chrome_exe( | 1029 const string16 chrome_exe( |
1006 installer_state.target_path().Append(installer::kChromeExe).value()); | 1030 installer_state.target_path().Append(installer::kChromeExe).value()); |
1007 | 1031 |
1008 const string16 suffix(ShellUtil::GetCurrentInstallationSuffix(browser_dist, | 1032 const string16 suffix(ShellUtil::GetCurrentInstallationSuffix(browser_dist, |
1009 chrome_exe)); | 1033 chrome_exe)); |
1010 | 1034 |
1011 bool is_chrome = product.is_chrome(); | 1035 bool is_chrome = product.is_chrome(); |
1036 bool is_app_host = product.is_chrome_app_host(); | |
1012 | 1037 |
1013 VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); | 1038 VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); |
1014 | 1039 |
1015 if (force_uninstall) { | 1040 if (force_uninstall) { |
1016 // Since --force-uninstall command line option is used, we are going to | 1041 // Since --force-uninstall command line option is used, we are going to |
1017 // do silent uninstall. Try to close all running Chrome instances. | 1042 // do silent uninstall. Try to close all running Chrome instances. |
1018 // NOTE: We don't do this for Chrome Frame. | 1043 // NOTE: We don't do this for Chrome Frame. |
1019 if (is_chrome) | 1044 if (is_chrome) |
1020 CloseAllChromeProcesses(); | 1045 CloseAllChromeProcesses(); |
1021 } else if (is_chrome) { | 1046 } else if (is_chrome) { |
(...skipping 24 matching lines...) Expand all Loading... | |
1046 new_cmd.AppendSwitch(installer::switches::kRemoveChromeRegistration); | 1071 new_cmd.AppendSwitch(installer::switches::kRemoveChromeRegistration); |
1047 if (!suffix.empty()) { | 1072 if (!suffix.empty()) { |
1048 new_cmd.AppendSwitchNative( | 1073 new_cmd.AppendSwitchNative( |
1049 installer::switches::kRegisterChromeBrowserSuffix, suffix); | 1074 installer::switches::kRegisterChromeBrowserSuffix, suffix); |
1050 } | 1075 } |
1051 DWORD exit_code = installer::UNKNOWN_STATUS; | 1076 DWORD exit_code = installer::UNKNOWN_STATUS; |
1052 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 1077 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
1053 } | 1078 } |
1054 } | 1079 } |
1055 | 1080 |
1081 if (is_app_host) { | |
gab
2012/11/01 04:46:19
|is_app_host| can be inlined here, no need for a v
huangs
2012/11/01 19:20:38
Done. The motivation was code symmetry, since is_
| |
1082 const string16 app_host_exe(installer_state.target_path(). | |
1083 Append(installer::kChromeAppHostExe).value()); | |
gab
2012/11/01 04:46:19
Bring '.' down to this line and indent 4 more spac
huangs
2012/11/01 19:20:38
The whole thing won't fit. Trying with keeping in
| |
1084 // First delete shortcuts from Start->Programs, Desktop & Quick Launch. | |
gab
2012/11/01 04:46:19
-First (this is the only thing you do...)
s/Start
huangs
2012/11/01 19:20:38
Done, also changed the comment that I copied this
| |
1085 DeleteAppHostShortcuts(installer_state, product, app_host_exe); | |
1086 } | |
1087 | |
1056 // Chrome is not in use so lets uninstall Chrome by deleting various files | 1088 // Chrome is not in use so lets uninstall Chrome by deleting various files |
1057 // and registry entries. Here we will just make best effort and keep going | 1089 // and registry entries. Here we will just make best effort and keep going |
1058 // in case of errors. | 1090 // in case of errors. |
1059 if (is_chrome) { | 1091 if (is_chrome) { |
1060 ClearRlzProductState(); | 1092 ClearRlzProductState(); |
1061 // Delete the key that delegate_execute might make. | 1093 // Delete the key that delegate_execute might make. |
1062 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 1094 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
1063 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 1095 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
1064 chrome::kMetroRegistryPath); | 1096 chrome::kMetroRegistryPath); |
1065 } | 1097 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 | 1297 |
1266 // Try and delete the preserved local state once the post-install | 1298 // Try and delete the preserved local state once the post-install |
1267 // operations are complete. | 1299 // operations are complete. |
1268 if (!backup_state_file.empty()) | 1300 if (!backup_state_file.empty()) |
1269 file_util::Delete(backup_state_file, false); | 1301 file_util::Delete(backup_state_file, false); |
1270 | 1302 |
1271 return ret; | 1303 return ret; |
1272 } | 1304 } |
1273 | 1305 |
1274 } // namespace installer | 1306 } // namespace installer |
OLD | NEW |