OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/file_version_info.h" | 16 #include "base/file_version_info.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process_util.h" | 18 #include "base/process_util.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/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
24 #include "base/win/win_util.h" | 25 #include "base/win/win_util.h" |
25 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
26 #include "breakpad/src/client/windows/handler/exception_handler.h" | 27 #include "breakpad/src/client/windows/handler/exception_handler.h" |
27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 29 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
29 #include "chrome/installer/setup/install.h" | 30 #include "chrome/installer/setup/install.h" |
30 #include "chrome/installer/setup/setup_constants.h" | 31 #include "chrome/installer/setup/setup_constants.h" |
31 #include "chrome/installer/setup/setup_util.h" | 32 #include "chrome/installer/setup/setup_util.h" |
32 #include "chrome/installer/setup/uninstall.h" | 33 #include "chrome/installer/setup/uninstall.h" |
33 #include "chrome/installer/util/browser_distribution.h" | 34 #include "chrome/installer/util/browser_distribution.h" |
| 35 #include "chrome/installer/util/channel_info.h" |
34 #include "chrome/installer/util/delete_after_reboot_helper.h" | 36 #include "chrome/installer/util/delete_after_reboot_helper.h" |
35 #include "chrome/installer/util/delete_tree_work_item.h" | 37 #include "chrome/installer/util/delete_tree_work_item.h" |
36 #include "chrome/installer/util/google_update_settings.h" | 38 #include "chrome/installer/util/google_update_settings.h" |
37 #include "chrome/installer/util/google_update_constants.h" | 39 #include "chrome/installer/util/google_update_constants.h" |
38 #include "chrome/installer/util/helper.h" | 40 #include "chrome/installer/util/helper.h" |
39 #include "chrome/installer/util/html_dialog.h" | 41 #include "chrome/installer/util/html_dialog.h" |
40 #include "chrome/installer/util/install_util.h" | 42 #include "chrome/installer/util/install_util.h" |
41 #include "chrome/installer/util/installer_state.h" | 43 #include "chrome/installer/util/installer_state.h" |
42 #include "chrome/installer/util/installation_state.h" | 44 #include "chrome/installer/util/installation_state.h" |
43 #include "chrome/installer/util/l10n_string_util.h" | 45 #include "chrome/installer/util/l10n_string_util.h" |
44 #include "chrome/installer/util/logging_installer.h" | 46 #include "chrome/installer/util/logging_installer.h" |
45 #include "chrome/installer/util/lzma_util.h" | 47 #include "chrome/installer/util/lzma_util.h" |
46 #include "chrome/installer/util/master_preferences.h" | 48 #include "chrome/installer/util/master_preferences.h" |
47 #include "chrome/installer/util/master_preferences_constants.h" | 49 #include "chrome/installer/util/master_preferences_constants.h" |
48 #include "chrome/installer/util/package_properties.h" | |
49 #include "chrome/installer/util/shell_util.h" | 50 #include "chrome/installer/util/shell_util.h" |
50 #include "chrome/installer/util/util_constants.h" | 51 #include "chrome/installer/util/util_constants.h" |
51 | 52 |
52 #include "installer_util_strings.h" // NOLINT | 53 #include "installer_util_strings.h" // NOLINT |
53 | 54 |
54 using installer::InstallerState; | 55 using installer::InstallerState; |
55 using installer::InstallationState; | 56 using installer::InstallationState; |
56 using installer::Product; | 57 using installer::Product; |
57 using installer::ProductPackageMapping; | |
58 using installer::ProductState; | 58 using installer::ProductState; |
59 using installer::Products; | 59 using installer::Products; |
60 using installer::Package; | |
61 using installer::Packages; | |
62 using installer::MasterPreferences; | 60 using installer::MasterPreferences; |
63 | 61 |
64 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 62 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
65 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 63 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
66 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 64 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
67 | 65 |
68 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( | 66 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
69 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 67 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
70 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 68 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
71 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | 69 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. |
72 | 70 |
73 namespace { | 71 namespace { |
74 | 72 |
75 // This method unpacks and uncompresses the given archive file. For Chrome | 73 // This method unpacks and uncompresses the given archive file. For Chrome |
76 // install we are creating a uncompressed archive that contains all the files | 74 // install we are creating a uncompressed archive that contains all the files |
77 // needed for the installer. This uncompressed archive is later compressed. | 75 // needed for the installer. This uncompressed archive is later compressed. |
78 // | 76 // |
79 // This method first uncompresses archive specified by parameter "archive" | 77 // This method first uncompresses archive specified by parameter "archive" |
80 // and assumes that it will result in an uncompressed full archive file | 78 // and assumes that it will result in an uncompressed full archive file |
81 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it | 79 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it |
82 // is patch file, it is applied to the old archive file that should be | 80 // is patch file, it is applied to the old archive file that should be |
83 // present on the system already. As the final step the new archive file | 81 // present on the system already. As the final step the new archive file |
84 // is unpacked in the path specified by parameter "output_directory". | 82 // is unpacked in the path specified by parameter "output_directory". |
85 DWORD UnPackArchive(const FilePath& archive, | 83 DWORD UnPackArchive(const FilePath& archive, |
86 const Package& installation, | 84 const InstallerState& installer_state, |
87 const FilePath& temp_path, | 85 const FilePath& temp_path, |
88 const FilePath& output_directory, | 86 const FilePath& output_directory, |
89 bool& incremental_install) { | 87 bool& incremental_install) { |
90 // First uncompress the payload. This could be a differential | 88 // First uncompress the payload. This could be a differential |
91 // update (patch.7z) or full archive (chrome.7z). If this uncompress fails | 89 // update (patch.7z) or full archive (chrome.7z). If this uncompress fails |
92 // return with error. | 90 // return with error. |
93 std::wstring unpacked_file; | 91 std::wstring unpacked_file; |
94 int32 ret = LzmaUtil::UnPackArchive(archive.value(), temp_path.value(), | 92 int32 ret = LzmaUtil::UnPackArchive(archive.value(), temp_path.value(), |
95 &unpacked_file); | 93 &unpacked_file); |
96 if (ret != NO_ERROR) | 94 if (ret != NO_ERROR) |
97 return ret; | 95 return ret; |
98 | 96 |
99 FilePath uncompressed_archive(temp_path.Append(installer::kChromeArchive)); | 97 FilePath uncompressed_archive(temp_path.Append(installer::kChromeArchive)); |
100 scoped_ptr<Version> archive_version( | 98 scoped_ptr<Version> archive_version( |
101 installer::GetVersionFromArchiveDir(installation.path())); | 99 installer::GetVersionFromArchiveDir(installer_state.target_path())); |
102 | 100 |
103 // Check if this is differential update and if it is, patch it to the | 101 // Check if this is differential update and if it is, patch it to the |
104 // installer archive that should already be on the machine. We assume | 102 // installer archive that should already be on the machine. We assume |
105 // it is a differential installer if chrome.7z is not found. | 103 // it is a differential installer if chrome.7z is not found. |
106 if (!file_util::PathExists(uncompressed_archive)) { | 104 if (!file_util::PathExists(uncompressed_archive)) { |
107 incremental_install = true; | 105 incremental_install = true; |
108 VLOG(1) << "Differential patch found. Applying to existing archive."; | 106 VLOG(1) << "Differential patch found. Applying to existing archive."; |
109 if (!archive_version.get()) { | 107 if (!archive_version.get()) { |
110 LOG(ERROR) << "Can not use differential update when Chrome is not " | 108 LOG(ERROR) << "Can not use differential update when Chrome is not " |
111 << "installed on the system."; | 109 << "installed on the system."; |
112 return installer::CHROME_NOT_INSTALLED; | 110 return installer::CHROME_NOT_INSTALLED; |
113 } | 111 } |
114 | 112 |
115 FilePath existing_archive(installation.path().Append( | 113 FilePath existing_archive(installer_state.target_path().Append( |
116 UTF8ToWide(archive_version->GetString()))); | 114 UTF8ToWide(archive_version->GetString()))); |
117 existing_archive = existing_archive.Append(installer::kInstallerDir); | 115 existing_archive = existing_archive.Append(installer::kInstallerDir); |
118 existing_archive = existing_archive.Append(installer::kChromeArchive); | 116 existing_archive = existing_archive.Append(installer::kChromeArchive); |
119 if (int i = installer::ApplyDiffPatch(FilePath(existing_archive), | 117 if (int i = installer::ApplyDiffPatch(FilePath(existing_archive), |
120 FilePath(unpacked_file), | 118 FilePath(unpacked_file), |
121 FilePath(uncompressed_archive))) { | 119 FilePath(uncompressed_archive))) { |
122 LOG(ERROR) << "Binary patching failed with error " << i; | 120 LOG(ERROR) << "Binary patching failed with error " << i; |
123 return i; | 121 return i; |
124 } | 122 } |
125 } | 123 } |
126 | 124 |
127 // Unpack the uncompressed archive. | 125 // Unpack the uncompressed archive. |
128 return LzmaUtil::UnPackArchive(uncompressed_archive.value(), | 126 return LzmaUtil::UnPackArchive(uncompressed_archive.value(), |
129 output_directory.value(), &unpacked_file); | 127 output_directory.value(), &unpacked_file); |
130 } | 128 } |
131 | 129 |
132 | 130 |
133 // This function is called when --rename-chrome-exe option is specified on | 131 // This function is called when --rename-chrome-exe option is specified on |
134 // setup.exe command line. This function assumes an in-use update has happened | 132 // setup.exe command line. This function assumes an in-use update has happened |
135 // for Chrome so there should be a file called new_chrome.exe on the file | 133 // for Chrome so there should be a file called new_chrome.exe on the file |
136 // system and a key called 'opv' in the registry. This function will move | 134 // system and a key called 'opv' in the registry. This function will move |
137 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. | 135 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. |
138 installer::InstallStatus RenameChromeExecutables( | 136 installer::InstallStatus RenameChromeExecutables( |
139 const Package& installation) { | 137 const InstallerState& installer_state) { |
140 FilePath chrome_exe(installation.path().Append(installer::kChromeExe)); | 138 const FilePath &target_path = installer_state.target_path(); |
141 FilePath chrome_old_exe(installation.path().Append( | 139 FilePath chrome_exe(target_path.Append(installer::kChromeExe)); |
142 installer::kChromeOldExe)); | 140 FilePath chrome_old_exe(target_path.Append(installer::kChromeOldExe)); |
143 FilePath chrome_new_exe(installation.path().Append( | 141 FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe)); |
144 installer::kChromeNewExe)); | |
145 | 142 |
146 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 143 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
147 install_list->AddDeleteTreeWorkItem(chrome_old_exe); | 144 install_list->AddDeleteTreeWorkItem(chrome_old_exe); |
148 FilePath temp_path; | 145 FilePath temp_path; |
149 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 146 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
150 LOG(ERROR) << "Failed to create Temp directory " << temp_path.value(); | 147 LOG(ERROR) << "Failed to create Temp directory " << temp_path.value(); |
151 return installer::RENAME_FAILED; | 148 return installer::RENAME_FAILED; |
152 } | 149 } |
153 | 150 |
154 install_list->AddCopyTreeWorkItem(chrome_new_exe.value(), | 151 install_list->AddCopyTreeWorkItem(chrome_new_exe.value(), |
155 chrome_exe.value(), | 152 chrome_exe.value(), |
156 temp_path.ToWStringHack(), | 153 temp_path.ToWStringHack(), |
157 WorkItem::IF_DIFFERENT, | 154 WorkItem::IF_DIFFERENT, |
158 std::wstring()); | 155 std::wstring()); |
159 install_list->AddDeleteTreeWorkItem(chrome_new_exe); | 156 install_list->AddDeleteTreeWorkItem(chrome_new_exe); |
160 | 157 |
161 HKEY reg_root = installation.system_level() ? HKEY_LOCAL_MACHINE : | 158 HKEY reg_root = installer_state.root_key(); |
162 HKEY_CURRENT_USER; | 159 const Products& products = installer_state.products(); |
163 const Products& products = installation.products(); | |
164 for (size_t i = 0; i < products.size(); ++i) { | 160 for (size_t i = 0; i < products.size(); ++i) { |
165 const Product* product = products[i]; | 161 const Product* product = products[i]; |
166 BrowserDistribution* browser_dist = product->distribution(); | 162 BrowserDistribution* browser_dist = product->distribution(); |
167 std::wstring version_key(browser_dist->GetVersionKey()); | 163 std::wstring version_key(browser_dist->GetVersionKey()); |
168 install_list->AddDeleteRegValueWorkItem(reg_root, | 164 install_list->AddDeleteRegValueWorkItem(reg_root, |
169 version_key, | 165 version_key, |
170 google_update::kRegOldVersionField); | 166 google_update::kRegOldVersionField); |
171 install_list->AddDeleteRegValueWorkItem(reg_root, | 167 install_list->AddDeleteRegValueWorkItem(reg_root, |
172 version_key, | 168 version_key, |
173 google_update::kRegRenameCmdField); | 169 google_update::kRegRenameCmdField); |
174 } | 170 } |
175 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; | 171 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; |
176 if (!install_list->Do()) { | 172 if (!install_list->Do()) { |
177 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; | 173 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; |
178 install_list->Rollback(); | 174 install_list->Rollback(); |
179 ret = installer::RENAME_FAILED; | 175 ret = installer::RENAME_FAILED; |
180 } | 176 } |
181 file_util::Delete(temp_path, true); | 177 file_util::Delete(temp_path, true); |
182 return ret; | 178 return ret; |
183 } | 179 } |
184 | 180 |
| 181 // The supported multi-install modes are: |
| 182 // --multi-install --chrome --chrome-frame --ready-mode |
| 183 // - If a non-multi Chrome Frame installation is present, Chrome Frame is |
| 184 // removed from |installer_state|'s list of products (thereby preserving |
| 185 // the existing SxS install). |
| 186 // - If a multi Chrome Frame installation is present, its options are |
| 187 // preserved (i.e., the --ready-mode command-line option is ignored). |
| 188 // --multi-install --chrome-frame |
| 189 // - If a non-multi Chrome Frame installation is present, fail. |
| 190 // - If a Chrome installation on a different channel is present, fail. |
| 191 // - If --ready-mode and no Chrome installation is present, fail. |
| 192 // - If a Chrome installation is present, add it to the set of products to |
| 193 // install. |
| 194 bool CheckMultiInstallConditions(const InstallationState& original_state, |
| 195 InstallerState* installer_state, |
| 196 installer::InstallStatus* status) { |
| 197 const Products& products = installer_state->products(); |
| 198 DCHECK(products.size()); |
| 199 |
| 200 bool is_first_install = true; |
| 201 const bool system_level = installer_state->system_install(); |
| 202 |
| 203 if (installer_state->is_multi_install()) { |
| 204 const Product* chrome = |
| 205 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 206 const Product* chrome_frame = |
| 207 installer_state->FindProduct(BrowserDistribution::CHROME_FRAME); |
| 208 const ProductState* cf_state = |
| 209 original_state.GetProductState(system_level, |
| 210 BrowserDistribution::CHROME_FRAME); |
| 211 if (chrome != NULL) { |
| 212 if (chrome_frame != NULL && |
| 213 chrome_frame->HasOption(installer::kOptionReadyMode)) { |
| 214 // We're being asked to install Chrome with Chrome Frame in ready-mode. |
| 215 // This is an optimistic operation: if a SxS install of Chrome Frame |
| 216 // is already present, don't touch it; if a multi-install of Chrome |
| 217 // Frame is present, preserve its settings (ready-mode, CEEE). |
| 218 if (cf_state != NULL) { |
| 219 installer_state->RemoveProduct(chrome_frame); |
| 220 chrome_frame = NULL; |
| 221 if (cf_state->is_multi_install()) { |
| 222 chrome_frame = installer_state->AddProductFromState( |
| 223 BrowserDistribution::CHROME_FRAME, *cf_state); |
| 224 VLOG(1) << "Upgrading existing multi-install Chrome Frame rather " |
| 225 "than installing in ready-mode."; |
| 226 } else { |
| 227 VLOG(1) << "Skipping upgrade of single-install Chrome Frame rather " |
| 228 "than installing in ready-mode."; |
| 229 } |
| 230 } else { |
| 231 VLOG(1) << "Performing initial install of Chrome Frame ready-mode."; |
| 232 } |
| 233 } |
| 234 } else if (chrome_frame != NULL) { |
| 235 // We're being asked to install or update Chrome Frame alone. |
| 236 const ProductState* chrome_state = |
| 237 original_state.GetProductState(system_level, |
| 238 BrowserDistribution::CHROME_BROWSER); |
| 239 if (chrome_state != NULL) { |
| 240 base::win::RegKey key; |
| 241 installer::ChannelInfo cf_channel; |
| 242 // Chrome Frame may not yet be installed, so peek into the registry |
| 243 // directly to see what channel Google Update has specified. There will |
| 244 // be no value if we're not being managed by Google Update. |
| 245 if (key.Open(installer_state->root_key(), |
| 246 chrome_frame->distribution()->GetStateKey().c_str(), |
| 247 KEY_QUERY_VALUE) == ERROR_SUCCESS) { |
| 248 cf_channel.Initialize(key); |
| 249 } |
| 250 // Fail if Chrome is already installed but is on a different update |
| 251 // channel. |
| 252 if (!cf_channel.EqualsBaseOf(chrome_state->channel())) { |
| 253 LOG(ERROR) << "Cannot install Chrome Frame because existing Chrome " |
| 254 "install is on a different update channel."; |
| 255 *status = installer::CONFLICTING_CHANNEL_EXISTS; |
| 256 InstallUtil::WriteInstallerResult(system_level, |
| 257 installer_state->state_key(), *status, |
| 258 IDS_INSTALL_CONFLICTING_CHANNEL_EXISTS_BASE, NULL); |
| 259 return false; |
| 260 } |
| 261 // Otherwise, add Chrome to the set of products (making it multi-install |
| 262 // in the process) so that it is updated, too. |
| 263 scoped_ptr<Product> multi_chrome(new Product( |
| 264 BrowserDistribution::GetSpecificDistribution( |
| 265 BrowserDistribution::CHROME_BROWSER))); |
| 266 multi_chrome->SetOption(installer::kOptionMultiInstall, true); |
| 267 chrome = installer_state->AddProduct(&multi_chrome); |
| 268 VLOG(1) << "Upgrading existing multi-install Chrome browser along with " |
| 269 << chrome_frame->distribution()->GetApplicationName(); |
| 270 } else if (chrome_frame->HasOption(installer::kOptionReadyMode)) { |
| 271 // Chrome Frame with ready-mode is to be installed, yet Chrome is |
| 272 // neither installed nor being installed. Fail. |
| 273 LOG(ERROR) << "Cannot install Chrome Frame in ready mode without " |
| 274 "Chrome."; |
| 275 *status = installer::READY_MODE_REQUIRES_CHROME; |
| 276 InstallUtil::WriteInstallerResult(system_level, |
| 277 installer_state->state_key(), *status, |
| 278 IDS_INSTALL_READY_MODE_REQUIRES_CHROME_BASE, NULL); |
| 279 return false; |
| 280 } |
| 281 } |
| 282 |
| 283 // Fail if we're installing Chrome Frame when a single-install of it is |
| 284 // already installed. |
| 285 // TODO(grt): Add support for migration of Chrome Frame from single- to |
| 286 // multi-install. |
| 287 if (chrome_frame != NULL && |
| 288 cf_state != NULL && !cf_state->is_multi_install()) { |
| 289 LOG(ERROR) << "Cannot migrate existing Chrome Frame installation to " |
| 290 "multi-install."; |
| 291 *status = installer::NON_MULTI_INSTALLATION_EXISTS; |
| 292 InstallUtil::WriteInstallerResult(system_level, |
| 293 installer_state->state_key(), *status, |
| 294 IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE, NULL); |
| 295 return false; |
| 296 } |
| 297 } else if (DCHECK_IS_ON()) { |
| 298 // It isn't possible to stuff two products into a single-install |
| 299 // InstallerState. Abort the process here in debug builds just in case |
| 300 // someone finds a way. |
| 301 DCHECK_EQ(1U, products.size()); |
| 302 } |
| 303 |
| 304 return true; |
| 305 } |
| 306 |
| 307 // In multi-install, adds all products to |installer_state| that are |
| 308 // multi-installed and must be updated along with the products already present |
| 309 // in |installer_state|. |
| 310 void AddExistingMultiInstalls(const InstallationState& original_state, |
| 311 InstallerState* installer_state) { |
| 312 if (installer_state->is_multi_install()) { |
| 313 BrowserDistribution::Type product_checks[] = { |
| 314 BrowserDistribution::CHROME_BROWSER, |
| 315 BrowserDistribution::CHROME_FRAME |
| 316 }; |
| 317 |
| 318 for (size_t i = 0; i < arraysize(product_checks); ++i) { |
| 319 BrowserDistribution::Type type = product_checks[i]; |
| 320 if (!installer_state->FindProduct(type)) { |
| 321 const ProductState* state = |
| 322 original_state.GetProductState(installer_state->system_install(), |
| 323 type); |
| 324 if ((state != NULL) && state->is_multi_install()) { |
| 325 installer_state->AddProductFromState(type, *state); |
| 326 VLOG(1) << "Product already installed and must be included: " |
| 327 << BrowserDistribution::GetSpecificDistribution( |
| 328 type)->GetApplicationName(); |
| 329 } |
| 330 } |
| 331 } |
| 332 } |
| 333 } |
| 334 |
| 335 // Checks for compatibility between the current state of the system and the |
| 336 // desired operation. Also applies policy that mutates the desired operation; |
| 337 // specifically, the |installer_state| object. |
| 338 // Also blocks simultaneous user-level and system-level installs. In the case |
| 339 // of trying to install user-level Chrome when system-level exists, the |
| 340 // existing system-level Chrome is launched. |
185 bool CheckPreInstallConditions(const InstallationState& original_state, | 341 bool CheckPreInstallConditions(const InstallationState& original_state, |
186 const InstallerState& installer_state, | 342 InstallerState* installer_state, |
187 const Package& installation, | |
188 const MasterPreferences& prefs, | |
189 installer::InstallStatus* status) { | 343 installer::InstallStatus* status) { |
190 const Products& products = installation.products(); | 344 const Products& products = installer_state->products(); |
191 DCHECK(products.size()); | 345 DCHECK(products.size()); |
192 | 346 |
| 347 if (!CheckMultiInstallConditions(original_state, installer_state, status)) |
| 348 return false; |
| 349 |
193 bool is_first_install = true; | 350 bool is_first_install = true; |
194 const bool system_level = installation.system_level(); | 351 const bool system_level = installer_state->system_install(); |
195 | 352 |
196 for (size_t i = 0; i < products.size(); ++i) { | 353 for (size_t i = 0; i < products.size(); ++i) { |
197 const Product* product = products[i]; | 354 const Product* product = products[i]; |
198 BrowserDistribution* browser_dist = product->distribution(); | 355 BrowserDistribution* browser_dist = product->distribution(); |
| 356 |
| 357 // Check for an existing installation of the product. |
199 const ProductState* product_state = | 358 const ProductState* product_state = |
200 original_state.GetProductState(system_level, browser_dist->GetType()); | 359 original_state.GetProductState(system_level, browser_dist->GetType()); |
201 if (product_state != NULL) | 360 if (product_state != NULL) { |
202 is_first_install = false; | 361 is_first_install = false; |
| 362 // Block downgrades from multi-install to single-install. |
| 363 if (!installer_state->is_multi_install() && |
| 364 product_state->is_multi_install()) { |
| 365 LOG(ERROR) << "Multi-install " << browser_dist->GetApplicationName() |
| 366 << " exists; aborting single install."; |
| 367 *status = installer::MULTI_INSTALLATION_EXISTS; |
| 368 InstallUtil::WriteInstallerResult(system_level, |
| 369 installer_state->state_key(), *status, |
| 370 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); |
| 371 return false; |
| 372 } |
| 373 } |
203 | 374 |
204 // Check to avoid simultaneous per-user and per-machine installs. | 375 // Check to avoid simultaneous per-user and per-machine installs. |
205 const ProductState* other_state = | 376 const ProductState* other_state = |
206 original_state.GetProductState(!system_level, browser_dist->GetType()); | 377 original_state.GetProductState(!system_level, browser_dist->GetType()); |
207 | |
208 if (other_state != NULL) { | 378 if (other_state != NULL) { |
209 LOG(ERROR) << "Already installed version " | 379 LOG(ERROR) << "Already installed version " |
210 << other_state->version().GetString() | 380 << other_state->version().GetString() |
211 << " conflicts with the current install mode."; | 381 << " conflicts with the current install mode."; |
212 if (!system_level && is_first_install && product->is_chrome()) { | 382 if (!system_level && is_first_install && product->is_chrome()) { |
213 // This is user-level install and there is a system-level chrome | 383 // This is user-level install and there is a system-level chrome |
214 // installation. Instruct Omaha to launch the existing one. There | 384 // installation. Instruct Google Update to launch the existing one. |
215 // should be no error dialog. | 385 // There should be no error dialog. |
216 FilePath chrome_exe(installer::GetChromeInstallPath(!system_level, | 386 FilePath chrome_exe(installer::GetChromeInstallPath(!system_level, |
217 browser_dist)); | 387 browser_dist)); |
218 if (chrome_exe.empty()) { | 388 if (chrome_exe.empty()) { |
219 // If we failed to construct install path. Give up. | 389 // If we failed to construct install path. Give up. |
220 *status = installer::OS_ERROR; | 390 *status = installer::OS_ERROR; |
221 InstallUtil::WriteInstallerResult(system_level, | 391 InstallUtil::WriteInstallerResult(system_level, |
222 installer_state.state_key(), *status, IDS_INSTALL_OS_ERROR_BASE, | 392 installer_state->state_key(), *status, IDS_INSTALL_OS_ERROR_BASE, |
223 NULL); | 393 NULL); |
224 } else { | 394 } else { |
225 *status = installer::EXISTING_VERSION_LAUNCHED; | 395 *status = installer::EXISTING_VERSION_LAUNCHED; |
226 chrome_exe = chrome_exe.Append(installer::kChromeExe); | 396 chrome_exe = chrome_exe.Append(installer::kChromeExe); |
227 CommandLine cmd(chrome_exe); | 397 CommandLine cmd(chrome_exe); |
228 cmd.AppendSwitch(switches::kFirstRun); | 398 cmd.AppendSwitch(switches::kFirstRun); |
229 InstallUtil::WriteInstallerResult(system_level, | 399 InstallUtil::WriteInstallerResult(system_level, |
230 installer_state.state_key(), *status, 0, NULL); | 400 installer_state->state_key(), *status, 0, NULL); |
231 VLOG(1) << "Launching existing system-level chrome instead."; | 401 VLOG(1) << "Launching existing system-level chrome instead."; |
232 base::LaunchApp(cmd, false, false, NULL); | 402 base::LaunchApp(cmd, false, false, NULL); |
233 } | 403 } |
234 return false; | 404 return false; |
235 } | 405 } |
236 | 406 |
237 // If the following compile assert fires it means that the InstallStatus | 407 // If the following compile assert fires it means that the InstallStatus |
238 // enumeration changed which will break the contract between the old | 408 // enumeration changed which will break the contract between the old |
239 // chrome installed and the new setup.exe that is trying to upgrade. | 409 // chrome installed and the new setup.exe that is trying to upgrade. |
240 COMPILE_ASSERT(installer::SXS_OPTION_NOT_SUPPORTED == 33, | 410 COMPILE_ASSERT(installer::CONFLICTING_CHANNEL_EXISTS == 39, |
241 dont_change_enum); | 411 dont_change_enum); |
242 | 412 |
243 // This is an update, not an install. Omaha should know the difference | 413 // This is an update, not an install. Omaha should know the difference |
244 // and not show a dialog. | 414 // and not show a dialog. |
245 *status = system_level ? installer::USER_LEVEL_INSTALL_EXISTS : | 415 *status = system_level ? installer::USER_LEVEL_INSTALL_EXISTS : |
246 installer::SYSTEM_LEVEL_INSTALL_EXISTS; | 416 installer::SYSTEM_LEVEL_INSTALL_EXISTS; |
247 int str_id = system_level ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : | 417 int str_id = system_level ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : |
248 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; | 418 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; |
249 InstallUtil::WriteInstallerResult(system_level, | 419 InstallUtil::WriteInstallerResult(system_level, |
250 installer_state.state_key(), *status, str_id, NULL); | 420 installer_state->state_key(), *status, str_id, NULL); |
251 return false; | 421 return false; |
252 } | 422 } |
253 } | 423 } |
254 | 424 |
| 425 // See what products are already installed in multi mode. When we do multi |
| 426 // installs, we must upgrade all installations since they share the binaries. |
| 427 AddExistingMultiInstalls(original_state, installer_state); |
| 428 |
255 // If no previous installation of Chrome, make sure installation directory | 429 // If no previous installation of Chrome, make sure installation directory |
256 // either does not exist or can be deleted (i.e. is not locked by some other | 430 // either does not exist or can be deleted (i.e. is not locked by some other |
257 // process). | 431 // process). |
258 if (is_first_install) { | 432 if (is_first_install) { |
259 if (file_util::PathExists(installation.path()) && | 433 if (file_util::PathExists(installer_state->target_path()) && |
260 !file_util::Delete(installation.path(), true)) { | 434 !file_util::Delete(installer_state->target_path(), true)) { |
261 LOG(ERROR) << "Installation directory " << installation.path().value() | 435 LOG(ERROR) << "Installation directory " |
| 436 << installer_state->target_path().value() |
262 << " exists and can not be deleted."; | 437 << " exists and can not be deleted."; |
263 *status = installer::INSTALL_DIR_IN_USE; | 438 *status = installer::INSTALL_DIR_IN_USE; |
264 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; | 439 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; |
265 InstallUtil::WriteInstallerResult(system_level, | 440 InstallUtil::WriteInstallerResult(system_level, |
266 installer_state.state_key(), *status, str_id, NULL); | 441 installer_state->state_key(), *status, str_id, NULL); |
267 return false; | 442 return false; |
268 } | 443 } |
269 } | 444 } |
270 | 445 |
271 return true; | 446 return true; |
272 } | 447 } |
273 | 448 |
274 installer::InstallStatus InstallChrome(const InstallationState& original_state, | 449 installer::InstallStatus InstallProducts( |
275 const InstallerState& installer_state, | 450 const InstallationState& original_state, |
276 const CommandLine& cmd_line, const Package& installation, | 451 const CommandLine& cmd_line, |
277 const MasterPreferences& prefs) { | 452 const MasterPreferences& prefs, |
| 453 InstallerState* installer_state) { |
| 454 const bool system_install = installer_state->system_install(); |
278 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 455 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
279 if (!CheckPreInstallConditions(original_state, installer_state, installation, | 456 if (!CheckPreInstallConditions(original_state, installer_state, |
280 prefs, &install_status)) | 457 &install_status)) |
281 return install_status; | 458 return install_status; |
282 | 459 |
283 // For install the default location for chrome.packed.7z is in current | 460 // For install the default location for chrome.packed.7z is in current |
284 // folder, so get that value first. | 461 // folder, so get that value first. |
285 FilePath archive(cmd_line.GetProgram().DirName().Append( | 462 FilePath archive(cmd_line.GetProgram().DirName().Append( |
286 installer::kChromeCompressedArchive)); | 463 installer::kChromeCompressedArchive)); |
287 | 464 |
288 // If --install-archive is given, get the user specified value | 465 // If --install-archive is given, get the user specified value |
289 if (cmd_line.HasSwitch(installer::switches::kInstallArchive)) { | 466 if (cmd_line.HasSwitch(installer::switches::kInstallArchive)) { |
290 archive = cmd_line.GetSwitchValuePath( | 467 archive = cmd_line.GetSwitchValuePath( |
291 installer::switches::kInstallArchive); | 468 installer::switches::kInstallArchive); |
292 } | 469 } |
293 VLOG(1) << "Archive found to install Chrome " << archive.value(); | 470 VLOG(1) << "Archive found to install Chrome " << archive.value(); |
294 const Products& products = installation.products(); | 471 const Products& products = installer_state->products(); |
295 | 472 |
296 // Create a temp folder where we will unpack Chrome archive. If it fails, | 473 // Create a temp folder where we will unpack Chrome archive. If it fails, |
297 // then we are doomed, so return immediately and no cleanup is required. | 474 // then we are doomed, so return immediately and no cleanup is required. |
298 FilePath temp_path; | 475 FilePath temp_path; |
299 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 476 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
300 LOG(ERROR) << "Could not create temporary path."; | 477 LOG(ERROR) << "Could not create temporary path."; |
301 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 478 InstallUtil::WriteInstallerResult(system_install, |
302 installer_state.state_key(), installer::TEMP_DIR_FAILED, | 479 installer_state->state_key(), installer::TEMP_DIR_FAILED, |
303 IDS_INSTALL_TEMP_DIR_FAILED_BASE, NULL); | 480 IDS_INSTALL_TEMP_DIR_FAILED_BASE, NULL); |
304 return installer::TEMP_DIR_FAILED; | 481 return installer::TEMP_DIR_FAILED; |
305 } | 482 } |
306 VLOG(1) << "created path " << temp_path.value(); | 483 VLOG(1) << "created path " << temp_path.value(); |
307 | 484 |
308 FilePath unpack_path(temp_path.Append(installer::kInstallSourceDir)); | 485 FilePath unpack_path(temp_path.Append(installer::kInstallSourceDir)); |
309 bool incremental_install = false; | 486 bool incremental_install = false; |
310 if (UnPackArchive(archive, installation, temp_path, unpack_path, | 487 if (UnPackArchive(archive, *installer_state, temp_path, unpack_path, |
311 incremental_install)) { | 488 incremental_install)) { |
312 install_status = installer::UNCOMPRESSION_FAILED; | 489 install_status = installer::UNCOMPRESSION_FAILED; |
313 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 490 InstallUtil::WriteInstallerResult(system_install, |
314 installer_state.state_key(), install_status, | 491 installer_state->state_key(), install_status, |
315 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); | 492 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); |
316 } else { | 493 } else { |
317 VLOG(1) << "unpacked to " << unpack_path.value(); | 494 VLOG(1) << "unpacked to " << unpack_path.value(); |
318 FilePath src_path(unpack_path.Append(installer::kInstallSourceChromeDir)); | 495 FilePath src_path(unpack_path.Append(installer::kInstallSourceChromeDir)); |
319 scoped_ptr<Version> | 496 scoped_ptr<Version> |
320 installer_version(installer::GetVersionFromArchiveDir(src_path)); | 497 installer_version(installer::GetVersionFromArchiveDir(src_path)); |
321 if (!installer_version.get()) { | 498 if (!installer_version.get()) { |
322 LOG(ERROR) << "Did not find any valid version in installer."; | 499 LOG(ERROR) << "Did not find any valid version in installer."; |
323 install_status = installer::INVALID_ARCHIVE; | 500 install_status = installer::INVALID_ARCHIVE; |
324 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 501 InstallUtil::WriteInstallerResult(system_install, |
325 installer_state.state_key(), install_status, | 502 installer_state->state_key(), install_status, |
326 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 503 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
327 } else { | 504 } else { |
328 // TODO(tommi): Move towards having only a single version that is common | 505 // TODO(tommi): Move towards having only a single version that is common |
329 // to all products. Only the package should have a version since it | 506 // to all products. Only the package should have a version since it |
330 // represents all the binaries. When a single product is upgraded, all | 507 // represents all the binaries. When a single product is upgraded, all |
331 // currently installed product for the shared binary installation, should | 508 // currently installed product for the shared binary installation, should |
332 // (or rather must) be upgraded. | 509 // (or rather must) be upgraded. |
333 VLOG(1) << "version to install: " << installer_version->GetString(); | 510 VLOG(1) << "version to install: " << installer_version->GetString(); |
334 bool higher_version_installed = false; | 511 bool higher_version_installed = false; |
335 for (size_t i = 0; i < installation.products().size(); ++i) { | 512 for (size_t i = 0; i < installer_state->products().size(); ++i) { |
336 const Product* product = installation.products()[i]; | 513 const Product* product = installer_state->products()[i]; |
337 const ProductState* product_state = | 514 const ProductState* product_state = |
338 original_state.GetProductState(installer_state.system_install(), | 515 original_state.GetProductState(system_install, |
339 product->distribution()->GetType()); | 516 product->distribution()->GetType()); |
340 if (product_state != NULL && | 517 if (product_state != NULL && |
341 (product_state->version().CompareTo(*installer_version) > 0)) { | 518 (product_state->version().CompareTo(*installer_version) > 0)) { |
342 LOG(ERROR) << "Higher version is already installed."; | 519 LOG(ERROR) << "Higher version is already installed."; |
343 higher_version_installed = true; | 520 higher_version_installed = true; |
344 install_status = installer::HIGHER_VERSION_EXISTS; | 521 install_status = installer::HIGHER_VERSION_EXISTS; |
345 | 522 |
346 if (product->is_chrome()) { | 523 if (product->is_chrome()) { |
347 // TODO(robertshield): We should take the installer result text | 524 // TODO(robertshield): We should take the installer result text |
348 // strings from the Product. | 525 // strings from the Product. |
349 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 526 InstallUtil::WriteInstallerResult(system_install, |
350 installer_state.state_key(), install_status, | 527 installer_state->state_key(), install_status, |
351 IDS_INSTALL_HIGHER_VERSION_BASE, NULL); | 528 IDS_INSTALL_HIGHER_VERSION_BASE, NULL); |
352 } else { | 529 } else { |
353 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 530 InstallUtil::WriteInstallerResult(system_install, |
354 installer_state.state_key(), install_status, | 531 installer_state->state_key(), install_status, |
355 IDS_INSTALL_HIGHER_VERSION_CF_BASE, NULL); | 532 IDS_INSTALL_HIGHER_VERSION_CF_BASE, NULL); |
356 } | 533 } |
357 } | 534 } |
358 } | 535 } |
359 | 536 |
360 if (!higher_version_installed) { | 537 if (!higher_version_installed) { |
361 // We want to keep uncompressed archive (chrome.7z) that we get after | 538 // We want to keep uncompressed archive (chrome.7z) that we get after |
362 // uncompressing and binary patching. Get the location for this file. | 539 // uncompressing and binary patching. Get the location for this file. |
363 FilePath archive_to_copy(temp_path.Append(installer::kChromeArchive)); | 540 FilePath archive_to_copy(temp_path.Append(installer::kChromeArchive)); |
364 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( | 541 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( |
365 installer::switches::kInstallerData)); | 542 installer::switches::kInstallerData)); |
366 install_status = installer::InstallOrUpdateProduct(original_state, | 543 install_status = installer::InstallOrUpdateProduct(original_state, |
367 installer_state, cmd_line.GetProgram(), archive_to_copy, temp_path, | 544 *installer_state, cmd_line.GetProgram(), archive_to_copy, temp_path, |
368 prefs_source_path, prefs, *installer_version, installation); | 545 prefs_source_path, prefs, *installer_version); |
369 | 546 |
370 int install_msg_base = IDS_INSTALL_FAILED_BASE; | 547 int install_msg_base = IDS_INSTALL_FAILED_BASE; |
371 std::wstring chrome_exe; | 548 std::wstring chrome_exe; |
372 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { | 549 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { |
373 if (FindProduct(products, BrowserDistribution::CHROME_FRAME)) { | 550 if (installer_state->FindProduct(BrowserDistribution::CHROME_FRAME)) { |
374 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; | 551 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; |
375 } else { | 552 } else { |
376 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; | 553 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; |
377 } | 554 } |
378 } else if (install_status != installer::INSTALL_FAILED) { | 555 } else if (install_status != installer::INSTALL_FAILED) { |
379 if (installation.path().empty()) { | 556 if (installer_state->target_path().empty()) { |
380 // If we failed to construct install path, it means the OS call to | 557 // If we failed to construct install path, it means the OS call to |
381 // get %ProgramFiles% or %AppData% failed. Report this as failure. | 558 // get %ProgramFiles% or %AppData% failed. Report this as failure. |
382 install_msg_base = IDS_INSTALL_OS_ERROR_BASE; | 559 install_msg_base = IDS_INSTALL_OS_ERROR_BASE; |
383 install_status = installer::OS_ERROR; | 560 install_status = installer::OS_ERROR; |
384 } else { | 561 } else { |
385 chrome_exe = installation.path() | 562 chrome_exe = installer_state->target_path() |
386 .Append(installer::kChromeExe).value(); | 563 .Append(installer::kChromeExe).value(); |
387 chrome_exe = L"\"" + chrome_exe + L"\""; | 564 chrome_exe = L"\"" + chrome_exe + L"\""; |
388 install_msg_base = 0; | 565 install_msg_base = 0; |
389 } | 566 } |
390 } | 567 } |
391 | 568 |
392 const Product* chrome_install = | 569 // Only do Chrome-specific stuff (like launching the browser) if |
393 FindProduct(products, BrowserDistribution::CHROME_BROWSER); | 570 // Chrome was specifically requested (rather than being upgraded as |
| 571 // part of a multi-install). |
| 572 const Product* chrome_install = prefs.install_chrome() ? |
| 573 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER) : |
| 574 NULL; |
394 | 575 |
395 bool value = false; | 576 bool value = false; |
396 if (chrome_install) { | 577 if (chrome_install) { |
397 prefs.GetBool( | 578 prefs.GetBool( |
398 installer::master_preferences::kDoNotRegisterForUpdateLaunch, | 579 installer::master_preferences::kDoNotRegisterForUpdateLaunch, |
399 &value); | 580 &value); |
400 } else { | 581 } else { |
401 value = true; // Never register. | 582 value = true; // Never register. |
402 } | 583 } |
403 | 584 |
404 bool write_chrome_launch_string = (!value) && | 585 bool write_chrome_launch_string = (!value) && |
405 (install_status != installer::IN_USE_UPDATED); | 586 (install_status != installer::IN_USE_UPDATED); |
406 | 587 |
407 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 588 InstallUtil::WriteInstallerResult(system_install, |
408 installer_state.state_key(), install_status, install_msg_base, | 589 installer_state->state_key(), install_status, install_msg_base, |
409 write_chrome_launch_string ? &chrome_exe : NULL); | 590 write_chrome_launch_string ? &chrome_exe : NULL); |
410 | 591 |
411 if (install_status == installer::FIRST_INSTALL_SUCCESS) { | 592 if (install_status == installer::FIRST_INSTALL_SUCCESS) { |
412 VLOG(1) << "First install successful."; | 593 VLOG(1) << "First install successful."; |
413 if (chrome_install) { | 594 if (chrome_install) { |
414 // We never want to launch Chrome in system level install mode. | 595 // We never want to launch Chrome in system level install mode. |
415 bool do_not_launch_chrome = false; | 596 bool do_not_launch_chrome = false; |
416 prefs.GetBool( | 597 prefs.GetBool( |
417 installer::master_preferences::kDoNotLaunchChrome, | 598 installer::master_preferences::kDoNotLaunchChrome, |
418 &do_not_launch_chrome); | 599 &do_not_launch_chrome); |
419 if (!installation.system_level() && !do_not_launch_chrome) | 600 if (!system_install && !do_not_launch_chrome) |
420 chrome_install->LaunchChrome(); | 601 chrome_install->LaunchChrome(installer_state->target_path()); |
421 } | 602 } |
422 } else if ((install_status == installer::NEW_VERSION_UPDATED) || | 603 } else if ((install_status == installer::NEW_VERSION_UPDATED) || |
423 (install_status == installer::IN_USE_UPDATED)) { | 604 (install_status == installer::IN_USE_UPDATED)) { |
424 for (size_t i = 0; i < products.size(); ++i) { | 605 for (size_t i = 0; i < products.size(); ++i) { |
425 installer::RemoveLegacyRegistryKeys( | 606 installer::RemoveLegacyRegistryKeys( |
426 products[i]->distribution()); | 607 products[i]->distribution()); |
427 } | 608 } |
428 } | 609 } |
429 } | 610 } |
430 } | 611 } |
431 // There might be an experiment (for upgrade usually) that needs to happen. | 612 // There might be an experiment (for upgrade usually) that needs to happen. |
432 // An experiment's outcome can include chrome's uninstallation. If that is | 613 // An experiment's outcome can include chrome's uninstallation. If that is |
433 // the case we would not do that directly at this point but in another | 614 // the case we would not do that directly at this point but in another |
434 // instance of setup.exe | 615 // instance of setup.exe |
435 // | 616 // |
436 // There is another way to reach this same function if this is a system | 617 // There is another way to reach this same function if this is a system |
437 // level install. See HandleNonInstallCmdLineOptions(). | 618 // level install. See HandleNonInstallCmdLineOptions(). |
438 for (size_t i = 0; i < products.size(); ++i) { | 619 for (size_t i = 0; i < products.size(); ++i) { |
439 const Product* product = products[i]; | 620 const Product* product = products[i]; |
440 product->distribution()->LaunchUserExperiment(install_status, | 621 product->distribution()->LaunchUserExperiment(install_status, |
441 *installer_version, *product, installation.system_level()); | 622 *installer_version, *product, system_install); |
442 } | 623 } |
443 } | 624 } |
444 | 625 |
445 // Delete temporary files. These include install temporary directory | 626 // Delete temporary files. These include install temporary directory |
446 // and master profile file if present. Note that we do not care about rollback | 627 // and master profile file if present. Note that we do not care about rollback |
447 // here and we schedule for deletion on reboot below if the deletes fail. As | 628 // here and we schedule for deletion on reboot below if the deletes fail. As |
448 // such, we do not use DeleteTreeWorkItem. | 629 // such, we do not use DeleteTreeWorkItem. |
449 VLOG(1) << "Deleting temporary directory " << temp_path.value(); | 630 VLOG(1) << "Deleting temporary directory " << temp_path.value(); |
450 bool cleanup_success = file_util::Delete(temp_path, true); | 631 bool cleanup_success = file_util::Delete(temp_path, true); |
451 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 632 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
(...skipping 13 matching lines...) Expand all Loading... |
465 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 646 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
466 std::wstring prefs_path = cmd_line.GetSwitchValueNative( | 647 std::wstring prefs_path = cmd_line.GetSwitchValueNative( |
467 installer::switches::kInstallerData); | 648 installer::switches::kInstallerData); |
468 ScheduleDirectoryForDeletion(prefs_path.c_str()); | 649 ScheduleDirectoryForDeletion(prefs_path.c_str()); |
469 } | 650 } |
470 } | 651 } |
471 | 652 |
472 for (size_t i = 0; i < products.size(); ++i) { | 653 for (size_t i = 0; i < products.size(); ++i) { |
473 const Product* product = products[i]; | 654 const Product* product = products[i]; |
474 product->distribution()->UpdateInstallStatus( | 655 product->distribution()->UpdateInstallStatus( |
475 installer_state.system_install(), incremental_install, | 656 system_install, incremental_install, prefs.is_multi_install(), |
476 prefs.is_multi_install(), install_status); | 657 install_status); |
477 } | 658 } |
478 if (prefs.is_multi_install()) { | 659 if (installer_state->is_multi_install()) { |
479 installation.properties()->UpdateInstallStatus( | 660 installer_state->multi_package_binaries_distribution()->UpdateInstallStatus( |
480 installer_state.system_install(), incremental_install, true, | 661 system_install, incremental_install, true, install_status); |
481 install_status); | |
482 } | 662 } |
483 | 663 |
484 return install_status; | 664 return install_status; |
485 } | 665 } |
486 | 666 |
487 installer::InstallStatus UninstallProduct( | 667 installer::InstallStatus UninstallProduct( |
488 const InstallationState& original_state, | 668 const InstallationState& original_state, |
489 const InstallerState& installer_state, | 669 const InstallerState& installer_state, |
490 const CommandLine& cmd_line, | 670 const CommandLine& cmd_line, |
491 const Product& product) { | 671 const Product& product) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return installer::EULA_ACCEPTED_OPT_IN; | 712 return installer::EULA_ACCEPTED_OPT_IN; |
533 } | 713 } |
534 VLOG(1) << "EULA accepted (no opt-in)"; | 714 VLOG(1) << "EULA accepted (no opt-in)"; |
535 return installer::EULA_ACCEPTED; | 715 return installer::EULA_ACCEPTED; |
536 } | 716 } |
537 | 717 |
538 // This method processes any command line options that make setup.exe do | 718 // This method processes any command line options that make setup.exe do |
539 // various tasks other than installation (renaming chrome.exe, showing eula | 719 // various tasks other than installation (renaming chrome.exe, showing eula |
540 // among others). This function returns true if any such command line option | 720 // among others). This function returns true if any such command line option |
541 // has been found and processed (so setup.exe should exit at that point). | 721 // has been found and processed (so setup.exe should exit at that point). |
542 bool HandleNonInstallCmdLineOptions(const InstallerState& installer_state, | 722 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
543 const CommandLine& cmd_line, | 723 const CommandLine& cmd_line, |
544 const ProductPackageMapping& installs, | 724 const InstallerState& installer_state, |
545 int* exit_code) { | 725 int* exit_code) { |
546 DCHECK(installs.products().size()); | |
547 bool handled = true; | 726 bool handled = true; |
548 // TODO(tommi): Split these checks up into functions and use a data driven | 727 // TODO(tommi): Split these checks up into functions and use a data driven |
549 // map of switch->function. | 728 // map of switch->function. |
550 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { | 729 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { |
551 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; | 730 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; |
552 // If --update-setup-exe command line option is given, we apply the given | 731 // If --update-setup-exe command line option is given, we apply the given |
553 // patch to current exe, and store the resulting binary in the path | 732 // patch to current exe, and store the resulting binary in the path |
554 // specified by --new-setup-exe. But we need to first unpack the file | 733 // specified by --new-setup-exe. But we need to first unpack the file |
555 // given in --update-setup-exe. | 734 // given in --update-setup-exe. |
556 FilePath temp_path; | 735 FilePath temp_path; |
(...skipping 24 matching lines...) Expand all Loading... |
581 NULL); | 760 NULL); |
582 } | 761 } |
583 file_util::Delete(temp_path, true); | 762 file_util::Delete(temp_path, true); |
584 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { | 763 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { |
585 // Check if we need to show the EULA. If it is passed as a command line | 764 // Check if we need to show the EULA. If it is passed as a command line |
586 // then the dialog is shown and regardless of the outcome setup exits here. | 765 // then the dialog is shown and regardless of the outcome setup exits here. |
587 std::wstring inner_frame = | 766 std::wstring inner_frame = |
588 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 767 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
589 *exit_code = ShowEULADialog(inner_frame); | 768 *exit_code = ShowEULADialog(inner_frame); |
590 if (installer::EULA_REJECTED != *exit_code) | 769 if (installer::EULA_REJECTED != *exit_code) |
591 GoogleUpdateSettings::SetEULAConsent(*installs.packages()[0].get(), true); | 770 GoogleUpdateSettings::SetEULAConsent(installer_state, true); |
592 } else if (cmd_line.HasSwitch( | 771 } else if (cmd_line.HasSwitch( |
593 installer::switches::kRegisterChromeBrowser)) { | 772 installer::switches::kRegisterChromeBrowser)) { |
594 const Product* chrome_install = | 773 const Product* chrome_install = |
595 FindProduct(installs.products(), BrowserDistribution::CHROME_BROWSER); | 774 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
596 DCHECK(chrome_install); | |
597 if (chrome_install) { | 775 if (chrome_install) { |
598 // If --register-chrome-browser option is specified, register all | 776 // If --register-chrome-browser option is specified, register all |
599 // Chrome protocol/file associations as well as register it as a valid | 777 // Chrome protocol/file associations as well as register it as a valid |
600 // browser for Start Menu->Internet shortcut. This option should only | 778 // browser for Start Menu->Internet shortcut. This option should only |
601 // be used when setup.exe is launched with admin rights. We do not | 779 // be used when setup.exe is launched with admin rights. We do not |
602 // make any user specific changes in this option. | 780 // make any user specific changes in this option. |
603 std::wstring chrome_exe(cmd_line.GetSwitchValueNative( | 781 std::wstring chrome_exe(cmd_line.GetSwitchValueNative( |
604 installer::switches::kRegisterChromeBrowser)); | 782 installer::switches::kRegisterChromeBrowser)); |
605 std::wstring suffix; | 783 std::wstring suffix; |
606 if (cmd_line.HasSwitch( | 784 if (cmd_line.HasSwitch( |
607 installer::switches::kRegisterChromeBrowserSuffix)) { | 785 installer::switches::kRegisterChromeBrowserSuffix)) { |
608 suffix = cmd_line.GetSwitchValueNative( | 786 suffix = cmd_line.GetSwitchValueNative( |
609 installer::switches::kRegisterChromeBrowserSuffix); | 787 installer::switches::kRegisterChromeBrowserSuffix); |
610 } | 788 } |
611 *exit_code = ShellUtil::RegisterChromeBrowser( | 789 *exit_code = ShellUtil::RegisterChromeBrowser( |
612 chrome_install->distribution(), chrome_exe, suffix, false); | 790 chrome_install->distribution(), chrome_exe, suffix, false); |
613 } else { | 791 } else { |
614 LOG(ERROR) << "Can't register browser - Chrome distribution not found"; | 792 LOG(DFATAL) << "Can't register browser - Chrome distribution not found"; |
615 *exit_code = installer::UNKNOWN_STATUS; | 793 *exit_code = installer::UNKNOWN_STATUS; |
616 } | 794 } |
617 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { | 795 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { |
618 // If --rename-chrome-exe is specified, we want to rename the executables | 796 // If --rename-chrome-exe is specified, we want to rename the executables |
619 // and exit. | 797 // and exit. |
620 const Packages& packages = installs.packages(); | 798 *exit_code = RenameChromeExecutables(installer_state); |
621 DCHECK_EQ(1U, packages.size()); | |
622 for (size_t i = 0; i < packages.size(); ++i) | |
623 *exit_code = RenameChromeExecutables(*packages[i].get()); | |
624 } else if (cmd_line.HasSwitch( | 799 } else if (cmd_line.HasSwitch( |
625 installer::switches::kRemoveChromeRegistration)) { | 800 installer::switches::kRemoveChromeRegistration)) { |
626 // This is almost reverse of --register-chrome-browser option above. | 801 // This is almost reverse of --register-chrome-browser option above. |
627 // Here we delete Chrome browser registration. This option should only | 802 // Here we delete Chrome browser registration. This option should only |
628 // be used when setup.exe is launched with admin rights. We do not | 803 // be used when setup.exe is launched with admin rights. We do not |
629 // make any user specific changes in this option. | 804 // make any user specific changes in this option. |
630 std::wstring suffix; | 805 std::wstring suffix; |
631 if (cmd_line.HasSwitch( | 806 if (cmd_line.HasSwitch( |
632 installer::switches::kRegisterChromeBrowserSuffix)) { | 807 installer::switches::kRegisterChromeBrowserSuffix)) { |
633 suffix = cmd_line.GetSwitchValueNative( | 808 suffix = cmd_line.GetSwitchValueNative( |
634 installer::switches::kRegisterChromeBrowserSuffix); | 809 installer::switches::kRegisterChromeBrowserSuffix); |
635 } | 810 } |
636 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; | 811 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; |
637 const Product* chrome_install = | 812 const Product* chrome_install = |
638 FindProduct(installs.products(), BrowserDistribution::CHROME_BROWSER); | 813 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
639 DCHECK(chrome_install); | 814 DCHECK(chrome_install); |
640 if (chrome_install) { | 815 if (chrome_install) { |
641 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), | 816 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), |
642 HKEY_LOCAL_MACHINE, suffix, tmp); | 817 HKEY_LOCAL_MACHINE, suffix, tmp); |
643 } | 818 } |
644 *exit_code = tmp; | 819 *exit_code = tmp; |
645 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { | 820 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { |
646 // Launch the inactive user toast experiment. | 821 // Launch the inactive user toast experiment. |
647 int flavor = -1; | 822 int flavor = -1; |
648 base::StringToInt(cmd_line.GetSwitchValueNative( | 823 base::StringToInt(cmd_line.GetSwitchValueNative( |
649 installer::switches::kInactiveUserToast), &flavor); | 824 installer::switches::kInactiveUserToast), &flavor); |
650 DCHECK_NE(-1, flavor); | 825 DCHECK_NE(-1, flavor); |
651 if (flavor == -1) { | 826 if (flavor == -1) { |
652 *exit_code = installer::UNKNOWN_STATUS; | 827 *exit_code = installer::UNKNOWN_STATUS; |
653 } else { | 828 } else { |
654 const Products& products = installs.products(); | 829 const Products& products = installer_state.products(); |
655 for (size_t i = 0; i < products.size(); ++i) { | 830 for (size_t i = 0; i < products.size(); ++i) { |
656 const Product* product = products[i]; | 831 const Product* product = products[i]; |
657 BrowserDistribution* browser_dist = product->distribution(); | 832 BrowserDistribution* browser_dist = product->distribution(); |
658 browser_dist->InactiveUserToastExperiment(flavor, *product); | 833 browser_dist->InactiveUserToastExperiment(flavor, *product, |
| 834 installer_state.target_path()); |
659 } | 835 } |
660 } | 836 } |
661 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 837 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
662 const Products& products = installs.products(); | 838 const Products& products = installer_state.products(); |
663 for (size_t i = 0; i < products.size(); ++i) { | 839 for (size_t i = 0; i < products.size(); ++i) { |
664 const Product* product = products[i]; | 840 const Product* product = products[i]; |
665 BrowserDistribution* browser_dist = product->distribution(); | 841 BrowserDistribution* browser_dist = product->distribution(); |
666 // We started as system-level and have been re-launched as user level | 842 // We started as system-level and have been re-launched as user level |
667 // to continue with the toast experiment. | 843 // to continue with the toast experiment. |
668 scoped_ptr<Version> installed_version( | 844 scoped_ptr<Version> installed_version( |
669 InstallUtil::GetChromeVersion(browser_dist, installs.system_level())); | 845 InstallUtil::GetChromeVersion(browser_dist, |
| 846 installer_state.system_install())); |
670 browser_dist->LaunchUserExperiment(installer::REENTRY_SYS_UPDATE, | 847 browser_dist->LaunchUserExperiment(installer::REENTRY_SYS_UPDATE, |
671 *installed_version, *product, true); | 848 *installed_version, *product, true); |
672 } | 849 } |
673 } else if (cmd_line.HasSwitch( | 850 } else if (cmd_line.HasSwitch( |
674 installer::switches::kChromeFrameReadyModeOptIn)) { | 851 installer::switches::kChromeFrameReadyModeOptIn)) { |
675 *exit_code = InstallUtil::GetInstallReturnCode( | 852 *exit_code = InstallUtil::GetInstallReturnCode( |
676 installer::ChromeFrameReadyModeOptIn(installer_state, cmd_line)); | 853 installer::ChromeFrameReadyModeOptIn(original_state, installer_state)); |
677 } else if (cmd_line.HasSwitch( | 854 } else if (cmd_line.HasSwitch( |
678 installer::switches::kChromeFrameReadyModeTempOptOut)) { | 855 installer::switches::kChromeFrameReadyModeTempOptOut)) { |
679 *exit_code = InstallUtil::GetInstallReturnCode( | 856 *exit_code = InstallUtil::GetInstallReturnCode( |
680 installer::ChromeFrameReadyModeTempOptOut(cmd_line)); | 857 installer::ChromeFrameReadyModeTempOptOut(original_state, |
| 858 installer_state)); |
681 } else if (cmd_line.HasSwitch( | 859 } else if (cmd_line.HasSwitch( |
682 installer::switches::kChromeFrameReadyModeEndTempOptOut)) { | 860 installer::switches::kChromeFrameReadyModeEndTempOptOut)) { |
683 *exit_code = InstallUtil::GetInstallReturnCode( | 861 *exit_code = InstallUtil::GetInstallReturnCode( |
684 installer::ChromeFrameReadyModeEndTempOptOut(cmd_line)); | 862 installer::ChromeFrameReadyModeEndTempOptOut(original_state, |
| 863 installer_state)); |
685 } else { | 864 } else { |
686 handled = false; | 865 handled = false; |
687 } | 866 } |
688 | 867 |
689 return handled; | 868 return handled; |
690 } | 869 } |
691 | 870 |
692 bool ShowRebootDialog() { | 871 bool ShowRebootDialog() { |
693 // Get a token for this process. | 872 // Get a token for this process. |
694 HANDLE token; | 873 HANDLE token; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return false; | 915 return false; |
737 } | 916 } |
738 initialized_ = true; | 917 initialized_ = true; |
739 return true; | 918 return true; |
740 } | 919 } |
741 | 920 |
742 private: | 921 private: |
743 bool initialized_; | 922 bool initialized_; |
744 }; | 923 }; |
745 | 924 |
746 bool PopulateInstallations(bool for_uninstall, | |
747 const MasterPreferences& prefs, | |
748 ProductPackageMapping* installations) { | |
749 DCHECK(installations); | |
750 bool success = true; | |
751 | 925 |
752 bool implicit_chrome_install = false; | |
753 bool implicit_gcf_install = false; | |
754 | 926 |
755 // See what products are already installed in multi mode. | |
756 // When we do multi installs, we must upgrade all installations in sync since | |
757 // they share the binaries. Be careful to not do this when we're uninstalling | |
758 // a product. | |
759 if (prefs.is_multi_install() && !for_uninstall) { | |
760 struct CheckInstall { | |
761 bool* installed; | |
762 BrowserDistribution::Type type; | |
763 } product_checks[] = { | |
764 {&implicit_chrome_install, BrowserDistribution::CHROME_BROWSER}, | |
765 {&implicit_gcf_install, BrowserDistribution::CHROME_FRAME}, | |
766 }; | |
767 | 927 |
768 for (size_t i = 0; i < arraysize(product_checks); ++i) { | |
769 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | |
770 product_checks[i].type, prefs); | |
771 *product_checks[i].installed = installer::IsInstalledAsMulti( | |
772 installations->system_level(), dist); | |
773 LOG_IF(INFO, *product_checks[i].installed) | |
774 << "Product already installed and must be included: " | |
775 << dist->GetApplicationName(); | |
776 } | |
777 } | |
778 | |
779 if (prefs.install_chrome() || implicit_chrome_install) { | |
780 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") | |
781 << " distribution: Chrome"; | |
782 success = installations->AddDistribution( | |
783 BrowserDistribution::CHROME_BROWSER, prefs); | |
784 } | |
785 | |
786 if (success && (prefs.install_chrome_frame() || implicit_gcf_install)) { | |
787 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") | |
788 << " distribution: Chrome Frame"; | |
789 success = installations->AddDistribution( | |
790 BrowserDistribution::CHROME_FRAME, prefs); | |
791 } | |
792 return success; | |
793 } | |
794 | 928 |
795 // Returns the Custom information for the client identified by the exe path | 929 // Returns the Custom information for the client identified by the exe path |
796 // passed in. This information is used for crash reporting. | 930 // passed in. This information is used for crash reporting. |
797 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 931 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
798 std::wstring product; | 932 std::wstring product; |
799 std::wstring version; | 933 std::wstring version; |
800 scoped_ptr<FileVersionInfo> | 934 scoped_ptr<FileVersionInfo> |
801 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 935 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
802 if (version_info.get()) { | 936 if (version_info.get()) { |
803 version = version_info->product_version(); | 937 version = version_info->product_version(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 1010 |
877 VLOG(1) << "multi install is " << prefs.is_multi_install(); | 1011 VLOG(1) << "multi install is " << prefs.is_multi_install(); |
878 bool system_install = false; | 1012 bool system_install = false; |
879 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); | 1013 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); |
880 VLOG(1) << "system install is " << system_install; | 1014 VLOG(1) << "system install is " << system_install; |
881 | 1015 |
882 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | 1016 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
883 InitializeCrashReporting(system_install)); | 1017 InitializeCrashReporting(system_install)); |
884 | 1018 |
885 InstallationState original_state; | 1019 InstallationState original_state; |
886 original_state.Initialize(prefs); | 1020 original_state.Initialize(); |
887 | 1021 |
888 InstallerState installer_state; | 1022 InstallerState installer_state; |
889 installer_state.Initialize(prefs, original_state); | 1023 installer_state.Initialize(cmd_line, prefs, original_state); |
890 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); | 1024 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); |
891 | 1025 |
892 ProductPackageMapping installations(prefs.is_multi_install(), system_install); | |
893 if (!PopulateInstallations(is_uninstall, prefs, &installations)) { | |
894 // Currently this can only fail if one of the installations is a multi and | |
895 // a pre-existing single installation exists or vice versa. | |
896 installer::InstallStatus status = installer::NON_MULTI_INSTALLATION_EXISTS; | |
897 int string_id = IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE; | |
898 if (!prefs.is_multi_install()) { | |
899 status = installer::MULTI_INSTALLATION_EXISTS; | |
900 string_id = IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE; | |
901 } | |
902 LOG(ERROR) << "Failed to populate installations: " << status; | |
903 InstallUtil::WriteInstallerResult(system_install, | |
904 installer_state.state_key(), status, string_id, NULL); | |
905 return status; | |
906 } | |
907 | |
908 // Check to make sure current system is WinXP or later. If not, log | 1026 // Check to make sure current system is WinXP or later. If not, log |
909 // error message and get out. | 1027 // error message and get out. |
910 if (!InstallUtil::IsOSSupported()) { | 1028 if (!InstallUtil::IsOSSupported()) { |
911 LOG(ERROR) << "Chrome only supports Windows XP or later."; | 1029 LOG(ERROR) << "Chrome only supports Windows XP or later."; |
912 InstallUtil::WriteInstallerResult(system_install, | 1030 InstallUtil::WriteInstallerResult(system_install, |
913 installer_state.state_key(), installer::OS_NOT_SUPPORTED, | 1031 installer_state.state_key(), installer::OS_NOT_SUPPORTED, |
914 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); | 1032 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); |
915 return installer::OS_NOT_SUPPORTED; | 1033 return installer::OS_NOT_SUPPORTED; |
916 } | 1034 } |
917 | 1035 |
(...skipping 15 matching lines...) Expand all Loading... |
933 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || | 1051 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || |
934 cmd_line.HasSwitch( | 1052 cmd_line.HasSwitch( |
935 installer::switches::kRemoveChromeRegistration) || | 1053 installer::switches::kRemoveChromeRegistration) || |
936 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || | 1054 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || |
937 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 1055 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
938 return installer::SXS_OPTION_NOT_SUPPORTED; | 1056 return installer::SXS_OPTION_NOT_SUPPORTED; |
939 } | 1057 } |
940 } | 1058 } |
941 | 1059 |
942 int exit_code = 0; | 1060 int exit_code = 0; |
943 if (HandleNonInstallCmdLineOptions(installer_state, cmd_line, installations, | 1061 if (HandleNonInstallCmdLineOptions(original_state, cmd_line, installer_state, |
944 &exit_code)) | 1062 &exit_code)) |
945 return exit_code; | 1063 return exit_code; |
946 | 1064 |
947 if (system_install && !IsUserAnAdmin()) { | 1065 if (system_install && !IsUserAnAdmin()) { |
948 if (base::win::GetVersion() >= base::win::VERSION_VISTA && | 1066 if (base::win::GetVersion() >= base::win::VERSION_VISTA && |
949 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { | 1067 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { |
950 CommandLine new_cmd(CommandLine::NO_PROGRAM); | 1068 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
951 new_cmd.AppendArguments(cmd_line, true); | 1069 new_cmd.AppendArguments(cmd_line, true); |
952 // Append --run-as-admin flag to let the new instance of setup.exe know | 1070 // Append --run-as-admin flag to let the new instance of setup.exe know |
953 // that we already tried to launch ourselves as admin. | 1071 // that we already tried to launch ourselves as admin. |
954 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); | 1072 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); |
955 DWORD exit_code = installer::UNKNOWN_STATUS; | 1073 DWORD exit_code = installer::UNKNOWN_STATUS; |
956 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 1074 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
957 return exit_code; | 1075 return exit_code; |
958 } else { | 1076 } else { |
959 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 1077 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
960 InstallUtil::WriteInstallerResult(system_install, | 1078 InstallUtil::WriteInstallerResult(system_install, |
961 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, | 1079 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, |
962 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); | 1080 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); |
963 return installer::INSUFFICIENT_RIGHTS; | 1081 return installer::INSUFFICIENT_RIGHTS; |
964 } | 1082 } |
965 } | 1083 } |
966 | 1084 |
967 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 1085 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
968 // If --uninstall option is given, uninstall chrome | 1086 // If --uninstall option is given, uninstall the identified product(s) |
969 if (is_uninstall) { | 1087 if (is_uninstall) { |
970 for (size_t i = 0; i < installations.products().size(); ++i) { | 1088 const Products& products = installer_state.products(); |
| 1089 for (size_t i = 0; i < products.size(); ++i) { |
971 install_status = UninstallProduct(original_state, installer_state, | 1090 install_status = UninstallProduct(original_state, installer_state, |
972 cmd_line, *installations.products()[i]); | 1091 cmd_line, *products[i]); |
973 } | 1092 } |
974 } else { | 1093 } else { |
975 // If --uninstall option is not specified, we assume it is install case. | 1094 // If --uninstall option is not specified, we assume it is install case. |
976 const Packages& packages = installations.packages(); | 1095 VLOG(1) << "Installing to " << installer_state.target_path().value(); |
977 VLOG(1) << "Installing to " << packages.size() << " target paths"; | 1096 install_status = InstallProducts(original_state, cmd_line, prefs, |
978 for (size_t i = 0; i < packages.size(); ++i) { | 1097 &installer_state); |
979 install_status = InstallChrome(original_state, installer_state, cmd_line, | |
980 *packages[i].get(), prefs); | |
981 } | |
982 } | 1098 } |
983 | 1099 |
984 const Product* cf_install = | 1100 const Product* cf_install = |
985 FindProduct(installations.products(), BrowserDistribution::CHROME_FRAME); | 1101 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
986 | 1102 |
987 if (cf_install && | 1103 if (cf_install && |
988 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { | 1104 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { |
989 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { | 1105 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { |
990 ShowRebootDialog(); | 1106 ShowRebootDialog(); |
991 } else if (is_uninstall) { | 1107 } else if (is_uninstall) { |
992 // Only show the message box if Chrome Frame was the only product being | 1108 // Only show the message box if Chrome Frame was the only product being |
993 // uninstalled. | 1109 // uninstalled. |
994 if (installations.products().size() == 1U) { | 1110 if (installer_state.products().size() == 1U) { |
995 ::MessageBoxW(NULL, | 1111 ::MessageBoxW(NULL, |
996 installer::GetLocalizedString( | 1112 installer::GetLocalizedString( |
997 IDS_UNINSTALL_COMPLETE_BASE).c_str(), | 1113 IDS_UNINSTALL_COMPLETE_BASE).c_str(), |
998 cf_install->distribution()->GetApplicationName().c_str(), | 1114 cf_install->distribution()->GetApplicationName().c_str(), |
999 MB_OK); | 1115 MB_OK); |
1000 } | 1116 } |
1001 } | 1117 } |
1002 } | 1118 } |
1003 | 1119 |
1004 int return_code = 0; | 1120 int return_code = 0; |
1005 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1121 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
1006 // rollback the action. If we're uninstalling we want to avoid this, so always | 1122 // rollback the action. If we're uninstalling we want to avoid this, so always |
1007 // report success, squashing any more informative return codes. | 1123 // report success, squashing any more informative return codes. |
1008 // TODO(tommi): Fix this loop when IsMsi has been moved out of the Product | 1124 if (!(installer_state.is_msi() && is_uninstall)) |
1009 // class. | 1125 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1010 for (size_t i = 0; i < installations.products().size(); ++i) { | 1126 // to pass through, since this is only returned on uninstall which is |
1011 const Product* product = installations.products()[i]; | 1127 // never invoked directly by Google Update. |
1012 if (!(product->IsMsi() && is_uninstall)) { | 1128 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1013 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | |
1014 // to pass through, since this is only returned on uninstall which is | |
1015 // never invoked directly by Google Update. | |
1016 return_code = InstallUtil::GetInstallReturnCode(install_status); | |
1017 } | |
1018 } | |
1019 | 1129 |
1020 VLOG(1) << "Installation complete, returning: " << return_code; | 1130 VLOG(1) << "Installation complete, returning: " << return_code; |
1021 | 1131 |
1022 return return_code; | 1132 return return_code; |
1023 } | 1133 } |
OLD | NEW |