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 #include <windows.h> | 5 #include <windows.h> |
6 #include <msi.h> | 6 #include <msi.h> |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "base/win/registry.h" | 24 #include "base/win/registry.h" |
25 #include "base/win/scoped_com_initializer.h" | 25 #include "base/win/scoped_com_initializer.h" |
26 #include "base/win/scoped_comptr.h" | 26 #include "base/win/scoped_comptr.h" |
27 #include "base/win/scoped_handle.h" | 27 #include "base/win/scoped_handle.h" |
28 #include "base/win/win_util.h" | 28 #include "base/win/win_util.h" |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "breakpad/src/client/windows/handler/exception_handler.h" | 30 #include "breakpad/src/client/windows/handler/exception_handler.h" |
| 31 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/installer/setup/chrome_frame_quick_enable.h" | 33 #include "chrome/installer/setup/chrome_frame_quick_enable.h" |
33 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 34 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
34 #include "chrome/installer/setup/install.h" | 35 #include "chrome/installer/setup/install.h" |
35 #include "chrome/installer/setup/install_worker.h" | 36 #include "chrome/installer/setup/install_worker.h" |
36 #include "chrome/installer/setup/setup_constants.h" | 37 #include "chrome/installer/setup/setup_constants.h" |
37 #include "chrome/installer/setup/setup_util.h" | 38 #include "chrome/installer/setup/setup_util.h" |
38 #include "chrome/installer/setup/uninstall.h" | 39 #include "chrome/installer/setup/uninstall.h" |
39 #include "chrome/installer/util/browser_distribution.h" | 40 #include "chrome/installer/util/browser_distribution.h" |
40 #include "chrome/installer/util/channel_info.h" | 41 #include "chrome/installer/util/channel_info.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 original_state, installer_state, cmd_line.GetProgram(), product, | 998 original_state, installer_state, cmd_line.GetProgram(), product, |
998 remove_all, force_uninstall, cmd_line); | 999 remove_all, force_uninstall, cmd_line); |
999 } | 1000 } |
1000 | 1001 |
1001 installer::InstallStatus UninstallProducts( | 1002 installer::InstallStatus UninstallProducts( |
1002 const InstallationState& original_state, | 1003 const InstallationState& original_state, |
1003 const InstallerState& installer_state, | 1004 const InstallerState& installer_state, |
1004 const CommandLine& cmd_line) { | 1005 const CommandLine& cmd_line) { |
1005 const Products& products = installer_state.products(); | 1006 const Products& products = installer_state.products(); |
1006 | 1007 |
1007 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) { | 1008 // Decide whether Active Setup should be triggered and/or system-level Chrome |
| 1009 // should be launched post-uninstall. This needs to be done outside the |
| 1010 // UninstallProduct calls as some of them might terminate the processes |
| 1011 // launched by a previous one otherwise... |
| 1012 bool trigger_active_setup = false; |
| 1013 // System-level Chrome will be launched via this command if its program gets |
| 1014 // set below. |
| 1015 CommandLine system_level_cmd(CommandLine::NO_PROGRAM); |
| 1016 |
| 1017 const Product* chrome = |
| 1018 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 1019 if (chrome) { |
1008 // InstallerState::Initialize always puts Chrome first, and we rely on that | 1020 // InstallerState::Initialize always puts Chrome first, and we rely on that |
1009 // here for this reason: if Chrome is in-use, the user will be prompted to | 1021 // here for this reason: if Chrome is in-use, the user will be prompted to |
1010 // confirm uninstallation. Upon cancel, we should not continue with the | 1022 // confirm uninstallation. Upon cancel, we should not continue with the |
1011 // other products. | 1023 // other products. |
1012 DCHECK(products[0]->is_chrome()); | 1024 DCHECK(products[0]->is_chrome()); |
| 1025 |
| 1026 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && |
| 1027 !installer_state.system_install()) { |
| 1028 BrowserDistribution* dist = chrome->distribution(); |
| 1029 const FilePath system_exe_path( |
| 1030 installer::GetChromeInstallPath(true, dist) |
| 1031 .Append(installer::kChromeExe)); |
| 1032 system_level_cmd.SetProgram(system_exe_path); |
| 1033 |
| 1034 FilePath first_run_sentinel; |
| 1035 InstallUtil::GetSentinelFilePath( |
| 1036 chrome::kFirstRunSentinel, dist, &first_run_sentinel); |
| 1037 if (file_util::PathExists(first_run_sentinel)) { |
| 1038 // If the Chrome being self-destructed has already undergone First Run, |
| 1039 // trigger Active Setup and make sure the system-level Chrome doesn't go |
| 1040 // through first run. |
| 1041 trigger_active_setup = true; |
| 1042 system_level_cmd.AppendSwitch(::switches::kNoFirstRun); |
| 1043 } |
| 1044 } |
1013 } | 1045 } |
1014 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 1046 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
1015 // Chrome Binaries should be last; if something else is cancelled, they | 1047 // Chrome Binaries should be last; if something else is cancelled, they |
1016 // should stay. | 1048 // should stay. |
1017 DCHECK(products[products.size() - 1]->is_chrome_binaries()); | 1049 DCHECK(products[products.size() - 1]->is_chrome_binaries()); |
1018 } | 1050 } |
1019 | 1051 |
1020 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; | 1052 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; |
1021 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; | 1053 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; |
1022 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); | 1054 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); |
1023 const bool remove_all = !cmd_line.HasSwitch( | 1055 const bool remove_all = !cmd_line.HasSwitch( |
1024 installer::switches::kDoNotRemoveSharedItems); | 1056 installer::switches::kDoNotRemoveSharedItems); |
1025 | 1057 |
1026 for (Products::const_iterator it = products.begin(); | 1058 for (Products::const_iterator it = products.begin(); |
1027 install_status != installer::UNINSTALL_CANCELLED && it < products.end(); | 1059 install_status != installer::UNINSTALL_CANCELLED && it < products.end(); |
1028 ++it) { | 1060 ++it) { |
1029 prod_status = UninstallProduct(original_state, installer_state, | 1061 prod_status = UninstallProduct(original_state, installer_state, |
1030 cmd_line, remove_all, force, **it); | 1062 cmd_line, remove_all, force, **it); |
1031 if (prod_status != installer::UNINSTALL_SUCCESSFUL) | 1063 if (prod_status != installer::UNINSTALL_SUCCESSFUL) |
1032 install_status = prod_status; | 1064 install_status = prod_status; |
1033 } | 1065 } |
1034 | 1066 |
1035 installer::CleanUpInstallationDirectoryAfterUninstall( | 1067 installer::CleanUpInstallationDirectoryAfterUninstall( |
1036 original_state, installer_state, cmd_line, &install_status); | 1068 original_state, installer_state, cmd_line, &install_status); |
1037 | 1069 |
| 1070 if (trigger_active_setup) |
| 1071 InstallUtil::TriggerActiveSetupCommand(); |
| 1072 |
| 1073 if (!system_level_cmd.GetProgram().empty()) |
| 1074 base::LaunchProcess(system_level_cmd, base::LaunchOptions(), NULL); |
| 1075 |
1038 // Tell Google Update that an uninstall has taken place. | 1076 // Tell Google Update that an uninstall has taken place. |
1039 // Ignore the return value: success or failure of Google Update | 1077 // Ignore the return value: success or failure of Google Update |
1040 // has no bearing on the success or failure of Chrome's uninstallation. | 1078 // has no bearing on the success or failure of Chrome's uninstallation. |
1041 google_update::UninstallGoogleUpdate(installer_state.system_install()); | 1079 google_update::UninstallGoogleUpdate(installer_state.system_install()); |
1042 | 1080 |
1043 return install_status; | 1081 return install_status; |
1044 } | 1082 } |
1045 | 1083 |
1046 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { | 1084 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { |
1047 VLOG(1) << "About to show EULA"; | 1085 VLOG(1) << "About to show EULA"; |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 if (!(installer_state.is_msi() && is_uninstall)) | 1705 if (!(installer_state.is_msi() && is_uninstall)) |
1668 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1706 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1669 // to pass through, since this is only returned on uninstall which is | 1707 // to pass through, since this is only returned on uninstall which is |
1670 // never invoked directly by Google Update. | 1708 // never invoked directly by Google Update. |
1671 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1709 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1672 | 1710 |
1673 VLOG(1) << "Installation complete, returning: " << return_code; | 1711 VLOG(1) << "Installation complete, returning: " << return_code; |
1674 | 1712 |
1675 return return_code; | 1713 return return_code; |
1676 } | 1714 } |
OLD | NEW |