| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <shlobj.h> | 5 #include <shlobj.h> |
| 6 #include <time.h> | 6 #include <time.h> |
| 7 | 7 |
| 8 #include "chrome/installer/setup/install.h" | 8 #include "chrome/installer/setup/install.h" |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 struct tm timeinfo = {0}; | 135 struct tm timeinfo = {0}; |
| 136 localtime_s(&timeinfo, &rawtime); | 136 localtime_s(&timeinfo, &rawtime); |
| 137 wchar_t buffer[9]; | 137 wchar_t buffer[9]; |
| 138 if (wcsftime(buffer, 9, L"%Y%m%d", &timeinfo) == 8) { | 138 if (wcsftime(buffer, 9, L"%Y%m%d", &timeinfo) == 8) { |
| 139 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 139 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
| 140 L"InstallDate", | 140 L"InstallDate", |
| 141 buffer, false); | 141 buffer, false); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Copy master preferences file provided to installer, in the same folder |
| 146 // as chrome.exe so Chrome first run can find it. This function will be called |
| 147 // only on the first install of Chrome. |
| 148 void CopyPreferenceFileForFirstRun(bool system_level, |
| 149 const std::wstring& prefs_source_path) { |
| 150 std::wstring prefs_dest_path( |
| 151 installer::GetChromeInstallPath(system_level)); |
| 152 file_util::AppendToPath(&prefs_dest_path, |
| 153 installer_util::kDefaultMasterPrefs); |
| 154 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) |
| 155 LOG(ERROR) << "failed copying master profile"; |
| 156 } |
| 157 |
| 145 // This method creates Chrome shortcuts in Start->Programs for all users or | 158 // This method creates Chrome shortcuts in Start->Programs for all users or |
| 146 // only for current user depending on whether it is system wide install or | 159 // only for current user depending on whether it is system wide install or |
| 147 // user only install. | 160 // user only install. |
| 148 // | 161 // |
| 149 // If first_install is true, it creates shortcuts for launching and | 162 // If first_install is true, it creates shortcuts for launching and |
| 150 // uninstalling chrome. | 163 // uninstalling chrome. |
| 151 // If first_install is false, the function only updates the shortcut for | 164 // If first_install is false, the function only updates the shortcut for |
| 152 // uninstalling chrome. According to | 165 // uninstalling chrome. According to |
| 153 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, | 166 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, |
| 154 // updating uninstall shortcut should not trigger Windows "new application | 167 // updating uninstall shortcut should not trigger Windows "new application |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (!success) { | 492 if (!success) { |
| 480 LOG(ERROR) << "Install failed, rolling back... "; | 493 LOG(ERROR) << "Install failed, rolling back... "; |
| 481 install_list->Rollback(); | 494 install_list->Rollback(); |
| 482 LOG(ERROR) << "Rollback complete. "; | 495 LOG(ERROR) << "Rollback complete. "; |
| 483 } | 496 } |
| 484 return success; | 497 return success; |
| 485 } | 498 } |
| 486 | 499 |
| 487 installer_util::InstallStatus installer::InstallOrUpdateChrome( | 500 installer_util::InstallStatus installer::InstallOrUpdateChrome( |
| 488 const std::wstring& exe_path, const std::wstring& archive_path, | 501 const std::wstring& exe_path, const std::wstring& archive_path, |
| 489 const std::wstring& install_temp_path, const DictionaryValue* prefs, | 502 const std::wstring& install_temp_path, const std::wstring& prefs_path, |
| 490 const Version& new_version, const Version* installed_version) { | 503 const DictionaryValue* prefs, const Version& new_version, |
| 504 const Version* installed_version) { |
| 491 bool system_install = installer_util::GetDistroBooleanPreference(prefs, | 505 bool system_install = installer_util::GetDistroBooleanPreference(prefs, |
| 492 installer_util::master_preferences::kSystemLevel); | 506 installer_util::master_preferences::kSystemLevel); |
| 493 std::wstring install_path(GetChromeInstallPath(system_install)); | 507 std::wstring install_path(GetChromeInstallPath(system_install)); |
| 494 if (install_path.empty()) { | 508 if (install_path.empty()) { |
| 495 LOG(ERROR) << "Could not get installation destination path."; | 509 LOG(ERROR) << "Could not get installation destination path."; |
| 496 return installer_util::INSTALL_FAILED; | 510 return installer_util::INSTALL_FAILED; |
| 497 } else { | 511 } else { |
| 498 LOG(INFO) << "install destination path: " << install_path; | 512 LOG(INFO) << "install destination path: " << install_path; |
| 499 } | 513 } |
| 500 | 514 |
| 501 std::wstring src_path(install_temp_path); | 515 std::wstring src_path(install_temp_path); |
| 502 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); | 516 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); |
| 503 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir)); | 517 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir)); |
| 504 | 518 |
| 505 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 519 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 506 bool install_success = InstallNewVersion(exe_path, archive_path, src_path, | 520 bool install_success = InstallNewVersion(exe_path, archive_path, src_path, |
| 507 install_path, install_temp_path, reg_root, new_version); | 521 install_path, install_temp_path, reg_root, new_version); |
| 508 | 522 |
| 509 installer_util::InstallStatus result; | 523 installer_util::InstallStatus result; |
| 510 if (!install_success) { | 524 if (!install_success) { |
| 511 LOG(ERROR) << "Install failed."; | 525 LOG(ERROR) << "Install failed."; |
| 512 result = installer_util::INSTALL_FAILED; | 526 result = installer_util::INSTALL_FAILED; |
| 513 } else { | 527 } else { |
| 514 if (!installed_version) { | 528 if (!installed_version) { |
| 515 LOG(INFO) << "First install of version " << new_version.GetString(); | 529 LOG(INFO) << "First install of version " << new_version.GetString(); |
| 516 result = installer_util::FIRST_INSTALL_SUCCESS; | 530 result = installer_util::FIRST_INSTALL_SUCCESS; |
| 531 CopyPreferenceFileForFirstRun(system_install, prefs_path); |
| 517 } else if (new_version.GetString() == installed_version->GetString()) { | 532 } else if (new_version.GetString() == installed_version->GetString()) { |
| 518 LOG(INFO) << "Install repaired of version " << new_version.GetString(); | 533 LOG(INFO) << "Install repaired of version " << new_version.GetString(); |
| 519 result = installer_util::INSTALL_REPAIRED; | 534 result = installer_util::INSTALL_REPAIRED; |
| 520 } else if (new_version.IsHigherThan(installed_version)) { | 535 } else if (new_version.IsHigherThan(installed_version)) { |
| 521 LOG(INFO) << "Version updated to " << new_version.GetString(); | 536 LOG(INFO) << "Version updated to " << new_version.GetString(); |
| 522 result = installer_util::NEW_VERSION_UPDATED; | 537 result = installer_util::NEW_VERSION_UPDATED; |
| 523 } else { | 538 } else { |
| 524 LOG(ERROR) << "Not sure how we got here." | 539 LOG(ERROR) << "Not sure how we got here." |
| 525 << " New version: " << new_version.GetString() | 540 << " New version: " << new_version.GetString() |
| 526 << ", installed version: " << installed_version->GetString(); | 541 << ", installed version: " << installed_version->GetString(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 551 } | 566 } |
| 552 | 567 |
| 553 std::wstring installer::GetInstallerPathUnderChrome( | 568 std::wstring installer::GetInstallerPathUnderChrome( |
| 554 const std::wstring& install_path, const std::wstring& new_version) { | 569 const std::wstring& install_path, const std::wstring& new_version) { |
| 555 std::wstring installer_path(install_path); | 570 std::wstring installer_path(install_path); |
| 556 file_util::AppendToPath(&installer_path, new_version); | 571 file_util::AppendToPath(&installer_path, new_version); |
| 557 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir); | 572 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir); |
| 558 return installer_path; | 573 return installer_path; |
| 559 } | 574 } |
| 560 | 575 |
| OLD | NEW |