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

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

Issue 13864015: Move app launcher and chrome apps shortcut strings into the installer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migrate_app_id_fix
Patch Set: fix linux Created 7 years, 2 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_START;
grt (UTC plus 2) 2013/10/22 13:37:45 if you use ShellUtil::ShortcutLocation rather than
gab 2013/10/22 17:07:29 Yes, but then you can't use ++ (enums are not iter
grt (UTC plus 2) 2013/10/22 18:08:07 agreed. i haven't been writing code enough recentl
352 old_target_exe, updated_properties)) { 352 location != ShellUtil::SHORTCUT_LOCATION_END; ++location) {
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 with ShortcutLocation:"
huangs 2013/10/17 19:13:35 NIT: Space after ":".
grt (UTC plus 2) 2013/10/22 13:37:45 nit: "with" -> "in"
calamity 2013/11/20 05:43:30 Done.
calamity 2013/11/20 05:43:30 Done.
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_START;
grt (UTC plus 2) 2013/10/22 13:37:45 int -> ShellUtil::ShortcutLocation
gab 2013/10/22 17:07:29 Same here.
calamity 2013/11/20 05:43:30 Done.
calamity 2013/11/20 05:43:30 Done.
402 } 379 location != ShellUtil::SHORTCUT_LOCATION_END; ++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 with ShortcutLocation:"
huangs 2013/10/17 19:13:35 NIT: Space after ":".
grt (UTC plus 2) 2013/10/22 13:37:45 nit: "with" -> "in"
gab 2013/10/22 17:07:29 Given this is the ID of the shortcut location I th
calamity 2013/11/20 05:43:30 Done.
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 } 386 }
415 387
416 // Unpin all pinned-to-taskbar shortcuts that point to |chrome_exe|. 388 // Unpin all pinned-to-taskbar shortcuts that point to |chrome_exe|.
417 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, 389 if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
gab 2013/10/17 15:13:31 SHORTCUT_LOCATION_TASKBAR_PINS will be processed a
calamity 2013/11/20 05:43:30 Done.
418 dist, ShellUtil::CURRENT_USER, target_exe)) { 390 dist, ShellUtil::CURRENT_USER, target_exe)) {
419 LOG(WARNING) << "Failed to unpin taskbar shortcuts at user-level."; 391 LOG(WARNING) << "Failed to unpin taskbar shortcuts at user-level.";
420 } 392 }
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 }
427 } 393 }
428 394
429 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) { 395 bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) {
430 base::FilePath parent_dir = path.DirName(); 396 base::FilePath parent_dir = path.DirName();
431 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir); 397 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir);
432 if (!ret) { 398 if (!ret) {
433 LOG(ERROR) << "Failed to schedule parent dir for deletion: " 399 LOG(ERROR) << "Failed to schedule parent dir for deletion: "
434 << parent_dir.value(); 400 << parent_dir.value();
435 } else { 401 } else {
436 base::FilePath grandparent_dir(parent_dir.DirName()); 402 base::FilePath grandparent_dir(parent_dir.DirName());
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 // If we need a reboot to continue, schedule the parent directories for 1458 // If we need a reboot to continue, schedule the parent directories for
1493 // deletion unconditionally. If they are not empty, the session manager 1459 // deletion unconditionally. If they are not empty, the session manager
1494 // will not delete them on reboot. 1460 // will not delete them on reboot.
1495 ScheduleParentAndGrandparentForDeletion(target_path); 1461 ScheduleParentAndGrandparentForDeletion(target_path);
1496 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { 1462 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) {
1497 *uninstall_status = UNINSTALL_FAILED; 1463 *uninstall_status = UNINSTALL_FAILED;
1498 } 1464 }
1499 } 1465 }
1500 1466
1501 } // namespace installer 1467 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698