Chromium Code Reviews| 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 // 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. This can only be called from user-level. |
|
gab
2013/09/11 20:34:23
s/from user-level/for user-level installs
huangs
2013/09/11 21:31:24
Done.
| |
| 333 // This should only be called from user-level. | 333 void RetargetUserShortcuts(const InstallerState& installer_state, |
| 334 void RetargetShortcuts(const InstallerState& installer_state, | 334 const Product& product, |
| 335 const Product& product, | 335 const base::FilePath& old_target_exe, |
| 336 const base::FilePath& old_target_exe, | 336 const base::FilePath& new_target_exe) { |
| 337 const base::FilePath& new_target_exe, | 337 if (installer_state.system_install()) { |
| 338 bool require_args) { | 338 NOTREACHED(); |
| 339 return; | |
| 340 } | |
| 341 DCHECK(!installer_state.system_install()); | |
|
gab
2013/09/11 20:34:23
Remove this line (same as above if).
huangs
2013/09/11 21:31:24
Oops. Done.
| |
| 339 BrowserDistribution* dist = product.distribution(); | 342 BrowserDistribution* dist = product.distribution(); |
| 340 DCHECK(!installer_state.system_install()); | |
| 341 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; | 343 ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; |
| 342 ShellUtil::ShortcutProperties updated_properties(install_level); | 344 ShellUtil::ShortcutProperties updated_properties(install_level); |
| 343 updated_properties.set_target(new_target_exe); | 345 updated_properties.set_target(new_target_exe); |
| 344 | 346 |
| 345 VLOG(1) << "Retargeting Desktop shortcuts."; | 347 VLOG(1) << "Retargeting Desktop shortcuts."; |
| 346 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, | 348 if (!ShellUtil::UpdateShortcutsWithArgs( |
|
gab
2013/09/11 20:34:23
Can we at least add a TODO to put these in a for l
huangs
2013/09/11 21:31:24
I'm thinking of https://chromiumcodereview.appspot
| |
| 347 install_level, old_target_exe, require_args, | 349 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, install_level, |
| 348 updated_properties)) { | 350 old_target_exe, updated_properties)) { |
| 349 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; | 351 LOG(WARNING) << "Failed to retarget Desktop shortcuts."; |
| 350 } | 352 } |
| 351 | 353 |
| 352 VLOG(1) << "Retargeting Quick Launch shortcuts."; | 354 VLOG(1) << "Retargeting Quick Launch shortcuts."; |
| 353 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, | 355 if (!ShellUtil::UpdateShortcutsWithArgs( |
| 354 dist, install_level, old_target_exe, | 356 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, install_level, |
| 355 require_args, updated_properties)) { | 357 old_target_exe, updated_properties)) { |
| 356 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; | 358 LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; |
| 357 } | 359 } |
| 358 | 360 |
| 359 VLOG(1) << "Retargeting Start Menu shortcuts."; | 361 VLOG(1) << "Retargeting Start Menu shortcuts."; |
| 360 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, | 362 if (!ShellUtil::UpdateShortcutsWithArgs( |
| 361 install_level, old_target_exe, require_args, | 363 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, install_level, |
| 362 updated_properties)) { | 364 old_target_exe, updated_properties)) { |
| 363 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; | 365 LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; |
| 364 } | 366 } |
| 365 | 367 |
| 366 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. | 368 // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. |
| 367 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, | 369 if (!ShellUtil::UpdateShortcutsWithArgs( |
| 368 dist, ShellUtil::CURRENT_USER, old_target_exe, | 370 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, dist, |
| 369 require_args, updated_properties)) { | 371 ShellUtil::CURRENT_USER, old_target_exe, updated_properties)) { |
| 370 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; | 372 LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; |
| 371 } | 373 } |
| 372 | 374 |
| 373 // Retarget the folder of secondary tiles from the start screen for |dist|. | 375 // Retarget the folder of secondary tiles from the start screen for |dist|. |
| 374 if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, | 376 if (!ShellUtil::UpdateShortcutsWithArgs( |
| 375 dist, install_level, old_target_exe, | 377 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, dist, install_level, |
| 376 require_args, updated_properties)) { | 378 old_target_exe, updated_properties)) { |
| 377 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; | 379 LOG(WARNING) << "Failed to retarget start-screen shortcuts."; |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 | 382 |
| 381 // Deletes shortcuts at |install_level| from Start menu, Desktop, | 383 // Deletes shortcuts at |install_level| from Start menu, Desktop, |
| 382 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). | 384 // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). |
| 383 // Only shortcuts pointing to |target_exe| will be removed. | 385 // Only shortcuts pointing to |target_exe| will be removed. |
| 384 void DeleteShortcuts(const InstallerState& installer_state, | 386 void DeleteShortcuts(const InstallerState& installer_state, |
| 385 const Product& product, | 387 const Product& product, |
| 386 const base::FilePath& target_exe) { | 388 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. | 1182 // Delete the key that delegate_execute might make. |
| 1181 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 1183 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 1182 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, | 1184 InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, |
| 1183 chrome::kMetroRegistryPath); | 1185 chrome::kMetroRegistryPath); |
| 1184 } | 1186 } |
| 1185 | 1187 |
| 1186 auto_launch_util::DisableAllAutoStartFeatures( | 1188 auto_launch_util::DisableAllAutoStartFeatures( |
| 1187 ASCIIToUTF16(chrome::kInitialProfile)); | 1189 ASCIIToUTF16(chrome::kInitialProfile)); |
| 1188 | 1190 |
| 1189 // Self-destruct flow: removing user-level Chrome because system-level | 1191 // Self-destruct flow: removing user-level Chrome because system-level |
| 1190 // Chrome exists. | 1192 // Chrome exists. |
|
gab
2013/09/11 20:34:23
Restructure this comment to only mention what is h
huangs
2013/09/11 21:31:24
Done.
| |
| 1191 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && | 1193 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && |
| 1192 !installer_state.system_install()) { | 1194 !installer_state.system_install()) { |
| 1193 const base::FilePath system_chrome_path( | 1195 const base::FilePath system_chrome_path( |
| 1194 GetChromeInstallPath(true, browser_dist). | 1196 GetChromeInstallPath(true, browser_dist). |
| 1195 Append(installer::kChromeExe)); | 1197 Append(installer::kChromeExe)); |
| 1196 VLOG(1) << "Retargeting user-generated Chrome shortcuts."; | 1198 VLOG(1) << "Retargeting user-generated Chrome shortcuts."; |
| 1197 if (base::PathExists(system_chrome_path)) { | 1199 if (base::PathExists(system_chrome_path)) { |
| 1198 // Retarget all user-generated shortcuts to user-level chrome.exe to | 1200 // Retarget all user-generated shortcuts to user-level chrome.exe to |
| 1199 // system-level chrome.exe. Heuristic: consider only shortcuts that have | 1201 // system-level chrome.exe. Heuristic: consider only shortcuts that have |
| 1200 // non-empty args. Therefore the main user-level chrome.exe will not get | 1202 // non-empty args. Therefore the main user-level chrome.exe will not get |
|
gab
2013/09/11 20:34:23
Such detail about the heuristic, etc. belong in th
huangs
2013/09/11 21:31:24
Done.
| |
| 1201 // retarged, and will get deleted by DeleteShortcuts() below. | 1203 // retarged, and will get deleted by DeleteShortcuts() below. |
| 1202 RetargetShortcuts(installer_state, product, base::FilePath(chrome_exe), | 1204 RetargetUserShortcuts(installer_state, product, |
| 1203 system_chrome_path, true); | 1205 base::FilePath(chrome_exe), system_chrome_path); |
| 1204 } else { | 1206 } else { |
| 1205 VLOG(1) << "Retarget failed: system-level Chrome not found."; | 1207 VLOG(1) << "Retarget failed: system-level Chrome not found."; |
| 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)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |