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

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

Issue 23581012: Restricting scope of ShellUtil's shortcut update feature for its specific usage in Chrome self-dest… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Function renaming and comment fixes. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/installer/util/shell_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 321 }
322 } 322 }
323 323
324 if (kill) { 324 if (kill) {
325 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; 325 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing.";
326 base::CleanupProcesses(installer::kChromeFrameHelperExe, base::TimeDelta(), 326 base::CleanupProcesses(installer::kChromeFrameHelperExe, base::TimeDelta(),
327 content::RESULT_CODE_HUNG, NULL); 327 content::RESULT_CODE_HUNG, NULL);
328 } 328 }
329 } 329 }
330 330
331 // Updates shortcuts to |old_target_exe| to target |new_target_exe| instead. If 331 // Updates shortcuts to |old_target_exe| that have non-empty args, making them
332 // |require_args| is set, then only updates shortcuts with non-empty targets. 332 // target |new_target_exe| instead. The non-empty args requirement is a
333 // This should only be called from user-level. 333 // heuristic to determine whether a shortcut is "user-generated". This routine
334 void RetargetShortcuts(const InstallerState& installer_state, 334 // can only be called for user-level installs.
335 const Product& product, 335 void RetargetUserShortcutsWithArgs(const InstallerState& installer_state,
336 const base::FilePath& old_target_exe, 336 const Product& product,
337 const base::FilePath& new_target_exe, 337 const base::FilePath& old_target_exe,
338 bool require_args) { 338 const base::FilePath& new_target_exe) {
339 if (installer_state.system_install()) {
340 NOTREACHED();
341 return;
342 }
339 BrowserDistribution* dist = product.distribution(); 343 BrowserDistribution* dist = product.distribution();
340 DCHECK(!installer_state.system_install());
341 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; 344 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER;
342 ShellUtil::ShortcutProperties updated_properties(install_level); 345 ShellUtil::ShortcutProperties updated_properties(install_level);
343 updated_properties.set_target(new_target_exe); 346 updated_properties.set_target(new_target_exe);
344 347
348 // TODO(huangs): Make this data-driven, along with DeleteShortcuts().
345 VLOG(1) << "Retargeting Desktop shortcuts."; 349 VLOG(1) << "Retargeting Desktop shortcuts.";
346 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, 350 if (!ShellUtil::UpdateShortcutsWithArgs(
347 install_level, old_target_exe, require_args, 351 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, install_level,
348 updated_properties)) { 352 old_target_exe, updated_properties)) {
349 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; 353 LOG(WARNING) << "Failed to retarget Desktop shortcuts.";
350 } 354 }
351 355
352 VLOG(1) << "Retargeting Quick Launch shortcuts."; 356 VLOG(1) << "Retargeting Quick Launch shortcuts.";
353 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, 357 if (!ShellUtil::UpdateShortcutsWithArgs(
354 dist, install_level, old_target_exe, 358 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, install_level,
355 require_args, updated_properties)) { 359 old_target_exe, updated_properties)) {
356 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; 360 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts.";
357 } 361 }
358 362
359 VLOG(1) << "Retargeting Start Menu shortcuts."; 363 VLOG(1) << "Retargeting Start Menu shortcuts.";
360 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, 364 if (!ShellUtil::UpdateShortcutsWithArgs(
361 install_level, old_target_exe, require_args, 365 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, install_level,
362 updated_properties)) { 366 old_target_exe, updated_properties)) {
363 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; 367 LOG(WARNING) << "Failed to retarget Start Menu shortcuts.";
364 } 368 }
365 369
366 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. 370 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|.
367 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, 371 if (!ShellUtil::UpdateShortcutsWithArgs(
368 dist, ShellUtil::CURRENT_USER, old_target_exe, 372 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, dist,
369 require_args, updated_properties)) { 373 ShellUtil::CURRENT_USER, old_target_exe, updated_properties)) {
370 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; 374 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level.";
371 } 375 }
372 376
373 // Retarget the folder of secondary tiles from the start screen for |dist|. 377 // Retarget the folder of secondary tiles from the start screen for |dist|.
374 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, 378 if (!ShellUtil::UpdateShortcutsWithArgs(
375 dist, install_level, old_target_exe, 379 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, dist, install_level,
376 require_args, updated_properties)) { 380 old_target_exe, updated_properties)) {
377 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; 381 LOG(WARNING) << "Failed to retarget start-screen shortcuts.";
378 } 382 }
379 } 383 }
380 384
381 // Deletes shortcuts at |install_level| from Start menu, Desktop, 385 // Deletes shortcuts at |install_level| from Start menu, Desktop,
382 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). 386 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+).
383 // Only shortcuts pointing to |target_exe| will be removed. 387 // Only shortcuts pointing to |target_exe| will be removed.
384 void DeleteShortcuts(const InstallerState& installer_state, 388 void DeleteShortcuts(const InstallerState& installer_state,
385 const Product& product, 389 const Product& product,
386 const base::FilePath& target_exe) { 390 const base::FilePath& target_exe) {
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 ClearRlzProductState(); 1183 ClearRlzProductState();
1180 // Delete the key that delegate_execute might make. 1184 // Delete the key that delegate_execute might make.
1181 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 1185 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
1182 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, 1186 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER,
1183 chrome::kMetroRegistryPath); 1187 chrome::kMetroRegistryPath);
1184 } 1188 }
1185 1189
1186 auto_launch_util::DisableAllAutoStartFeatures( 1190 auto_launch_util::DisableAllAutoStartFeatures(
1187 ASCIIToUTF16(chrome::kInitialProfile)); 1191 ASCIIToUTF16(chrome::kInitialProfile));
1188 1192
1189 // Self-destruct flow: removing user-level Chrome because system-level 1193 // If user-level chrome is self-destructing as a result of encountering a
1190 // Chrome exists. 1194 // system-level chrome, retarget owned non-default shortcuts (app shortcuts,
1195 // profile shortcuts, etc.) to the system-level chrome.
1191 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && 1196 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) &&
1192 !installer_state.system_install()) { 1197 !installer_state.system_install()) {
1193 const base::FilePath system_chrome_path( 1198 const base::FilePath system_chrome_path(
1194 GetChromeInstallPath(true, browser_dist). 1199 GetChromeInstallPath(true, browser_dist).
1195 Append(installer::kChromeExe)); 1200 Append(installer::kChromeExe));
1196 VLOG(1) << "Retargeting user-generated Chrome shortcuts."; 1201 VLOG(1) << "Retargeting user-generated Chrome shortcuts.";
1197 if (base::PathExists(system_chrome_path)) { 1202 if (base::PathExists(system_chrome_path)) {
1198 // Retarget all user-generated shortcuts to user-level chrome.exe to 1203 RetargetUserShortcutsWithArgs(installer_state, product,
1199 // system-level chrome.exe. Heuristic: consider only shortcuts that have 1204 base::FilePath(chrome_exe),
1200 // non-empty args. Therefore the main user-level chrome.exe will not get 1205 system_chrome_path);
1201 // retarged, and will get deleted by DeleteShortcuts() below.
1202 RetargetShortcuts(installer_state, product, base::FilePath(chrome_exe),
1203 system_chrome_path, true);
1204 } else { 1206 } else {
1205 VLOG(1) << "Retarget failed: system-level Chrome not found."; 1207 VLOG(1) << "Retarget failed: system-level Chrome not found.";
gab 2013/09/13 14:31:25 s/VLOG(1)/LOG(ERROR)
huangs 2013/09/13 20:17:02 Done.
1206 } 1208 }
1207 } 1209 }
1208 1210
1209 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe)); 1211 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe));
1210 1212
1211 } else if (product.is_chrome_app_host()) { 1213 } else if (product.is_chrome_app_host()) {
1212 const base::FilePath app_host_exe( 1214 const base::FilePath app_host_exe(
1213 installer_state.target_path().Append(installer::kChromeAppHostExe)); 1215 installer_state.target_path().Append(installer::kChromeAppHostExe));
1214 DeleteShortcuts(installer_state, product, app_host_exe); 1216 DeleteShortcuts(installer_state, product, app_host_exe);
1215 } 1217 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 // deletion unconditionally. If they are not empty, the session manager 1499 // deletion unconditionally. If they are not empty, the session manager
1498 // will not delete them on reboot. 1500 // will not delete them on reboot.
1499 ScheduleParentAndGrandparentForDeletion(target_path); 1501 ScheduleParentAndGrandparentForDeletion(target_path);
1500 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == 1502 } else if (DeleteApplicationProductAndVendorDirectories(target_path) ==
1501 installer::DELETE_FAILED) { 1503 installer::DELETE_FAILED) {
1502 *uninstall_status = installer::UNINSTALL_FAILED; 1504 *uninstall_status = installer::UNINSTALL_FAILED;
1503 } 1505 }
1504 } 1506 }
1505 1507
1506 } // namespace installer 1508 } // namespace installer
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/util/shell_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698