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/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
24 #include "base/win/scoped_comptr.h" | |
24 #include "base/win/scoped_handle.h" | 25 #include "base/win/scoped_handle.h" |
25 #include "base/win/win_util.h" | 26 #include "base/win/win_util.h" |
26 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
27 #include "breakpad/src/client/windows/handler/exception_handler.h" | 28 #include "breakpad/src/client/windows/handler/exception_handler.h" |
28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/installer/setup/chrome_frame_quick_enable.h" | 30 #include "chrome/installer/setup/chrome_frame_quick_enable.h" |
30 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 31 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
31 #include "chrome/installer/setup/install.h" | 32 #include "chrome/installer/setup/install.h" |
32 #include "chrome/installer/setup/install_worker.h" | 33 #include "chrome/installer/setup/install_worker.h" |
33 #include "chrome/installer/setup/setup_constants.h" | 34 #include "chrome/installer/setup/setup_constants.h" |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1024 return installer::EULA_REJECTED; | 1025 return installer::EULA_REJECTED; |
1025 } | 1026 } |
1026 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { | 1027 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { |
1027 VLOG(1) << "EULA accepted (opt-in)"; | 1028 VLOG(1) << "EULA accepted (opt-in)"; |
1028 return installer::EULA_ACCEPTED_OPT_IN; | 1029 return installer::EULA_ACCEPTED_OPT_IN; |
1029 } | 1030 } |
1030 VLOG(1) << "EULA accepted (no opt-in)"; | 1031 VLOG(1) << "EULA accepted (no opt-in)"; |
1031 return installer::EULA_ACCEPTED; | 1032 return installer::EULA_ACCEPTED; |
1032 } | 1033 } |
1033 | 1034 |
1035 // Creates the sentinel indicating that the EULA was required and has been | |
1036 // accepted. | |
1037 bool CreateEULASentinel(BrowserDistribution* dist) { | |
1038 FilePath eula_sentinel; | |
1039 if (!InstallUtil::GetSentinelFilePath(installer::kEULASentinelFile, | |
1040 dist, &eula_sentinel)) | |
1041 return false; | |
grt (UTC plus 2)
2012/09/21 13:21:16
parens
robertshield
2012/09/26 01:35:53
Done.
grt (UTC plus 2)
2012/09/26 01:59:21
And by "parens", I of course meant "braces", as in
| |
1042 return file_util::WriteFile(eula_sentinel, "", 0) != -1; | |
1043 } | |
1044 | |
1045 void ActivateMetroChrome() { | |
1046 // Check to see if we're per-user or not. Need to do this since we may | |
1047 // not have been invoked with --system-level even for a machine install. | |
1048 wchar_t exe_path[MAX_PATH * 2] = {}; | |
1049 GetModuleFileName(NULL, exe_path, arraysize(exe_path)); | |
1050 bool is_per_user_install = InstallUtil::IsPerUserInstall(exe_path); | |
1051 | |
1052 string16 app_model_id = | |
1053 ShellUtil::GetBrowserModelId(BrowserDistribution::GetDistribution(), | |
1054 is_per_user_install); | |
1055 | |
1056 base::win::ScopedComPtr<IApplicationActivationManager> activator; | |
1057 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager); | |
1058 if (SUCCEEDED(hr)) { | |
1059 DWORD pid = 0; | |
1060 hr = activator->ActivateApplication( | |
1061 app_model_id.c_str(), L"open", AO_NONE, &pid); | |
1062 } | |
1063 | |
1064 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. " | |
1065 << "hr=" << std::hex << hr; | |
1066 } | |
1067 | |
1034 // This method processes any command line options that make setup.exe do | 1068 // This method processes any command line options that make setup.exe do |
1035 // various tasks other than installation (renaming chrome.exe, showing eula | 1069 // various tasks other than installation (renaming chrome.exe, showing eula |
1036 // among others). This function returns true if any such command line option | 1070 // among others). This function returns true if any such command line option |
1037 // has been found and processed (so setup.exe should exit at that point). | 1071 // has been found and processed (so setup.exe should exit at that point). |
1038 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, | 1072 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
1039 const CommandLine& cmd_line, | 1073 const CommandLine& cmd_line, |
1040 InstallerState* installer_state, | 1074 InstallerState* installer_state, |
1041 int* exit_code) { | 1075 int* exit_code) { |
1042 bool handled = true; | 1076 bool handled = true; |
1043 // TODO(tommi): Split these checks up into functions and use a data driven | 1077 // TODO(tommi): Split these checks up into functions and use a data driven |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 status, IDS_SETUP_PATCH_FAILED_BASE, NULL); | 1117 status, IDS_SETUP_PATCH_FAILED_BASE, NULL); |
1084 } | 1118 } |
1085 // We will be exiting normally, so clear the stage indicator. | 1119 // We will be exiting normally, so clear the stage indicator. |
1086 installer_state->UpdateStage(installer::NO_STAGE); | 1120 installer_state->UpdateStage(installer::NO_STAGE); |
1087 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { | 1121 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { |
1088 // Check if we need to show the EULA. If it is passed as a command line | 1122 // Check if we need to show the EULA. If it is passed as a command line |
1089 // then the dialog is shown and regardless of the outcome setup exits here. | 1123 // then the dialog is shown and regardless of the outcome setup exits here. |
1090 string16 inner_frame = | 1124 string16 inner_frame = |
1091 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 1125 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
1092 *exit_code = ShowEULADialog(inner_frame); | 1126 *exit_code = ShowEULADialog(inner_frame); |
1127 | |
1093 if (installer::EULA_REJECTED != *exit_code) { | 1128 if (installer::EULA_REJECTED != *exit_code) { |
1094 GoogleUpdateSettings::SetEULAConsent( | 1129 if (GoogleUpdateSettings::SetEULAConsent( |
1095 original_state, BrowserDistribution::GetDistribution(), true); | 1130 original_state, BrowserDistribution::GetDistribution(), true)) { |
1131 CreateEULASentinel(BrowserDistribution::GetDistribution()); | |
1132 } | |
1133 // For a metro-originated launch, we now need to launch back into metro. | |
1134 if (cmd_line.HasSwitch(installer::switches::kShowEulaForMetro)) | |
1135 ActivateMetroChrome(); | |
1096 } | 1136 } |
1097 } else if (cmd_line.HasSwitch( | 1137 } else if (cmd_line.HasSwitch( |
1098 installer::switches::kConfigureUserSettings)) { | 1138 installer::switches::kConfigureUserSettings)) { |
1099 DCHECK(installer_state->system_install()); | 1139 DCHECK(installer_state->system_install()); |
1100 const Product* chrome_install = | 1140 const Product* chrome_install = |
1101 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1141 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
1102 DCHECK(chrome_install); | 1142 DCHECK(chrome_install); |
1103 // TODO(gab): Implement the new shortcut functionality here. | 1143 // TODO(gab): Implement the new shortcut functionality here. |
1104 LOG(ERROR) << "--configure-user-settings is not implemented."; | 1144 LOG(ERROR) << "--configure-user-settings is not implemented."; |
1105 } else if (cmd_line.HasSwitch( | 1145 } else if (cmd_line.HasSwitch( |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 if (!(installer_state.is_msi() && is_uninstall)) | 1559 if (!(installer_state.is_msi() && is_uninstall)) |
1520 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1560 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1521 // to pass through, since this is only returned on uninstall which is | 1561 // to pass through, since this is only returned on uninstall which is |
1522 // never invoked directly by Google Update. | 1562 // never invoked directly by Google Update. |
1523 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1563 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1524 | 1564 |
1525 VLOG(1) << "Installation complete, returning: " << return_code; | 1565 VLOG(1) << "Installation complete, returning: " << return_code; |
1526 | 1566 |
1527 return return_code; | 1567 return return_code; |
1528 } | 1568 } |
OLD | NEW |