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 #include <stddef.h> |
| 11 #include <stdint.h> |
10 | 12 |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
14 #include "base/files/file_enumerator.h" | 16 #include "base/files/file_enumerator.h" |
15 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/macros.h" |
16 #include "base/path_service.h" | 19 #include "base/path_service.h" |
17 #include "base/process/kill.h" | 20 #include "base/process/kill.h" |
18 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
22 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
23 #include "base/win/scoped_handle.h" | 26 #include "base/win/scoped_handle.h" |
24 #include "base/win/shortcut.h" | 27 #include "base/win/shortcut.h" |
25 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 << temp_file.value(); | 488 << temp_file.value(); |
486 if (!base::Move(setup_file, temp_file)) { | 489 if (!base::Move(setup_file, temp_file)) { |
487 PLOG(ERROR) << "Failed to move " << setup_file.BaseName().value() | 490 PLOG(ERROR) << "Failed to move " << setup_file.BaseName().value() |
488 << " to " << temp_file.value(); | 491 << " to " << temp_file.value(); |
489 return false; | 492 return false; |
490 } | 493 } |
491 | 494 |
492 // We cannot delete the file right away, but try to delete it some other | 495 // We cannot delete the file right away, but try to delete it some other |
493 // way. Either with the help of a different process or the system. | 496 // way. Either with the help of a different process or the system. |
494 if (!base::DeleteFileAfterReboot(temp_file)) { | 497 if (!base::DeleteFileAfterReboot(temp_file)) { |
495 const uint32 kDeleteAfterMs = 10 * 1000; | 498 const uint32_t kDeleteAfterMs = 10 * 1000; |
496 installer::DeleteFileFromTempProcess(temp_file, kDeleteAfterMs); | 499 installer::DeleteFileFromTempProcess(temp_file, kDeleteAfterMs); |
497 } | 500 } |
498 } | 501 } |
499 return true; | 502 return true; |
500 } | 503 } |
501 | 504 |
502 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, | 505 DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, |
503 const base::FilePath& setup_exe) { | 506 const base::FilePath& setup_exe) { |
504 const base::FilePath& target_path = installer_state.target_path(); | 507 const base::FilePath& target_path = installer_state.target_path(); |
505 if (target_path.empty()) { | 508 if (target_path.empty()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 564 |
562 return result; | 565 return result; |
563 } | 566 } |
564 | 567 |
565 // This method checks if Chrome is currently running or if the user has | 568 // This method checks if Chrome is currently running or if the user has |
566 // cancelled the uninstall operation by clicking Cancel on the confirmation | 569 // cancelled the uninstall operation by clicking Cancel on the confirmation |
567 // box that Chrome pops up. | 570 // box that Chrome pops up. |
568 InstallStatus IsChromeActiveOrUserCancelled( | 571 InstallStatus IsChromeActiveOrUserCancelled( |
569 const InstallerState& installer_state, | 572 const InstallerState& installer_state, |
570 const Product& product) { | 573 const Product& product) { |
571 int32 exit_code = content::RESULT_CODE_NORMAL_EXIT; | 574 int32_t exit_code = content::RESULT_CODE_NORMAL_EXIT; |
572 base::CommandLine options(base::CommandLine::NO_PROGRAM); | 575 base::CommandLine options(base::CommandLine::NO_PROGRAM); |
573 options.AppendSwitch(installer::switches::kUninstall); | 576 options.AppendSwitch(installer::switches::kUninstall); |
574 | 577 |
575 // Here we want to save user from frustration (in case of Chrome crashes) | 578 // Here we want to save user from frustration (in case of Chrome crashes) |
576 // and continue with the uninstallation as long as chrome.exe process exit | 579 // and continue with the uninstallation as long as chrome.exe process exit |
577 // code is NOT one of the following: | 580 // code is NOT one of the following: |
578 // - UNINSTALL_CHROME_ALIVE - chrome.exe is currently running | 581 // - UNINSTALL_CHROME_ALIVE - chrome.exe is currently running |
579 // - UNINSTALL_USER_CANCEL - User cancelled uninstallation | 582 // - UNINSTALL_USER_CANCEL - User cancelled uninstallation |
580 // - HUNG - chrome.exe was killed by HuntForZombieProcesses() (until we can | 583 // - HUNG - chrome.exe was killed by HuntForZombieProcesses() (until we can |
581 // give this method some brains and not kill chrome.exe launched | 584 // give this method some brains and not kill chrome.exe launched |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 // If we need a reboot to continue, schedule the parent directories for | 1440 // If we need a reboot to continue, schedule the parent directories for |
1438 // deletion unconditionally. If they are not empty, the session manager | 1441 // deletion unconditionally. If they are not empty, the session manager |
1439 // will not delete them on reboot. | 1442 // will not delete them on reboot. |
1440 ScheduleParentAndGrandparentForDeletion(target_path); | 1443 ScheduleParentAndGrandparentForDeletion(target_path); |
1441 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { | 1444 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { |
1442 *uninstall_status = UNINSTALL_FAILED; | 1445 *uninstall_status = UNINSTALL_FAILED; |
1443 } | 1446 } |
1444 } | 1447 } |
1445 | 1448 |
1446 } // namespace installer | 1449 } // namespace installer |
OLD | NEW |