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 <string> | 10 #include <string> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/installer/util/installation_state.h" | 53 #include "chrome/installer/util/installation_state.h" |
54 #include "chrome/installer/util/installation_validator.h" | 54 #include "chrome/installer/util/installation_validator.h" |
55 #include "chrome/installer/util/installer_state.h" | 55 #include "chrome/installer/util/installer_state.h" |
56 #include "chrome/installer/util/l10n_string_util.h" | 56 #include "chrome/installer/util/l10n_string_util.h" |
57 #include "chrome/installer/util/logging_installer.h" | 57 #include "chrome/installer/util/logging_installer.h" |
58 #include "chrome/installer/util/lzma_util.h" | 58 #include "chrome/installer/util/lzma_util.h" |
59 #include "chrome/installer/util/master_preferences.h" | 59 #include "chrome/installer/util/master_preferences.h" |
60 #include "chrome/installer/util/master_preferences_constants.h" | 60 #include "chrome/installer/util/master_preferences_constants.h" |
61 #include "chrome/installer/util/self_cleaning_temp_dir.h" | 61 #include "chrome/installer/util/self_cleaning_temp_dir.h" |
62 #include "chrome/installer/util/shell_util.h" | 62 #include "chrome/installer/util/shell_util.h" |
| 63 #include "chrome/installer/util/user_experiment.h" |
63 #include "chrome/installer/util/util_constants.h" | 64 #include "chrome/installer/util/util_constants.h" |
64 | 65 |
65 #include "installer_util_strings.h" // NOLINT | 66 #include "installer_util_strings.h" // NOLINT |
66 | 67 |
67 using installer::InstallerState; | 68 using installer::InstallerState; |
68 using installer::InstallationState; | 69 using installer::InstallationState; |
69 using installer::InstallationValidator; | 70 using installer::InstallationValidator; |
70 using installer::Product; | 71 using installer::Product; |
71 using installer::ProductState; | 72 using installer::ProductState; |
72 using installer::Products; | 73 using installer::Products; |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 { | 916 { |
916 // If installation failed, use the path to the currently running setup. | 917 // If installation failed, use the path to the currently running setup. |
917 // If installation succeeded, use the path to setup in the installer dir. | 918 // If installation succeeded, use the path to setup in the installer dir. |
918 base::FilePath setup_path(cmd_line.GetProgram()); | 919 base::FilePath setup_path(cmd_line.GetProgram()); |
919 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { | 920 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { |
920 setup_path = installer_state.GetInstallerDirectory(*installer_version) | 921 setup_path = installer_state.GetInstallerDirectory(*installer_version) |
921 .Append(setup_path.BaseName()); | 922 .Append(setup_path.BaseName()); |
922 } | 923 } |
923 for (Products::const_iterator it = products.begin(); it < products.end(); | 924 for (Products::const_iterator it = products.begin(); it < products.end(); |
924 ++it) { | 925 ++it) { |
| 926 using installer::user_experiment::UserExperiment; |
925 const Product& product = **it; | 927 const Product& product = **it; |
926 product.distribution()->LaunchUserExperiment(setup_path, | 928 if (UserExperiment::IsExperimentSupported( |
927 install_status, *installer_version, product, system_install); | 929 product.distribution()->GetType(), |
| 930 UserExperiment::kExperimentAny)) { |
| 931 UserExperiment::LaunchUserExperiment(setup_path, |
| 932 install_status, *installer_version, product, system_install); |
| 933 } |
928 } | 934 } |
929 } | 935 } |
930 } | 936 } |
931 | 937 |
932 // Delete the master profile file if present. Note that we do not care about | 938 // Delete the master profile file if present. Note that we do not care about |
933 // rollback here and we schedule for deletion on reboot if the delete fails. | 939 // rollback here and we schedule for deletion on reboot if the delete fails. |
934 // As such, we do not use DeleteTreeWorkItem. | 940 // As such, we do not use DeleteTreeWorkItem. |
935 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 941 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
936 base::FilePath prefs_path(cmd_line.GetSwitchValuePath( | 942 base::FilePath prefs_path(cmd_line.GetSwitchValuePath( |
937 installer::switches::kInstallerData)); | 943 installer::switches::kInstallerData)); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 } | 1238 } |
1233 | 1239 |
1234 // This method processes any command line options that make setup.exe do | 1240 // This method processes any command line options that make setup.exe do |
1235 // various tasks other than installation (renaming chrome.exe, showing eula | 1241 // various tasks other than installation (renaming chrome.exe, showing eula |
1236 // among others). This function returns true if any such command line option | 1242 // among others). This function returns true if any such command line option |
1237 // has been found and processed (so setup.exe should exit at that point). | 1243 // has been found and processed (so setup.exe should exit at that point). |
1238 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, | 1244 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
1239 const CommandLine& cmd_line, | 1245 const CommandLine& cmd_line, |
1240 InstallerState* installer_state, | 1246 InstallerState* installer_state, |
1241 int* exit_code) { | 1247 int* exit_code) { |
| 1248 using installer::user_experiment::UserExperiment; |
1242 // TODO(gab): Add a local |status| variable which each block below sets; | 1249 // TODO(gab): Add a local |status| variable which each block below sets; |
1243 // only determine the |exit_code| from |status| at the end (this will allow | 1250 // only determine the |exit_code| from |status| at the end (this will allow |
1244 // this method to validate that | 1251 // this method to validate that |
1245 // (!handled || status != installer::UNKNOWN_STATUS)). | 1252 // (!handled || status != installer::UNKNOWN_STATUS)). |
1246 bool handled = true; | 1253 bool handled = true; |
1247 // TODO(tommi): Split these checks up into functions and use a data driven | 1254 // TODO(tommi): Split these checks up into functions and use a data driven |
1248 // map of switch->function. | 1255 // map of switch->function. |
1249 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { | 1256 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { |
1250 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; | 1257 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; |
1251 // If --update-setup-exe command line option is given, we apply the given | 1258 // If --update-setup-exe command line option is given, we apply the given |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); | 1429 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); |
1423 DCHECK_NE(-1, flavor); | 1430 DCHECK_NE(-1, flavor); |
1424 if (flavor == -1) { | 1431 if (flavor == -1) { |
1425 *exit_code = installer::UNKNOWN_STATUS; | 1432 *exit_code = installer::UNKNOWN_STATUS; |
1426 } else { | 1433 } else { |
1427 const Products& products = installer_state->products(); | 1434 const Products& products = installer_state->products(); |
1428 for (Products::const_iterator it = products.begin(); it < products.end(); | 1435 for (Products::const_iterator it = products.begin(); it < products.end(); |
1429 ++it) { | 1436 ++it) { |
1430 const Product& product = **it; | 1437 const Product& product = **it; |
1431 BrowserDistribution* browser_dist = product.distribution(); | 1438 BrowserDistribution* browser_dist = product.distribution(); |
1432 browser_dist->InactiveUserToastExperiment( | 1439 if (UserExperiment::IsExperimentSupported(browser_dist->GetType(), |
1433 flavor, ASCIIToUTF16(experiment_group), product, | 1440 UserExperiment::kExperimentInactiveUserToast)) { |
1434 installer_state->target_path()); | 1441 UserExperiment::InactiveUserToastExperiment( |
| 1442 browser_dist, flavor, ASCIIToUTF16(experiment_group), product, |
| 1443 installer_state->target_path()); |
| 1444 } |
1435 } | 1445 } |
1436 } | 1446 } |
1437 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 1447 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
1438 const Products& products = installer_state->products(); | 1448 const Products& products = installer_state->products(); |
1439 for (Products::const_iterator it = products.begin(); it < products.end(); | 1449 for (Products::const_iterator it = products.begin(); it < products.end(); |
1440 ++it) { | 1450 ++it) { |
1441 const Product& product = **it; | 1451 const Product& product = **it; |
1442 BrowserDistribution* browser_dist = product.distribution(); | 1452 BrowserDistribution* browser_dist = product.distribution(); |
1443 // We started as system-level and have been re-launched as user level | 1453 // We started as system-level and have been re-launched as user level |
1444 // to continue with the toast experiment. | 1454 // to continue with the toast experiment. |
1445 Version installed_version; | 1455 Version installed_version; |
1446 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); | 1456 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); |
1447 if (!installed_version.IsValid()) { | 1457 if (!installed_version.IsValid()) { |
1448 LOG(ERROR) << "No installation of " | 1458 LOG(ERROR) << "No installation of " |
1449 << browser_dist->GetAppShortCutName() | 1459 << browser_dist->GetAppShortCutName() |
1450 << " found for system-level toast."; | 1460 << " found for system-level toast."; |
1451 } else { | 1461 } else { |
1452 browser_dist->LaunchUserExperiment(cmd_line.GetProgram(), | 1462 if (UserExperiment::IsExperimentSupported(browser_dist->GetType(), |
1453 installer::REENTRY_SYS_UPDATE, | 1463 UserExperiment::kExperimentAny)) { |
1454 installed_version, product, true); | 1464 UserExperiment::LaunchUserExperiment(cmd_line.GetProgram(), |
| 1465 installer::REENTRY_SYS_UPDATE, installed_version, product, true); |
| 1466 } |
1455 } | 1467 } |
1456 } | 1468 } |
1457 } else if (cmd_line.HasSwitch( | 1469 } else if (cmd_line.HasSwitch( |
1458 installer::switches::kChromeFrameReadyModeOptIn)) { | 1470 installer::switches::kChromeFrameReadyModeOptIn)) { |
1459 *exit_code = InstallUtil::GetInstallReturnCode( | 1471 *exit_code = InstallUtil::GetInstallReturnCode( |
1460 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); | 1472 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); |
1461 } else if (cmd_line.HasSwitch( | 1473 } else if (cmd_line.HasSwitch( |
1462 installer::switches::kChromeFrameReadyModeTempOptOut)) { | 1474 installer::switches::kChromeFrameReadyModeTempOptOut)) { |
1463 *exit_code = InstallUtil::GetInstallReturnCode( | 1475 *exit_code = InstallUtil::GetInstallReturnCode( |
1464 installer::ChromeFrameReadyModeTempOptOut(original_state, | 1476 installer::ChromeFrameReadyModeTempOptOut(original_state, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 if (!(installer_state.is_msi() && is_uninstall)) | 1761 if (!(installer_state.is_msi() && is_uninstall)) |
1750 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1762 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1751 // to pass through, since this is only returned on uninstall which is | 1763 // to pass through, since this is only returned on uninstall which is |
1752 // never invoked directly by Google Update. | 1764 // never invoked directly by Google Update. |
1753 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1765 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1754 | 1766 |
1755 VLOG(1) << "Installation complete, returning: " << return_code; | 1767 VLOG(1) << "Installation complete, returning: " << return_code; |
1756 | 1768 |
1757 return return_code; | 1769 return return_code; |
1758 } | 1770 } |
OLD | NEW |