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

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

Issue 22382007: On user-level Chrome self-destruct, make user-created shortcuts target system-level chrome.exe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. 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') | chrome/installer/util/shell_util.cc » ('J')
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
332 // |require_args| is set, then only updates shortcuts with non-empty targets.
gab 2013/09/09 13:00:31 s/non-empty targets/non-empty arguments ?
huangs 2013/09/11 19:02:52 Ah, good catch. Done.
333 // This should only be called from user-level.
334 void RetargetShortcuts(const InstallerState& installer_state,
335 const Product& product,
336 const base::FilePath& old_target_exe,
337 const base::FilePath& new_target_exe,
338 bool require_args) {
339 BrowserDistribution* dist = product.distribution();
340 DCHECK(!installer_state.system_install());
gab 2013/09/09 13:00:31 Move DCHECK to top: checking the method's contract
huangs 2013/09/11 19:02:52 Done (should get rid of "!").
341 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER;
342 ShellUtil::ShortcutProperties updated_properties(install_level);
343 updated_properties.set_target(new_target_exe);
344
345 VLOG(1) << "Retargeting Desktop shortcuts.";
346 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
gab 2013/09/09 13:00:31 Please put these in a for loop through all locatio
huangs 2013/09/11 19:02:52 DeleteShortcuts() message string also distinguish
gab 2013/09/11 20:23:06 Ah ok, sgtm :)!
347 install_level, old_target_exe, require_args,
348 updated_properties)) {
349 LOG(WARNING) << "Failed to retarget Desktop shortcuts.";
350 }
351
352 VLOG(1) << "Retargeting Quick Launch shortcuts.";
353 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
354 dist, install_level, old_target_exe,
355 require_args, updated_properties)) {
356 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts.";
357 }
358
359 VLOG(1) << "Retargeting Start Menu shortcuts.";
360 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist,
361 install_level, old_target_exe, require_args,
362 updated_properties)) {
363 LOG(WARNING) << "Failed to retarget Start Menu shortcuts.";
364 }
365
366 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|.
367 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
368 dist, ShellUtil::CURRENT_USER, old_target_exe,
369 require_args, updated_properties)) {
370 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level.";
371 }
372
373 // Retarget the folder of secondary tiles from the start screen for |dist|.
374 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS,
375 dist, install_level, old_target_exe,
376 require_args, updated_properties)) {
377 LOG(WARNING) << "Failed to retarget start-screen shortcuts.";
378 }
379 }
380
331 // Deletes shortcuts at |install_level| from Start menu, Desktop, 381 // Deletes shortcuts at |install_level| from Start menu, Desktop,
332 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). 382 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+).
333 // Only shortcuts pointing to |target_exe| will be removed. 383 // Only shortcuts pointing to |target_exe| will be removed.
334 void DeleteShortcuts(const InstallerState& installer_state, 384 void DeleteShortcuts(const InstallerState& installer_state,
335 const Product& product, 385 const Product& product,
336 const base::FilePath& target_exe) { 386 const base::FilePath& target_exe) {
337 BrowserDistribution* dist = product.distribution(); 387 BrowserDistribution* dist = product.distribution();
338 388
339 // The per-user shortcut for this user, if present on a system-level install, 389 // The per-user shortcut for this user, if present on a system-level install,
340 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks(). 390 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks().
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 ClearRlzProductState(); 1179 ClearRlzProductState();
1130 // Delete the key that delegate_execute might make. 1180 // Delete the key that delegate_execute might make.
1131 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 1181 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
1132 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, 1182 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER,
1133 chrome::kMetroRegistryPath); 1183 chrome::kMetroRegistryPath);
1134 } 1184 }
1135 1185
1136 auto_launch_util::DisableAllAutoStartFeatures( 1186 auto_launch_util::DisableAllAutoStartFeatures(
1137 ASCIIToUTF16(chrome::kInitialProfile)); 1187 ASCIIToUTF16(chrome::kInitialProfile));
1138 1188
1189 // Self-destruct flow: removing user-level Chrome because system-level
1190 // Chrome exists.
1191 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) &&
1192 !installer_state.system_install()) {
1193 const base::FilePath system_chrome_path(
1194 GetChromeInstallPath(true, browser_dist).
1195 Append(installer::kChromeExe));
1196 VLOG(1) << "Retargeting user-generated Chrome shortcuts.";
1197 if (base::PathExists(system_chrome_path)) {
1198 // Retarget all user-generated shortcuts to user-level chrome.exe to
1199 // system-level chrome.exe. Heuristic: consider only shortcuts that have
1200 // non-empty args. Therefore the main user-level chrome.exe will not get
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 {
1205 VLOG(1) << "Retarget failed: system-level Chrome not found.";
1206 }
1207 }
1208
1139 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe)); 1209 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe));
1140 1210
1141 } else if (product.is_chrome_app_host()) { 1211 } else if (product.is_chrome_app_host()) {
1142 const base::FilePath app_host_exe( 1212 const base::FilePath app_host_exe(
1143 installer_state.target_path().Append(installer::kChromeAppHostExe)); 1213 installer_state.target_path().Append(installer::kChromeAppHostExe));
1144 DeleteShortcuts(installer_state, product, app_host_exe); 1214 DeleteShortcuts(installer_state, product, app_host_exe);
1145 } 1215 }
1146 1216
1147 // Delete the registry keys (Uninstall key and Version key). 1217 // Delete the registry keys (Uninstall key and Version key).
1148 HKEY reg_root = installer_state.root_key(); 1218 HKEY reg_root = installer_state.root_key();
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 // deletion unconditionally. If they are not empty, the session manager 1497 // deletion unconditionally. If they are not empty, the session manager
1428 // will not delete them on reboot. 1498 // will not delete them on reboot.
1429 ScheduleParentAndGrandparentForDeletion(target_path); 1499 ScheduleParentAndGrandparentForDeletion(target_path);
1430 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == 1500 } else if (DeleteApplicationProductAndVendorDirectories(target_path) ==
1431 installer::DELETE_FAILED) { 1501 installer::DELETE_FAILED) {
1432 *uninstall_status = installer::UNINSTALL_FAILED; 1502 *uninstall_status = installer::UNINSTALL_FAILED;
1433 } 1503 }
1434 } 1504 }
1435 1505
1436 } // namespace installer 1506 } // namespace installer
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/util/shell_util.h » ('j') | chrome/installer/util/shell_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698