OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <msi.h> | 6 #include <msi.h> |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 LOG(ERROR) << "Can not use differential update when Chrome is not " | 80 LOG(ERROR) << "Can not use differential update when Chrome is not " |
81 << "installed on the system."; | 81 << "installed on the system."; |
82 return installer_util::CHROME_NOT_INSTALLED; | 82 return installer_util::CHROME_NOT_INSTALLED; |
83 } | 83 } |
84 std::wstring existing_archive = | 84 std::wstring existing_archive = |
85 installer::GetChromeInstallPath(system_install); | 85 installer::GetChromeInstallPath(system_install); |
86 file_util::AppendToPath(&existing_archive, | 86 file_util::AppendToPath(&existing_archive, |
87 installed_version->GetString()); | 87 installed_version->GetString()); |
88 file_util::AppendToPath(&existing_archive, installer_util::kInstallerDir); | 88 file_util::AppendToPath(&existing_archive, installer_util::kInstallerDir); |
89 file_util::AppendToPath(&existing_archive, installer::kChromeArchive); | 89 file_util::AppendToPath(&existing_archive, installer::kChromeArchive); |
90 if (int i = setup_util::ApplyDiffPatch(existing_archive, unpacked_file, | 90 if (int i = setup_util::ApplyDiffPatch(FilePath(existing_archive), |
91 uncompressed_archive)) { | 91 FilePath(unpacked_file), |
92 FilePath(uncompressed_archive))) { | |
92 LOG(ERROR) << "Binary patching failed with error " << i; | 93 LOG(ERROR) << "Binary patching failed with error " << i; |
93 return i; | 94 return i; |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 // Unpack the uncompressed archive. | 98 // Unpack the uncompressed archive. |
98 return LzmaUtil::UnPackArchive(uncompressed_archive, path, &unpacked_file); | 99 return LzmaUtil::UnPackArchive(uncompressed_archive, path, &unpacked_file); |
99 } | 100 } |
100 | 101 |
101 | 102 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 bool system_level = false; | 221 bool system_level = false; |
221 installer_util::GetDistroBooleanPreference(prefs, | 222 installer_util::GetDistroBooleanPreference(prefs, |
222 installer_util::master_preferences::kSystemLevel, &system_level); | 223 installer_util::master_preferences::kSystemLevel, &system_level); |
223 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; | 224 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; |
224 if (!CheckPreInstallConditions(installed_version, | 225 if (!CheckPreInstallConditions(installed_version, |
225 system_level, install_status)) | 226 system_level, install_status)) |
226 return install_status; | 227 return install_status; |
227 | 228 |
228 // For install the default location for chrome.packed.7z is in current | 229 // For install the default location for chrome.packed.7z is in current |
229 // folder, so get that value first. | 230 // folder, so get that value first. |
230 std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program()); | 231 FilePath archive = |
viettrungluu
2010/10/14 19:51:27
Probably the way to break this line (to be consist
| |
231 file_util::AppendToPath(&archive, | 232 cmd_line.GetProgram().DirName() |
232 std::wstring(installer::kChromeCompressedArchive)); | 233 .Append(installer::kChromeCompressedArchive); |
233 | 234 |
234 // If --install-archive is given, get the user specified value | 235 // If --install-archive is given, get the user specified value |
235 if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) { | 236 if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) { |
236 archive = cmd_line.GetSwitchValueNative( | 237 archive = cmd_line.GetSwitchValuePath( |
237 installer_util::switches::kInstallArchive); | 238 installer_util::switches::kInstallArchive); |
238 } | 239 } |
239 LOG(INFO) << "Archive found to install Chrome " << archive; | 240 LOG(INFO) << "Archive found to install Chrome " << archive.value(); |
240 | 241 |
241 // Create a temp folder where we will unpack Chrome archive. If it fails, | 242 // Create a temp folder where we will unpack Chrome archive. If it fails, |
242 // then we are doomed, so return immediately and no cleanup is required. | 243 // then we are doomed, so return immediately and no cleanup is required. |
243 FilePath temp_path; | 244 FilePath temp_path; |
244 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 245 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
245 LOG(ERROR) << "Could not create temporary path."; | 246 LOG(ERROR) << "Could not create temporary path."; |
246 InstallUtil::WriteInstallerResult(system_level, | 247 InstallUtil::WriteInstallerResult(system_level, |
247 installer_util::TEMP_DIR_FAILED, | 248 installer_util::TEMP_DIR_FAILED, |
248 IDS_INSTALL_TEMP_DIR_FAILED_BASE, | 249 IDS_INSTALL_TEMP_DIR_FAILED_BASE, |
249 NULL); | 250 NULL); |
250 return installer_util::TEMP_DIR_FAILED; | 251 return installer_util::TEMP_DIR_FAILED; |
251 } | 252 } |
252 LOG(INFO) << "created path " << temp_path.value(); | 253 LOG(INFO) << "created path " << temp_path.value(); |
253 | 254 |
254 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 255 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
255 std::wstring unpack_path(temp_path.ToWStringHack()); | 256 std::wstring unpack_path(temp_path.ToWStringHack()); |
256 file_util::AppendToPath(&unpack_path, | 257 file_util::AppendToPath(&unpack_path, |
257 std::wstring(installer::kInstallSourceDir)); | 258 std::wstring(installer::kInstallSourceDir)); |
258 bool incremental_install = false; | 259 bool incremental_install = false; |
259 if (UnPackArchive(archive, system_level, installed_version, | 260 if (UnPackArchive(archive.value(), system_level, installed_version, |
260 temp_path.ToWStringHack(), unpack_path, | 261 temp_path.ToWStringHack(), unpack_path, |
261 incremental_install)) { | 262 incremental_install)) { |
262 install_status = installer_util::UNCOMPRESSION_FAILED; | 263 install_status = installer_util::UNCOMPRESSION_FAILED; |
263 InstallUtil::WriteInstallerResult(system_level, install_status, | 264 InstallUtil::WriteInstallerResult(system_level, install_status, |
264 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, | 265 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, |
265 NULL); | 266 NULL); |
266 } else { | 267 } else { |
267 LOG(INFO) << "unpacked to " << unpack_path; | 268 LOG(INFO) << "unpacked to " << unpack_path; |
268 std::wstring src_path(unpack_path); | 269 std::wstring src_path(unpack_path); |
269 file_util::AppendToPath(&src_path, | 270 file_util::AppendToPath(&src_path, |
270 std::wstring(installer::kInstallSourceChromeDir)); | 271 std::wstring(installer::kInstallSourceChromeDir)); |
271 scoped_ptr<installer::Version> | 272 scoped_ptr<installer::Version> |
272 installer_version(setup_util::GetVersionFromDir(src_path)); | 273 installer_version(setup_util::GetVersionFromDir(FilePath(src_path))); |
273 if (!installer_version.get()) { | 274 if (!installer_version.get()) { |
274 LOG(ERROR) << "Did not find any valid version in installer."; | 275 LOG(ERROR) << "Did not find any valid version in installer."; |
275 install_status = installer_util::INVALID_ARCHIVE; | 276 install_status = installer_util::INVALID_ARCHIVE; |
276 InstallUtil::WriteInstallerResult(system_level, install_status, | 277 InstallUtil::WriteInstallerResult(system_level, install_status, |
277 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 278 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
278 } else { | 279 } else { |
279 LOG(INFO) << "version to install: " << installer_version->GetString(); | 280 LOG(INFO) << "version to install: " << installer_version->GetString(); |
280 if (installed_version && | 281 if (installed_version && |
281 installed_version->IsHigherThan(installer_version.get())) { | 282 installed_version->IsHigherThan(installer_version.get())) { |
282 LOG(ERROR) << "Higher version is already installed."; | 283 LOG(ERROR) << "Higher version is already installed."; |
283 install_status = installer_util::HIGHER_VERSION_EXISTS; | 284 install_status = installer_util::HIGHER_VERSION_EXISTS; |
284 InstallUtil::WriteInstallerResult(system_level, install_status, | 285 InstallUtil::WriteInstallerResult(system_level, install_status, |
285 IDS_INSTALL_HIGHER_VERSION_BASE, | 286 IDS_INSTALL_HIGHER_VERSION_BASE, |
286 NULL); | 287 NULL); |
287 } else { | 288 } else { |
288 // We want to keep uncompressed archive (chrome.7z) that we get after | 289 // We want to keep uncompressed archive (chrome.7z) that we get after |
289 // uncompressing and binary patching. Get the location for this file. | 290 // uncompressing and binary patching. Get the location for this file. |
290 std::wstring archive_to_copy(temp_path.ToWStringHack()); | 291 FilePath archive_to_copy = temp_path.Append(installer::kChromeArchive); |
291 file_util::AppendToPath(&archive_to_copy, installer::kChromeArchive); | |
292 std::wstring prefs_source_path = cmd_line.GetSwitchValueNative( | 292 std::wstring prefs_source_path = cmd_line.GetSwitchValueNative( |
293 installer_util::switches::kInstallerData); | 293 installer_util::switches::kInstallerData); |
294 install_status = installer::InstallOrUpdateChrome( | 294 install_status = installer::InstallOrUpdateChrome( |
295 cmd_line.program(), archive_to_copy, temp_path.ToWStringHack(), | 295 cmd_line.GetProgram().value(), archive_to_copy.value(), |
296 temp_path.ToWStringHack(), | |
296 prefs_source_path, prefs, *installer_version, installed_version); | 297 prefs_source_path, prefs, *installer_version, installed_version); |
297 | 298 |
298 int install_msg_base = IDS_INSTALL_FAILED_BASE; | 299 int install_msg_base = IDS_INSTALL_FAILED_BASE; |
299 std::wstring chrome_exe; | 300 std::wstring chrome_exe; |
300 if (install_status == installer_util::SAME_VERSION_REPAIR_FAILED) { | 301 if (install_status == installer_util::SAME_VERSION_REPAIR_FAILED) { |
301 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; | 302 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; |
302 } else if (install_status != installer_util::INSTALL_FAILED) { | 303 } else if (install_status != installer_util::INSTALL_FAILED) { |
303 chrome_exe = installer::GetChromeInstallPath(system_level); | 304 chrome_exe = installer::GetChromeInstallPath(system_level); |
304 if (chrome_exe.empty()) { | 305 if (chrome_exe.empty()) { |
305 // If we failed to construct install path, it means the OS call to | 306 // If we failed to construct install path, it means the OS call to |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 LOG(ERROR) << "No Chrome installation found for uninstall."; | 392 LOG(ERROR) << "No Chrome installation found for uninstall."; |
392 InstallUtil::WriteInstallerResult(system_install, | 393 InstallUtil::WriteInstallerResult(system_install, |
393 installer_util::CHROME_NOT_INSTALLED, | 394 installer_util::CHROME_NOT_INSTALLED, |
394 IDS_UNINSTALL_FAILED_BASE, NULL); | 395 IDS_UNINSTALL_FAILED_BASE, NULL); |
395 return installer_util::CHROME_NOT_INSTALLED; | 396 return installer_util::CHROME_NOT_INSTALLED; |
396 } | 397 } |
397 | 398 |
398 bool remove_all = !cmd_line.HasSwitch( | 399 bool remove_all = !cmd_line.HasSwitch( |
399 installer_util::switches::kDoNotRemoveSharedItems); | 400 installer_util::switches::kDoNotRemoveSharedItems); |
400 | 401 |
401 return installer_setup::UninstallChrome(cmd_line.program(), system_install, | 402 return installer_setup::UninstallChrome(cmd_line.GetProgram().value(), |
403 system_install, | |
402 remove_all, force, | 404 remove_all, force, |
403 cmd_line, cmd_params); | 405 cmd_line, cmd_params); |
404 } | 406 } |
405 | 407 |
406 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { | 408 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { |
407 LOG(INFO) << "About to show EULA"; | 409 LOG(INFO) << "About to show EULA"; |
408 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); | 410 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); |
409 if (eula_path.empty()) { | 411 if (eula_path.empty()) { |
410 LOG(ERROR) << "No EULA path available"; | 412 LOG(ERROR) << "No EULA path available"; |
411 return installer_util::EULA_REJECTED; | 413 return installer_util::EULA_REJECTED; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 FilePath temp_path; | 449 FilePath temp_path; |
448 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 450 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
449 LOG(ERROR) << "Could not create temporary path."; | 451 LOG(ERROR) << "Could not create temporary path."; |
450 } else { | 452 } else { |
451 std::wstring setup_patch = cmd_line.GetSwitchValueNative( | 453 std::wstring setup_patch = cmd_line.GetSwitchValueNative( |
452 installer_util::switches::kUpdateSetupExe); | 454 installer_util::switches::kUpdateSetupExe); |
453 LOG(INFO) << "Opening archive " << setup_patch; | 455 LOG(INFO) << "Opening archive " << setup_patch; |
454 std::wstring uncompressed_patch; | 456 std::wstring uncompressed_patch; |
455 if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(), | 457 if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(), |
456 &uncompressed_patch) == NO_ERROR) { | 458 &uncompressed_patch) == NO_ERROR) { |
457 std::wstring old_setup_exe = cmd_line.program(); | 459 FilePath old_setup_exe = cmd_line.GetProgram(); |
458 std::wstring new_setup_exe = cmd_line.GetSwitchValueNative( | 460 FilePath new_setup_exe = cmd_line.GetSwitchValuePath( |
459 installer_util::switches::kNewSetupExe); | 461 installer_util::switches::kNewSetupExe); |
460 if (!setup_util::ApplyDiffPatch(old_setup_exe, uncompressed_patch, | 462 if (!setup_util::ApplyDiffPatch(old_setup_exe, |
463 FilePath(uncompressed_patch), | |
461 new_setup_exe)) | 464 new_setup_exe)) |
462 status = installer_util::NEW_VERSION_UPDATED; | 465 status = installer_util::NEW_VERSION_UPDATED; |
463 } | 466 } |
464 } | 467 } |
465 | 468 |
466 exit_code = dist->GetInstallReturnCode(status); | 469 exit_code = dist->GetInstallReturnCode(status); |
467 if (exit_code) { | 470 if (exit_code) { |
468 LOG(WARNING) << "setup.exe patching failed."; | 471 LOG(WARNING) << "setup.exe patching failed."; |
469 InstallUtil::WriteInstallerResult(system_install, status, | 472 InstallUtil::WriteInstallerResult(system_install, status, |
470 IDS_SETUP_PATCH_FAILED_BASE, NULL); | 473 IDS_SETUP_PATCH_FAILED_BASE, NULL); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 } | 672 } |
670 | 673 |
671 int exit_code = 0; | 674 int exit_code = 0; |
672 if (HandleNonInstallCmdLineOptions(parsed_command_line, system_install, | 675 if (HandleNonInstallCmdLineOptions(parsed_command_line, system_install, |
673 exit_code)) | 676 exit_code)) |
674 return exit_code; | 677 return exit_code; |
675 | 678 |
676 if (system_install && !IsUserAnAdmin()) { | 679 if (system_install && !IsUserAnAdmin()) { |
677 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && | 680 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && |
678 !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { | 681 !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { |
679 std::wstring exe = parsed_command_line.program(); | 682 std::wstring exe = parsed_command_line.GetProgram().value(); |
680 std::wstring params(command_line); | 683 std::wstring params(command_line); |
681 // Append --run-as-admin flag to let the new instance of setup.exe know | 684 // Append --run-as-admin flag to let the new instance of setup.exe know |
682 // that we already tried to launch ourselves as admin. | 685 // that we already tried to launch ourselves as admin. |
683 params.append(L" --"); | 686 params.append(L" --"); |
684 params.append(installer_util::switches::kRunAsAdmin); | 687 params.append(installer_util::switches::kRunAsAdmin); |
685 DWORD exit_code = installer_util::UNKNOWN_STATUS; | 688 DWORD exit_code = installer_util::UNKNOWN_STATUS; |
686 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); | 689 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); |
687 return exit_code; | 690 return exit_code; |
688 } else { | 691 } else { |
689 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 692 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { | 744 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { |
742 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT | 745 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT |
743 // to pass through, since this is only returned on uninstall which is never | 746 // to pass through, since this is only returned on uninstall which is never |
744 // invoked directly by Google Update. | 747 // invoked directly by Google Update. |
745 return_code = dist->GetInstallReturnCode(install_status); | 748 return_code = dist->GetInstallReturnCode(install_status); |
746 } | 749 } |
747 | 750 |
748 LOG(INFO) << "Installation complete, returning: " << return_code; | 751 LOG(INFO) << "Installation complete, returning: " << return_code; |
749 return return_code; | 752 return return_code; |
750 } | 753 } |
OLD | NEW |