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