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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 } | 1026 } |
1027 | 1027 |
1028 // This method processes any command line options that make setup.exe do | 1028 // This method processes any command line options that make setup.exe do |
1029 // various tasks other than installation (renaming chrome.exe, showing eula | 1029 // various tasks other than installation (renaming chrome.exe, showing eula |
1030 // among others). This function returns true if any such command line option | 1030 // among others). This function returns true if any such command line option |
1031 // has been found and processed (so setup.exe should exit at that point). | 1031 // has been found and processed (so setup.exe should exit at that point). |
1032 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, | 1032 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
1033 const CommandLine& cmd_line, | 1033 const CommandLine& cmd_line, |
1034 InstallerState* installer_state, | 1034 InstallerState* installer_state, |
1035 int* exit_code) { | 1035 int* exit_code) { |
| 1036 // TODO(gab): Add a local |status| variable which each block below sets; |
| 1037 // only determine the |exit_code| from |status| at the end (this will allow |
| 1038 // this method to validate that |
| 1039 // (!handled || status != installer::UNKNOWN_STATUS)). |
1036 bool handled = true; | 1040 bool handled = true; |
1037 // TODO(tommi): Split these checks up into functions and use a data driven | 1041 // TODO(tommi): Split these checks up into functions and use a data driven |
1038 // map of switch->function. | 1042 // map of switch->function. |
1039 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { | 1043 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { |
1040 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; | 1044 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; |
1041 // If --update-setup-exe command line option is given, we apply the given | 1045 // If --update-setup-exe command line option is given, we apply the given |
1042 // patch to current exe, and store the resulting binary in the path | 1046 // patch to current exe, and store the resulting binary in the path |
1043 // specified by --new-setup-exe. But we need to first unpack the file | 1047 // specified by --new-setup-exe. But we need to first unpack the file |
1044 // given in --update-setup-exe. | 1048 // given in --update-setup-exe. |
1045 ScopedTempDir temp_path; | 1049 ScopedTempDir temp_path; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 // then the dialog is shown and regardless of the outcome setup exits here. | 1087 // then the dialog is shown and regardless of the outcome setup exits here. |
1084 string16 inner_frame = | 1088 string16 inner_frame = |
1085 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 1089 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
1086 *exit_code = ShowEULADialog(inner_frame); | 1090 *exit_code = ShowEULADialog(inner_frame); |
1087 if (installer::EULA_REJECTED != *exit_code) { | 1091 if (installer::EULA_REJECTED != *exit_code) { |
1088 GoogleUpdateSettings::SetEULAConsent( | 1092 GoogleUpdateSettings::SetEULAConsent( |
1089 original_state, BrowserDistribution::GetDistribution(), true); | 1093 original_state, BrowserDistribution::GetDistribution(), true); |
1090 } | 1094 } |
1091 } else if (cmd_line.HasSwitch( | 1095 } else if (cmd_line.HasSwitch( |
1092 installer::switches::kConfigureUserSettings)) { | 1096 installer::switches::kConfigureUserSettings)) { |
1093 DCHECK(installer_state->system_install()); | 1097 // NOTE: Should the work done here, on kConfigureUserSettings, change: |
| 1098 // kActiveSetupVersion in install_worker.cc needs to be increased for Active |
| 1099 // Setup to invoke this again for all users of this install. |
1094 const Product* chrome_install = | 1100 const Product* chrome_install = |
1095 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1101 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
1096 DCHECK(chrome_install); | 1102 |
1097 // TODO(gab): Implement the new shortcut functionality here. | 1103 // Create per-user Start Menu shortcuts. |
1098 LOG(ERROR) << "--configure-user-settings is not implemented."; | 1104 // TODO(gab): This should really be more involved, but for now creating |
| 1105 // the shortcut and leaving it non-updated in later updates is fine. |
| 1106 // This is all coming in an upcoming refactoring of the shortcuts, but for |
| 1107 // now this will simply create the user-level shortcut once on the first |
| 1108 // (and only) invocation of Active Setup for Chrome for this user. |
| 1109 installer::InstallStatus status = installer::INVALID_STATE_FOR_OPTION; |
| 1110 if (chrome_install && installer_state->system_install()) { |
| 1111 ForceCreateUserLevelStartMenuShortcut(*installer_state, *chrome_install); |
| 1112 status = installer::INSTALL_REPAIRED; |
| 1113 } else { |
| 1114 LOG(DFATAL) << "chrome_install:" << chrome_install |
| 1115 << ", system_install:" << installer_state->system_install(); |
| 1116 } |
| 1117 *exit_code = InstallUtil::GetInstallReturnCode(status); |
1099 } else if (cmd_line.HasSwitch( | 1118 } else if (cmd_line.HasSwitch( |
1100 installer::switches::kRegisterChromeBrowser)) { | 1119 installer::switches::kRegisterChromeBrowser)) { |
1101 installer::InstallStatus status = installer::UNKNOWN_STATUS; | 1120 installer::InstallStatus status = installer::UNKNOWN_STATUS; |
1102 const Product* chrome_install = | 1121 const Product* chrome_install = |
1103 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1122 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
1104 if (chrome_install) { | 1123 if (chrome_install) { |
1105 // If --register-chrome-browser option is specified, register all | 1124 // If --register-chrome-browser option is specified, register all |
1106 // Chrome protocol/file associations, as well as register it as a valid | 1125 // Chrome protocol/file associations, as well as register it as a valid |
1107 // browser for Start Menu->Internet shortcut. This switch will also | 1126 // browser for Start Menu->Internet shortcut. This switch will also |
1108 // register Chrome as a valid handler for a set of URL protocols that | 1127 // register Chrome as a valid handler for a set of URL protocols that |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1185 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
1167 DCHECK(chrome_install); | 1186 DCHECK(chrome_install); |
1168 if (chrome_install) { | 1187 if (chrome_install) { |
1169 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), | 1188 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), |
1170 HKEY_LOCAL_MACHINE, suffix, installer_state->target_path(), &tmp); | 1189 HKEY_LOCAL_MACHINE, suffix, installer_state->target_path(), &tmp); |
1171 } | 1190 } |
1172 *exit_code = tmp; | 1191 *exit_code = tmp; |
1173 } else if (cmd_line.HasSwitch(installer::switches::kOnOsUpgrade)) { | 1192 } else if (cmd_line.HasSwitch(installer::switches::kOnOsUpgrade)) { |
1174 const Product* chrome_install = | 1193 const Product* chrome_install = |
1175 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1194 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 1195 installer::InstallStatus status = installer::INVALID_STATE_FOR_OPTION; |
1176 if (chrome_install) { | 1196 if (chrome_install) { |
1177 installer::HandleOsUpgradeForBrowser(*installer_state, | 1197 installer::HandleOsUpgradeForBrowser(*installer_state, |
1178 *chrome_install, | 1198 *chrome_install, |
1179 cmd_line.GetProgram()); | 1199 cmd_line.GetProgram()); |
| 1200 status = installer::INSTALL_REPAIRED; |
| 1201 } else { |
| 1202 LOG(DFATAL) << "Chrome product not found."; |
1180 } | 1203 } |
1181 *exit_code = InstallUtil::GetInstallReturnCode(installer::INSTALL_REPAIRED); | 1204 *exit_code = InstallUtil::GetInstallReturnCode(status); |
1182 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { | 1205 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { |
1183 // Launch the inactive user toast experiment. | 1206 // Launch the inactive user toast experiment. |
1184 int flavor = -1; | 1207 int flavor = -1; |
1185 base::StringToInt(cmd_line.GetSwitchValueNative( | 1208 base::StringToInt(cmd_line.GetSwitchValueNative( |
1186 installer::switches::kInactiveUserToast), &flavor); | 1209 installer::switches::kInactiveUserToast), &flavor); |
1187 std::string experiment_group = | 1210 std::string experiment_group = |
1188 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); | 1211 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); |
1189 DCHECK_NE(-1, flavor); | 1212 DCHECK_NE(-1, flavor); |
1190 if (flavor == -1) { | 1213 if (flavor == -1) { |
1191 *exit_code = installer::UNKNOWN_STATUS; | 1214 *exit_code = installer::UNKNOWN_STATUS; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 if (!(installer_state.is_msi() && is_uninstall)) | 1531 if (!(installer_state.is_msi() && is_uninstall)) |
1509 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1532 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1510 // to pass through, since this is only returned on uninstall which is | 1533 // to pass through, since this is only returned on uninstall which is |
1511 // never invoked directly by Google Update. | 1534 // never invoked directly by Google Update. |
1512 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1535 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1513 | 1536 |
1514 VLOG(1) << "Installation complete, returning: " << return_code; | 1537 VLOG(1) << "Installation complete, returning: " << return_code; |
1515 | 1538 |
1516 return return_code; | 1539 return return_code; |
1517 } | 1540 } |
OLD | NEW |