Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/installer/setup/uninstall.cc

Issue 14287008: Refactoring installer shortcut deletion; adding dedicated shortcut update feature. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment fixes; reduced RemoveShortcuts() to a single interface. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void DeleteShortcuts(const InstallerState& installer_state, 332 void DeleteShortcuts(const InstallerState& installer_state,
333 const Product& product, 333 const Product& product,
334 const base::FilePath& target_exe) { 334 const base::FilePath& target_exe) {
335 BrowserDistribution* dist = product.distribution(); 335 BrowserDistribution* dist = product.distribution();
336 336
337 // The per-user shortcut for this user, if present on a system-level install, 337 // The per-user shortcut for this user, if present on a system-level install,
338 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). 338 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks().
339 ShellUtil::ShellChange install_level = installer_state.system_install() ? 339 ShellUtil::ShellChange install_level = installer_state.system_install() ?
340 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; 340 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER;
341 341
342 VLOG(1) << "Deleting Desktop shortcut."; 342 VLOG(1) << "Deleting Desktop shortcuts.";
343 if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, 343 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
344 target_exe, install_level, NULL)) { 344 install_level, target_exe)) {
345 LOG(WARNING) << "Failed to delete Desktop shortcut."; 345 LOG(WARNING) << "Failed to delete Desktop shortcuts.";
346 }
347 // Also try to delete the alternate desktop shortcut. It is not sufficient
348 // to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on
349 // delete is considered success.
350 if (!ShellUtil::RemoveShortcut(
351 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, target_exe, install_level,
352 &dist->GetAlternateApplicationName())) {
353 LOG(WARNING) << "Failed to delete alternate Desktop shortcut.";
354 } 346 }
355 347
356 VLOG(1) << "Deleting Quick Launch shortcut."; 348 VLOG(1) << "Deleting Quick Launch shortcuts.";
357 if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, 349 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
358 dist, target_exe, install_level, NULL)) { 350 dist, install_level, target_exe)) {
359 LOG(WARNING) << "Failed to delete Quick Launch shortcut."; 351 LOG(WARNING) << "Failed to delete Quick Launch shortcuts.";
360 } 352 }
361 353
362 VLOG(1) << "Deleting Start Menu shortcuts."; 354 VLOG(1) << "Deleting Start Menu shortcuts.";
363 if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, 355 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist,
364 target_exe, install_level, NULL)) { 356 install_level, target_exe)) {
365 LOG(WARNING) << "Failed to delete Start Menu shortcuts."; 357 LOG(WARNING) << "Failed to delete Start Menu shortcuts.";
366 } 358 }
367 359
368 // Although the shortcut removal calls above will unpin their shortcut if they 360 // Perform dedicated unpinning pinned-to-taskbar shortcuts, rather than
369 // result in a deletion (i.e. shortcut existed and pointed to |target_exe|), 361 // during shortcut removal above (which is unreliable since shortcuts may be
370 // it is possible for shortcuts to remain pinned while their parent shortcut 362 // retargeted at some point).
gab 2013/04/30 22:30:22 "Unpin all pinned-to-taskbar shortcuts that point
huangs 2013/05/01 04:11:51 Done.
371 // has been deleted or changed to point to another |target_exe|. Make sure all 363 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
372 // pinned-to-taskbar shortcuts that point to |target_exe| are unpinned. 364 dist, ShellUtil::CURRENT_USER, target_exe)) {
373 ShellUtil::RemoveTaskbarShortcuts(target_exe.value()); 365 LOG_IF(WARNING, base::win::GetVersion() >= base::win::VERSION_WIN7)
366 << "Failed to unpin taskbar shortcuts at user-level.";
367 }
374 368
375 ShellUtil::RemoveStartScreenShortcuts(product.distribution(), 369 // Remove all secondary tiles with target set to |target_exe| from the
376 target_exe.value()); 370 // start screen for |dist|.
gab 2013/04/30 22:30:22 This comment is wrong, the code actually deletes t
huangs 2013/05/01 04:11:51 Just copying the old comment for RemoveStartScreen
371 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS,
372 dist, install_level, target_exe)) {
373 LOG_IF(WARNING, base::win::GetVersion() >= base::win::VERSION_WIN8)
374 << "Failed to delete start-screen shortcuts.";
375 }
377 } 376 }
378 377
379 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) { 378 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) {
380 base::FilePath parent_dir = path.DirName(); 379 base::FilePath parent_dir = path.DirName();
381 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); 380 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str());
382 if (!ret) { 381 if (!ret) {
383 LOG(ERROR) << "Failed to schedule parent dir for deletion: " 382 LOG(ERROR) << "Failed to schedule parent dir for deletion: "
384 << parent_dir.value(); 383 << parent_dir.value();
385 } else { 384 } else {
386 base::FilePath grandparent_dir(parent_dir.DirName()); 385 base::FilePath grandparent_dir(parent_dir.DirName());
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 // deletion unconditionally. If they are not empty, the session manager 1413 // deletion unconditionally. If they are not empty, the session manager
1415 // will not delete them on reboot. 1414 // will not delete them on reboot.
1416 ScheduleParentAndGrandparentForDeletion(target_path); 1415 ScheduleParentAndGrandparentForDeletion(target_path);
1417 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == 1416 } else if (DeleteApplicationProductAndVendorDirectories(target_path) ==
1418 installer::DELETE_FAILED) { 1417 installer::DELETE_FAILED) {
1419 *uninstall_status = installer::UNINSTALL_FAILED; 1418 *uninstall_status = installer::UNINSTALL_FAILED;
1420 } 1419 }
1421 } 1420 }
1422 1421
1423 } // namespace installer 1422 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698