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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
gab
2013/09/13 01:53:26
nit: Remove this extra empty line.
huangs
2013/09/13 04:16:26
Done.
| |
332 // |require_args| is set, then only updates shortcuts with non-empty targets. | 332 // Updates shortcuts to |old_target_exe| that have non-empty args, making them |
333 // This should only be called from user-level. | 333 // target |new_target_exe| instead. The non-empty args requirement is a |
334 void RetargetShortcuts(const InstallerState& installer_state, | 334 // heuristic to determine whether a shortcut is "user-generated". This routine |
335 const Product& product, | 335 // can only be called for user-level installs. |
336 const base::FilePath& old_target_exe, | 336 void RetargetUserShortcuts(const InstallerState& installer_state, |
gab
2013/09/13 01:53:26
WDYT of calling this method RetargetUserShortcutsW
huangs
2013/09/13 04:16:26
I was sneaky and used the word "User" to refer to
| |
337 const base::FilePath& new_target_exe, | 337 const Product& product, |
338 bool require_args) { | 338 const base::FilePath& old_target_exe, |
339 const base::FilePath& new_target_exe) { | |
340 if (installer_state.system_install()) { | |
341 NOTREACHED(); | |
342 return; | |
343 } | |
339 BrowserDistribution* dist = product.distribution(); | 344 BrowserDistribution* dist = product.distribution(); |
340 DCHECK(!installer_state.system_install()); | |
341 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; | 345 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; |
342 ShellUtil::ShortcutProperties updated_properties(install_level); | 346 ShellUtil::ShortcutProperties updated_properties(install_level); |
343 updated_properties.set_target(new_target_exe); | 347 updated_properties.set_target(new_target_exe); |
344 | 348 |
349 // TODO(huangs): Make this data-driven, along with DeleteShortcuts(). | |
345 VLOG(1) << "Retargeting Desktop shortcuts."; | 350 VLOG(1) << "Retargeting Desktop shortcuts."; |
346 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, | 351 if (!ShellUtil::UpdateShortcutsWithArgs( |
347 install_level, old_target_exe, require_args, | 352 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, install_level, |
348 updated_properties)) { | 353 old_target_exe, updated_properties)) { |
349 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; | 354 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; |
350 } | 355 } |
351 | 356 |
352 VLOG(1) << "Retargeting Quick Launch shortcuts."; | 357 VLOG(1) << "Retargeting Quick Launch shortcuts."; |
353 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, | 358 if (!ShellUtil::UpdateShortcutsWithArgs( |
354 dist, install_level, old_target_exe, | 359 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, install_level, |
355 require_args, updated_properties)) { | 360 old_target_exe, updated_properties)) { |
356 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; | 361 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; |
357 } | 362 } |
358 | 363 |
359 VLOG(1) << "Retargeting Start Menu shortcuts."; | 364 VLOG(1) << "Retargeting Start Menu shortcuts."; |
360 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, | 365 if (!ShellUtil::UpdateShortcutsWithArgs( |
361 install_level, old_target_exe, require_args, | 366 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, install_level, |
362 updated_properties)) { | 367 old_target_exe, updated_properties)) { |
363 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; | 368 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; |
364 } | 369 } |
365 | 370 |
366 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. | 371 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. |
367 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, | 372 if (!ShellUtil::UpdateShortcutsWithArgs( |
368 dist, ShellUtil::CURRENT_USER, old_target_exe, | 373 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, dist, |
369 require_args, updated_properties)) { | 374 ShellUtil::CURRENT_USER, old_target_exe, updated_properties)) { |
370 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; | 375 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; |
371 } | 376 } |
372 | 377 |
373 // Retarget the folder of secondary tiles from the start screen for |dist|. | 378 // Retarget the folder of secondary tiles from the start screen for |dist|. |
374 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, | 379 if (!ShellUtil::UpdateShortcutsWithArgs( |
375 dist, install_level, old_target_exe, | 380 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, dist, install_level, |
376 require_args, updated_properties)) { | 381 old_target_exe, updated_properties)) { |
377 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; | 382 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; |
378 } | 383 } |
379 } | 384 } |
380 | 385 |
381 // Deletes shortcuts at |install_level| from Start menu, Desktop, | 386 // Deletes shortcuts at |install_level| from Start menu, Desktop, |
382 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). | 387 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). |
383 // Only shortcuts pointing to |target_exe| will be removed. | 388 // Only shortcuts pointing to |target_exe| will be removed. |
384 void DeleteShortcuts(const InstallerState& installer_state, | 389 void DeleteShortcuts(const InstallerState& installer_state, |
385 const Product& product, | 390 const Product& product, |
386 const base::FilePath& target_exe) { | 391 const base::FilePath& target_exe) { |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 // Delete the key that delegate_execute might make. | 1185 // Delete the key that delegate_execute might make. |
1181 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 1186 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
1182 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 1187 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
1183 chrome::kMetroRegistryPath); | 1188 chrome::kMetroRegistryPath); |
1184 } | 1189 } |
1185 | 1190 |
1186 auto_launch_util::DisableAllAutoStartFeatures( | 1191 auto_launch_util::DisableAllAutoStartFeatures( |
1187 ASCIIToUTF16(chrome::kInitialProfile)); | 1192 ASCIIToUTF16(chrome::kInitialProfile)); |
1188 | 1193 |
1189 // Self-destruct flow: removing user-level Chrome because system-level | 1194 // Self-destruct flow: removing user-level Chrome because system-level |
1190 // Chrome exists. | 1195 // Chrome exists. Also, make user-generated shortcuts retarget system-level |
1196 // Chrome. | |
gab
2013/09/13 01:53:26
I still think the first part of this comment is ov
huangs
2013/09/13 04:16:26
Done. I take that your use of "chrome" (generic go
gab
2013/09/13 14:31:24
Yes it is intentional, except that it's chrome (th
| |
1191 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && | 1197 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && |
1192 !installer_state.system_install()) { | 1198 !installer_state.system_install()) { |
1193 const base::FilePath system_chrome_path( | 1199 const base::FilePath system_chrome_path( |
1194 GetChromeInstallPath(true, browser_dist). | 1200 GetChromeInstallPath(true, browser_dist). |
1195 Append(installer::kChromeExe)); | 1201 Append(installer::kChromeExe)); |
1196 VLOG(1) << "Retargeting user-generated Chrome shortcuts."; | 1202 VLOG(1) << "Retargeting user-generated Chrome shortcuts."; |
1197 if (base::PathExists(system_chrome_path)) { | 1203 if (base::PathExists(system_chrome_path)) { |
1198 // Retarget all user-generated shortcuts to user-level chrome.exe to | 1204 // Update all user-generated user-level chrome.exe shortcuts, so they |
1199 // system-level chrome.exe. Heuristic: consider only shortcuts that have | 1205 // retarget system-level chrome.exe. In particular, this excludes the |
1200 // non-empty args. Therefore the main user-level chrome.exe will not get | 1206 // main shortcuts to user-level chrome.exe, so it get deleted below. |
gab
2013/09/13 01:53:26
I'd say the suggested comment above is sufficient
huangs
2013/09/13 04:16:26
Removed comment.
| |
1201 // retarged, and will get deleted by DeleteShortcuts() below. | 1207 RetargetUserShortcuts(installer_state, product, |
1202 RetargetShortcuts(installer_state, product, base::FilePath(chrome_exe), | 1208 base::FilePath(chrome_exe), system_chrome_path); |
1203 system_chrome_path, true); | |
1204 } else { | 1209 } else { |
1205 VLOG(1) << "Retarget failed: system-level Chrome not found."; | 1210 VLOG(1) << "Retarget failed: system-level Chrome not found."; |
1206 } | 1211 } |
1207 } | 1212 } |
1208 | 1213 |
1209 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe)); | 1214 DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe)); |
1210 | 1215 |
1211 } else if (product.is_chrome_app_host()) { | 1216 } else if (product.is_chrome_app_host()) { |
1212 const base::FilePath app_host_exe( | 1217 const base::FilePath app_host_exe( |
1213 installer_state.target_path().Append(installer::kChromeAppHostExe)); | 1218 installer_state.target_path().Append(installer::kChromeAppHostExe)); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1497 // deletion unconditionally. If they are not empty, the session manager | 1502 // deletion unconditionally. If they are not empty, the session manager |
1498 // will not delete them on reboot. | 1503 // will not delete them on reboot. |
1499 ScheduleParentAndGrandparentForDeletion(target_path); | 1504 ScheduleParentAndGrandparentForDeletion(target_path); |
1500 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == | 1505 } else if (DeleteApplicationProductAndVendorDirectories(target_path) == |
1501 installer::DELETE_FAILED) { | 1506 installer::DELETE_FAILED) { |
1502 *uninstall_status = installer::UNINSTALL_FAILED; | 1507 *uninstall_status = installer::UNINSTALL_FAILED; |
1503 } | 1508 } |
1504 } | 1509 } |
1505 | 1510 |
1506 } // namespace installer | 1511 } // namespace installer |
OLD | NEW |