| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <string> | 5 #include <string> |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #include <msi.h> | 7 #include <msi.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/registry.h" | 15 #include "base/registry.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/win_util.h" | 17 #include "base/win_util.h" |
| 18 #include "chrome/installer/setup/setup.h" | 18 #include "chrome/installer/setup/setup.h" |
| 19 #include "chrome/installer/setup/setup_constants.h" | 19 #include "chrome/installer/setup/setup_constants.h" |
| 20 #include "chrome/installer/setup/setup_util.h" |
| 20 #include "chrome/installer/setup/uninstall.h" | 21 #include "chrome/installer/setup/uninstall.h" |
| 21 #include "chrome/installer/util/browser_distribution.h" | 22 #include "chrome/installer/util/browser_distribution.h" |
| 22 #include "chrome/installer/util/delete_tree_work_item.h" | 23 #include "chrome/installer/util/delete_tree_work_item.h" |
| 23 #include "chrome/installer/util/helper.h" | 24 #include "chrome/installer/util/helper.h" |
| 24 #include "chrome/installer/util/html_dialog.h" | 25 #include "chrome/installer/util/html_dialog.h" |
| 25 #include "chrome/installer/util/install_util.h" | 26 #include "chrome/installer/util/install_util.h" |
| 26 #include "chrome/installer/util/l10n_string_util.h" | 27 #include "chrome/installer/util/l10n_string_util.h" |
| 27 #include "chrome/installer/util/logging_installer.h" | 28 #include "chrome/installer/util/logging_installer.h" |
| 28 #include "chrome/installer/util/lzma_util.h" | 29 #include "chrome/installer/util/lzma_util.h" |
| 29 #include "chrome/installer/util/google_update_settings.h" | 30 #include "chrome/installer/util/google_update_settings.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if ((ret = util.UnPack(path)) != NO_ERROR) { | 148 if ((ret = util.UnPack(path)) != NO_ERROR) { |
| 148 LOG(ERROR) << "Error during uncompression: " << ret; | 149 LOG(ERROR) << "Error during uncompression: " << ret; |
| 149 } | 150 } |
| 150 util.CloseArchive(); | 151 util.CloseArchive(); |
| 151 } | 152 } |
| 152 | 153 |
| 153 return ret; | 154 return ret; |
| 154 } | 155 } |
| 155 | 156 |
| 156 | 157 |
| 157 // Find the version of Chrome from an install source directory. | |
| 158 // Chrome_path should contain a complete and unpacked install package (i.e. | |
| 159 // a Chrome directory under which there is a version folder). | |
| 160 // Returns the version or NULL if no version is found. | |
| 161 installer::Version* GetVersionFromDir(const std::wstring& chrome_path) { | |
| 162 LOG(INFO) << "Looking for Chrome version folder under " << chrome_path; | |
| 163 std::wstring root_path(chrome_path); | |
| 164 file_util::AppendToPath(&root_path, L"*"); | |
| 165 | |
| 166 WIN32_FIND_DATA find_file_data; | |
| 167 HANDLE file_handle = FindFirstFile(root_path.c_str(), &find_file_data); | |
| 168 BOOL ret = TRUE; | |
| 169 installer::Version *version = NULL; | |
| 170 // Here we are assuming that the installer we have is really valid so there | |
| 171 // can not be two version directories. We exit as soon as we find a valid | |
| 172 // version directory. | |
| 173 while (ret) { | |
| 174 if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { | |
| 175 LOG(INFO) << "directory found: " << find_file_data.cFileName; | |
| 176 version = | |
| 177 installer::Version::GetVersionFromString(find_file_data.cFileName); | |
| 178 if (version) break; | |
| 179 } | |
| 180 ret = FindNextFile(file_handle, &find_file_data); | |
| 181 } | |
| 182 FindClose(file_handle); | |
| 183 | |
| 184 return version; | |
| 185 } | |
| 186 | |
| 187 // This function is called when --rename-chrome-exe option is specified on | 158 // This function is called when --rename-chrome-exe option is specified on |
| 188 // setup.exe command line. This function assumes an in-use update has happened | 159 // setup.exe command line. This function assumes an in-use update has happened |
| 189 // for Chrome so there should be a file called new_chrome.exe on the file | 160 // for Chrome so there should be a file called new_chrome.exe on the file |
| 190 // system and a key called 'opv' in the registry. This function will move | 161 // system and a key called 'opv' in the registry. This function will move |
| 191 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. | 162 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. |
| 192 installer_util::InstallStatus RenameChromeExecutables(bool system_install) { | 163 installer_util::InstallStatus RenameChromeExecutables(bool system_install) { |
| 193 std::wstring chrome_path(installer::GetChromeInstallPath(system_install)); | 164 std::wstring chrome_path(installer::GetChromeInstallPath(system_install)); |
| 194 | 165 |
| 195 std::wstring chrome_exe(chrome_path); | 166 std::wstring chrome_exe(chrome_path); |
| 196 file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe); | 167 file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 install_status = installer_util::UNCOMPRESSION_FAILED; | 349 install_status = installer_util::UNCOMPRESSION_FAILED; |
| 379 InstallUtil::WriteInstallerResult(system_install, install_status, | 350 InstallUtil::WriteInstallerResult(system_install, install_status, |
| 380 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, | 351 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, |
| 381 NULL); | 352 NULL); |
| 382 } else { | 353 } else { |
| 383 LOG(INFO) << "unpacked to " << unpack_path; | 354 LOG(INFO) << "unpacked to " << unpack_path; |
| 384 std::wstring src_path(unpack_path); | 355 std::wstring src_path(unpack_path); |
| 385 file_util::AppendToPath(&src_path, | 356 file_util::AppendToPath(&src_path, |
| 386 std::wstring(installer::kInstallSourceChromeDir)); | 357 std::wstring(installer::kInstallSourceChromeDir)); |
| 387 scoped_ptr<installer::Version> | 358 scoped_ptr<installer::Version> |
| 388 installer_version(GetVersionFromDir(src_path)); | 359 installer_version(setup_util::GetVersionFromDir(src_path)); |
| 389 if (!installer_version.get()) { | 360 if (!installer_version.get()) { |
| 390 LOG(ERROR) << "Did not find any valid version in installer."; | 361 LOG(ERROR) << "Did not find any valid version in installer."; |
| 391 install_status = installer_util::INVALID_ARCHIVE; | 362 install_status = installer_util::INVALID_ARCHIVE; |
| 392 InstallUtil::WriteInstallerResult(system_install, install_status, | 363 InstallUtil::WriteInstallerResult(system_install, install_status, |
| 393 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 364 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
| 394 } else { | 365 } else { |
| 395 LOG(INFO) << "version to install: " << installer_version->GetString(); | 366 LOG(INFO) << "version to install: " << installer_version->GetString(); |
| 396 if (installed_version && | 367 if (installed_version && |
| 397 installed_version->IsHigherThan(installer_version.get())) { | 368 installed_version->IsHigherThan(installer_version.get())) { |
| 398 LOG(ERROR) << "Higher version is already installed."; | 369 LOG(ERROR) << "Higher version is already installed."; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 } else { | 672 } else { |
| 702 install_status = InstallChrome(parsed_command_line, | 673 install_status = InstallChrome(parsed_command_line, |
| 703 installed_version.get(), | 674 installed_version.get(), |
| 704 options); | 675 options); |
| 705 } | 676 } |
| 706 | 677 |
| 707 CoUninitialize(); | 678 CoUninitialize(); |
| 708 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 679 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 709 return dist->GetInstallReturnCode(install_status); | 680 return dist->GetInstallReturnCode(install_status); |
| 710 } | 681 } |
| OLD | NEW |