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" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "base/memory/scoped_ptr.h" | |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/process_util.h" | 18 #include "base/process_util.h" |
18 #include "base/string16.h" | 19 #include "base/string16.h" |
19 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 21 #include "base/string_util.h" |
21 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
22 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
24 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
25 #include "base/win/scoped_com_initializer.h" | 26 #include "base/win/scoped_com_initializer.h" |
26 #include "base/win/scoped_comptr.h" | 27 #include "base/win/scoped_comptr.h" |
27 #include "base/win/scoped_handle.h" | 28 #include "base/win/scoped_handle.h" |
28 #include "base/win/win_util.h" | 29 #include "base/win/win_util.h" |
29 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
30 #include "breakpad/src/client/windows/handler/exception_handler.h" | 31 #include "breakpad/src/client/windows/handler/exception_handler.h" |
32 #include "chrome/common/chrome_constants.h" | |
31 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/installer/setup/chrome_frame_quick_enable.h" | 34 #include "chrome/installer/setup/chrome_frame_quick_enable.h" |
33 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 35 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
34 #include "chrome/installer/setup/install.h" | 36 #include "chrome/installer/setup/install.h" |
35 #include "chrome/installer/setup/install_worker.h" | 37 #include "chrome/installer/setup/install_worker.h" |
36 #include "chrome/installer/setup/setup_constants.h" | 38 #include "chrome/installer/setup/setup_constants.h" |
37 #include "chrome/installer/setup/setup_util.h" | 39 #include "chrome/installer/setup/setup_util.h" |
38 #include "chrome/installer/setup/uninstall.h" | 40 #include "chrome/installer/setup/uninstall.h" |
39 #include "chrome/installer/util/browser_distribution.h" | 41 #include "chrome/installer/util/browser_distribution.h" |
40 #include "chrome/installer/util/channel_info.h" | 42 #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, | 999 original_state, installer_state, cmd_line.GetProgram(), product, |
998 remove_all, force_uninstall, cmd_line); | 1000 remove_all, force_uninstall, cmd_line); |
999 } | 1001 } |
1000 | 1002 |
1001 installer::InstallStatus UninstallProducts( | 1003 installer::InstallStatus UninstallProducts( |
1002 const InstallationState& original_state, | 1004 const InstallationState& original_state, |
1003 const InstallerState& installer_state, | 1005 const InstallerState& installer_state, |
1004 const CommandLine& cmd_line) { | 1006 const CommandLine& cmd_line) { |
1005 const Products& products = installer_state.products(); | 1007 const Products& products = installer_state.products(); |
1006 | 1008 |
1009 // Decide whether Active Setup should be triggered and/or system-level Chrome | |
1010 // should be launched post-uninstall. This needs to be done outside the | |
1011 // UninstallProduct calls as some of them might terminate the processes | |
1012 // launched by a previous one otherwise... | |
1013 bool trigger_active_setup = false; | |
1014 // System-level Chrome will be launched via this command if it gets set below. | |
1015 scoped_ptr<CommandLine> system_level_cmd; | |
grt (UTC plus 2)
2013/01/02 17:59:33
It seems more straightforward to use:
CommandLin
gab
2013/01/02 21:15:48
Done.
| |
1016 | |
1007 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) { | 1017 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) { |
1008 // InstallerState::Initialize always puts Chrome first, and we rely on that | 1018 // 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 | 1019 // 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 | 1020 // confirm uninstallation. Upon cancel, we should not continue with the |
1011 // other products. | 1021 // other products. |
1012 DCHECK(products[0]->is_chrome()); | 1022 DCHECK(products[0]->is_chrome()); |
1023 | |
1024 if (cmd_line.HasSwitch(installer::switches::kSelfDestruct)) { | |
grt (UTC plus 2)
2013/01/02 17:59:33
&& !system_level() since this shouldn't be done if
gab
2013/01/02 21:15:48
Sure.
| |
1025 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | |
1026 BrowserDistribution::CHROME_BROWSER); | |
1027 const FilePath system_exe_path( | |
1028 installer::GetChromeInstallPath(true, dist) | |
1029 .Append(installer::kChromeExe)); | |
1030 system_level_cmd.reset(new CommandLine(system_exe_path)); | |
1031 | |
1032 FilePath first_run_sentinel; | |
1033 InstallUtil::GetSentinelFilePath( | |
1034 chrome::kFirstRunSentinel, false, products[0]->distribution(), | |
grt (UTC plus 2)
2013/01/02 17:59:33
isn't products[0]->distribution() the same as |dis
gab
2013/01/02 21:15:48
Indeed :)!
| |
1035 &first_run_sentinel); | |
1036 if (file_util::PathExists(first_run_sentinel)) { | |
1037 // If the Chrome being self-destructed has already undergone First Run, | |
1038 // trigger Active Setup and make sure the system-level Chrome doesn't go | |
1039 // through first run. | |
grt (UTC plus 2)
2013/01/02 17:59:33
is there a difference between using --no-first-run
gab
2013/01/02 21:15:48
Hmmm, well arguably dropping the beacon here could
| |
1040 trigger_active_setup = true; | |
1041 system_level_cmd->AppendSwitch(::switches::kNoFirstRun); | |
grt (UTC plus 2)
2013/01/02 17:59:33
nit: remove the :: in front of "switches" unless i
gab
2013/01/02 21:15:48
It is necessary since installer::switches also exi
| |
1042 } | |
1043 } | |
1013 } | 1044 } |
1014 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 1045 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
1015 // Chrome Binaries should be last; if something else is cancelled, they | 1046 // Chrome Binaries should be last; if something else is cancelled, they |
1016 // should stay. | 1047 // should stay. |
1017 DCHECK(products[products.size() - 1]->is_chrome_binaries()); | 1048 DCHECK(products[products.size() - 1]->is_chrome_binaries()); |
1018 } | 1049 } |
1019 | 1050 |
1020 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; | 1051 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; |
1021 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; | 1052 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; |
1022 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); | 1053 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); |
1023 const bool remove_all = !cmd_line.HasSwitch( | 1054 const bool remove_all = !cmd_line.HasSwitch( |
1024 installer::switches::kDoNotRemoveSharedItems); | 1055 installer::switches::kDoNotRemoveSharedItems); |
1025 | 1056 |
1026 for (Products::const_iterator it = products.begin(); | 1057 for (Products::const_iterator it = products.begin(); |
1027 install_status != installer::UNINSTALL_CANCELLED && it < products.end(); | 1058 install_status != installer::UNINSTALL_CANCELLED && it < products.end(); |
1028 ++it) { | 1059 ++it) { |
1029 prod_status = UninstallProduct(original_state, installer_state, | 1060 prod_status = UninstallProduct(original_state, installer_state, |
1030 cmd_line, remove_all, force, **it); | 1061 cmd_line, remove_all, force, **it); |
1031 if (prod_status != installer::UNINSTALL_SUCCESSFUL) | 1062 if (prod_status != installer::UNINSTALL_SUCCESSFUL) |
1032 install_status = prod_status; | 1063 install_status = prod_status; |
1033 } | 1064 } |
1034 | 1065 |
1035 installer::CleanUpInstallationDirectoryAfterUninstall( | 1066 installer::CleanUpInstallationDirectoryAfterUninstall( |
1036 original_state, installer_state, cmd_line, &install_status); | 1067 original_state, installer_state, cmd_line, &install_status); |
1037 | 1068 |
1069 if (install_status != installer::UNINSTALL_CANCELLED) { | |
1070 if (trigger_active_setup) | |
grt (UTC plus 2)
2013/01/02 17:59:33
install_status may be any of: (CHROME_NOT_INSTALLE
gab
2013/01/02 21:15:48
In fact I think it was wrong to base this off of "
| |
1071 InstallUtil::TriggerActiveSetupCommand(); | |
1072 | |
1073 if (system_level_cmd.get()) | |
1074 base::LaunchProcess(*system_level_cmd, base::LaunchOptions(), NULL); | |
1075 } | |
1076 | |
1038 // Tell Google Update that an uninstall has taken place. | 1077 // Tell Google Update that an uninstall has taken place. |
1039 // Ignore the return value: success or failure of Google Update | 1078 // Ignore the return value: success or failure of Google Update |
1040 // has no bearing on the success or failure of Chrome's uninstallation. | 1079 // has no bearing on the success or failure of Chrome's uninstallation. |
1041 google_update::UninstallGoogleUpdate(installer_state.system_install()); | 1080 google_update::UninstallGoogleUpdate(installer_state.system_install()); |
1042 | 1081 |
1043 return install_status; | 1082 return install_status; |
1044 } | 1083 } |
1045 | 1084 |
1046 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { | 1085 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { |
1047 VLOG(1) << "About to show EULA"; | 1086 VLOG(1) << "About to show EULA"; |
(...skipping 13 matching lines...) Expand all Loading... | |
1061 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { | 1100 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { |
1062 VLOG(1) << "EULA accepted (opt-in)"; | 1101 VLOG(1) << "EULA accepted (opt-in)"; |
1063 return installer::EULA_ACCEPTED_OPT_IN; | 1102 return installer::EULA_ACCEPTED_OPT_IN; |
1064 } | 1103 } |
1065 VLOG(1) << "EULA accepted (no opt-in)"; | 1104 VLOG(1) << "EULA accepted (no opt-in)"; |
1066 return installer::EULA_ACCEPTED; | 1105 return installer::EULA_ACCEPTED; |
1067 } | 1106 } |
1068 | 1107 |
1069 // Creates the sentinel indicating that the EULA was required and has been | 1108 // Creates the sentinel indicating that the EULA was required and has been |
1070 // accepted. | 1109 // accepted. |
1071 bool CreateEULASentinel(BrowserDistribution* dist) { | 1110 bool CreateEULASentinel(bool system_install, |
grt (UTC plus 2)
2013/01/02 17:59:33
The EULA only applies for system-level installs, s
gab
2013/01/02 21:15:48
Done.
| |
1111 BrowserDistribution* dist) { | |
1072 FilePath eula_sentinel; | 1112 FilePath eula_sentinel; |
1073 if (!InstallUtil::GetSentinelFilePath(installer::kEULASentinelFile, | 1113 if (!InstallUtil::GetSentinelFilePath( |
1074 dist, &eula_sentinel)) { | 1114 installer::kEULASentinelFile, system_install, dist, &eula_sentinel)) { |
1075 return false; | 1115 return false; |
1076 } | 1116 } |
1077 | 1117 |
1078 return (file_util::CreateDirectory(eula_sentinel.DirName()) && | 1118 return (file_util::CreateDirectory(eula_sentinel.DirName()) && |
1079 file_util::WriteFile(eula_sentinel, "", 0) != -1); | 1119 file_util::WriteFile(eula_sentinel, "", 0) != -1); |
1080 } | 1120 } |
1081 | 1121 |
1082 void ActivateMetroChrome() { | 1122 void ActivateMetroChrome() { |
1083 // Check to see if we're per-user or not. Need to do this since we may | 1123 // Check to see if we're per-user or not. Need to do this since we may |
1084 // not have been invoked with --system-level even for a machine install. | 1124 // not have been invoked with --system-level even for a machine install. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { | 1274 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { |
1235 // Check if we need to show the EULA. If it is passed as a command line | 1275 // Check if we need to show the EULA. If it is passed as a command line |
1236 // then the dialog is shown and regardless of the outcome setup exits here. | 1276 // then the dialog is shown and regardless of the outcome setup exits here. |
1237 string16 inner_frame = | 1277 string16 inner_frame = |
1238 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 1278 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
1239 *exit_code = ShowEULADialog(inner_frame); | 1279 *exit_code = ShowEULADialog(inner_frame); |
1240 | 1280 |
1241 if (installer::EULA_REJECTED != *exit_code) { | 1281 if (installer::EULA_REJECTED != *exit_code) { |
1242 if (GoogleUpdateSettings::SetEULAConsent( | 1282 if (GoogleUpdateSettings::SetEULAConsent( |
1243 original_state, BrowserDistribution::GetDistribution(), true)) { | 1283 original_state, BrowserDistribution::GetDistribution(), true)) { |
1244 CreateEULASentinel(BrowserDistribution::GetDistribution()); | 1284 CreateEULASentinel(installer_state->system_install(), |
grt (UTC plus 2)
2013/01/02 17:59:33
FYI: --system-level isn't passed to setup.exe in t
gab
2013/01/02 21:15:48
Done.
| |
1285 BrowserDistribution::GetDistribution()); | |
1245 } | 1286 } |
1246 // For a metro-originated launch, we now need to launch back into metro. | 1287 // For a metro-originated launch, we now need to launch back into metro. |
1247 if (cmd_line.HasSwitch(installer::switches::kShowEulaForMetro)) | 1288 if (cmd_line.HasSwitch(installer::switches::kShowEulaForMetro)) |
1248 ActivateMetroChrome(); | 1289 ActivateMetroChrome(); |
1249 } | 1290 } |
1250 } else if (cmd_line.HasSwitch(installer::switches::kConfigureUserSettings)) { | 1291 } else if (cmd_line.HasSwitch(installer::switches::kConfigureUserSettings)) { |
1251 // NOTE: Should the work done here, on kConfigureUserSettings, change: | 1292 // NOTE: Should the work done here, on kConfigureUserSettings, change: |
1252 // kActiveSetupVersion in install_worker.cc needs to be increased for Active | 1293 // kActiveSetupVersion in install_worker.cc needs to be increased for Active |
1253 // Setup to invoke this again for all users of this install. | 1294 // Setup to invoke this again for all users of this install. |
1254 const Product* chrome_install = | 1295 const Product* chrome_install = |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1667 if (!(installer_state.is_msi() && is_uninstall)) | 1708 if (!(installer_state.is_msi() && is_uninstall)) |
1668 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1709 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1669 // to pass through, since this is only returned on uninstall which is | 1710 // to pass through, since this is only returned on uninstall which is |
1670 // never invoked directly by Google Update. | 1711 // never invoked directly by Google Update. |
1671 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1712 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1672 | 1713 |
1673 VLOG(1) << "Installation complete, returning: " << return_code; | 1714 VLOG(1) << "Installation complete, returning: " << return_code; |
1674 | 1715 |
1675 return return_code; | 1716 return return_code; |
1676 } | 1717 } |
OLD | NEW |