Chromium Code Reviews| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 const base::FilePath& new_target_exe) { | 338 const base::FilePath& new_target_exe) { |
| 339 if (installer_state.system_install()) { | 339 if (installer_state.system_install()) { |
| 340 NOTREACHED(); | 340 NOTREACHED(); |
| 341 return; | 341 return; |
| 342 } | 342 } |
| 343 BrowserDistribution* dist = product.distribution(); | 343 BrowserDistribution* dist = product.distribution(); |
| 344 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; | 344 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; |
| 345 ShellUtil::ShortcutProperties updated_properties(install_level); | 345 ShellUtil::ShortcutProperties updated_properties(install_level); |
| 346 updated_properties.set_target(new_target_exe); | 346 updated_properties.set_target(new_target_exe); |
| 347 | 347 |
| 348 // TODO(huangs): Make this data-driven, along with DeleteShortcuts(). | 348 // Retarget all shortcuts that point to |old_target_exe| from all |
| 349 VLOG(1) << "Retargeting Desktop shortcuts."; | 349 // ShellUtil::ShortcutLocations. |
| 350 if (!ShellUtil::UpdateShortcutsWithArgs( | 350 VLOG(1) << "Retargeting shortcuts."; |
| 351 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, install_level, | 351 for (int location = ShellUtil::SHORTCUT_LOCATION_FIRST; |
| 352 old_target_exe, updated_properties)) { | 352 location != ShellUtil::NUM_SHORTCUT_LOCATIONS; ++location) { |
|
gab
2013/11/25 13:05:10
You marked as done, but looks like you only change
calamity
2013/11/26 02:51:17
Done.
| |
| 353 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; | 353 if (!ShellUtil::UpdateShortcutsWithArgs( |
| 354 } | 354 static_cast<ShellUtil::ShortcutLocation>(location), dist, |
| 355 | 355 install_level, old_target_exe, updated_properties)) { |
| 356 VLOG(1) << "Retargeting Quick Launch shortcuts."; | 356 LOG(WARNING) << "Failed to retarget shortcuts in ShortcutLocation: " |
| 357 if (!ShellUtil::UpdateShortcutsWithArgs( | 357 << location; |
| 358 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, install_level, | 358 } |
| 359 old_target_exe, updated_properties)) { | |
| 360 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; | |
| 361 } | |
| 362 | |
| 363 VLOG(1) << "Retargeting Start Menu shortcuts."; | |
| 364 if (!ShellUtil::UpdateShortcutsWithArgs( | |
| 365 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, install_level, | |
| 366 old_target_exe, updated_properties)) { | |
| 367 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; | |
| 368 } | |
| 369 | |
| 370 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. | |
| 371 if (!ShellUtil::UpdateShortcutsWithArgs( | |
| 372 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, dist, | |
| 373 ShellUtil::CURRENT_USER, old_target_exe, updated_properties)) { | |
| 374 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; | |
| 375 } | |
| 376 | |
| 377 // Retarget the folder of secondary tiles from the start screen for |dist|. | |
| 378 if (!ShellUtil::UpdateShortcutsWithArgs( | |
| 379 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, dist, install_level, | |
| 380 old_target_exe, updated_properties)) { | |
| 381 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; | |
| 382 } | 359 } |
| 383 } | 360 } |
| 384 | 361 |
| 385 // Deletes shortcuts at |install_level| from Start menu, Desktop, | 362 // Deletes shortcuts at |install_level| from Start menu, Desktop, |
| 386 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). | 363 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). |
| 387 // Only shortcuts pointing to |target_exe| will be removed. | 364 // Only shortcuts pointing to |target_exe| will be removed. |
| 388 void DeleteShortcuts(const InstallerState& installer_state, | 365 void DeleteShortcuts(const InstallerState& installer_state, |
| 389 const Product& product, | 366 const Product& product, |
| 390 const base::FilePath& target_exe) { | 367 const base::FilePath& target_exe) { |
| 391 BrowserDistribution* dist = product.distribution(); | 368 BrowserDistribution* dist = product.distribution(); |
| 392 | 369 |
| 393 // The per-user shortcut for this user, if present on a system-level install, | 370 // The per-user shortcut for this user, if present on a system-level install, |
| 394 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). | 371 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). |
| 395 ShellUtil::ShellChange install_level = installer_state.system_install() ? | 372 ShellUtil::ShellChange install_level = installer_state.system_install() ? |
| 396 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | 373 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| 397 | 374 |
| 398 VLOG(1) << "Deleting Desktop shortcuts."; | 375 // Delete and unpin all shortcuts that point to |target_exe| from all |
| 399 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, | 376 // ShellUtil::ShortcutLocations. |
| 400 install_level, target_exe)) { | 377 VLOG(1) << "Deleting shortcuts."; |
| 401 LOG(WARNING) << "Failed to delete Desktop shortcuts."; | 378 for (int location = ShellUtil::SHORTCUT_LOCATION_FIRST; |
| 402 } | 379 location < ShellUtil::NUM_SHORTCUT_LOCATIONS; ++location) { |
| 403 | 380 if (!ShellUtil::RemoveShortcuts( |
| 404 VLOG(1) << "Deleting Quick Launch shortcuts."; | 381 static_cast<ShellUtil::ShortcutLocation>(location), dist, |
| 405 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, | 382 install_level, target_exe)) { |
| 406 dist, install_level, target_exe)) { | 383 LOG(WARNING) << "Failed to delete shortcuts in ShortcutLocation:" |
| 407 LOG(WARNING) << "Failed to delete Quick Launch shortcuts."; | 384 << location; |
| 408 } | 385 } |
| 409 | |
| 410 VLOG(1) << "Deleting Start Menu shortcuts."; | |
| 411 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, | |
| 412 install_level, target_exe)) { | |
| 413 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; | |
| 414 } | |
| 415 | |
| 416 // Unpin all pinned-to-taskbar shortcuts that point to |chrome_exe|. | |
| 417 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, | |
| 418 dist, ShellUtil::CURRENT_USER, target_exe)) { | |
| 419 LOG(WARNING) << "Failed to unpin taskbar shortcuts at user-level."; | |
| 420 } | |
| 421 | |
| 422 // Delete the folder of secondary tiles from the start screen for |dist|. | |
| 423 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, | |
| 424 dist, install_level, target_exe)) { | |
| 425 LOG(WARNING) << "Failed to delete start-screen shortcuts."; | |
| 426 } | 386 } |
| 427 } | 387 } |
| 428 | 388 |
| 429 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) { | 389 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) { |
| 430 base::FilePath parent_dir = path.DirName(); | 390 base::FilePath parent_dir = path.DirName(); |
| 431 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir); | 391 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir); |
| 432 if (!ret) { | 392 if (!ret) { |
| 433 LOG(ERROR) << "Failed to schedule parent dir for deletion: " | 393 LOG(ERROR) << "Failed to schedule parent dir for deletion: " |
| 434 << parent_dir.value(); | 394 << parent_dir.value(); |
| 435 } else { | 395 } else { |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 // If we need a reboot to continue, schedule the parent directories for | 1453 // If we need a reboot to continue, schedule the parent directories for |
| 1494 // deletion unconditionally. If they are not empty, the session manager | 1454 // deletion unconditionally. If they are not empty, the session manager |
| 1495 // will not delete them on reboot. | 1455 // will not delete them on reboot. |
| 1496 ScheduleParentAndGrandparentForDeletion(target_path); | 1456 ScheduleParentAndGrandparentForDeletion(target_path); |
| 1497 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { | 1457 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { |
| 1498 *uninstall_status = UNINSTALL_FAILED; | 1458 *uninstall_status = UNINSTALL_FAILED; |
| 1499 } | 1459 } |
| 1500 } | 1460 } |
| 1501 | 1461 |
| 1502 } // namespace installer | 1462 } // namespace installer |
| OLD | NEW |