| 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 "chrome/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
| 6 | 6 |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 #include <time.h> | 8 #include <time.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 16 #include "chrome/installer/setup/setup_constants.h" | 16 #include "chrome/installer/setup/setup_constants.h" |
| 17 #include "chrome/installer/util/browser_distribution.h" | 17 #include "chrome/installer/util/browser_distribution.h" |
| 18 #include "chrome/installer/util/create_reg_key_work_item.h" | 18 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 19 #include "chrome/installer/util/delete_after_reboot_helper.h" | 19 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 20 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| 21 #include "chrome/installer/util/helper.h" | 21 #include "chrome/installer/util/helper.h" |
| 22 #include "chrome/installer/util/install_util.h" | 22 #include "chrome/installer/util/install_util.h" |
| 23 #include "chrome/installer/util/master_preferences.h" | 23 #include "chrome/installer/util/master_preferences_constants.h" |
| 24 #include "chrome/installer/util/set_reg_value_work_item.h" | 24 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 25 #include "chrome/installer/util/shell_util.h" | 25 #include "chrome/installer/util/shell_util.h" |
| 26 #include "chrome/installer/util/util_constants.h" | 26 #include "chrome/installer/util/util_constants.h" |
| 27 #include "chrome/installer/util/work_item_list.h" | 27 #include "chrome/installer/util/work_item_list.h" |
| 28 | 28 |
| 29 // Build-time generated include file. | 29 // Build-time generated include file. |
| 30 #include "installer_util_strings.h" // NOLINT | 30 #include "installer_util_strings.h" // NOLINT |
| 31 #include "registered_dlls.h" // NOLINT | 31 #include "registered_dlls.h" // NOLINT |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 const std::wstring& install_path, const std::wstring& new_version) { | 722 const std::wstring& install_path, const std::wstring& new_version) { |
| 723 std::wstring installer_path(install_path); | 723 std::wstring installer_path(install_path); |
| 724 file_util::AppendToPath(&installer_path, new_version); | 724 file_util::AppendToPath(&installer_path, new_version); |
| 725 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir); | 725 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir); |
| 726 return installer_path; | 726 return installer_path; |
| 727 } | 727 } |
| 728 | 728 |
| 729 installer_util::InstallStatus installer::InstallOrUpdateChrome( | 729 installer_util::InstallStatus installer::InstallOrUpdateChrome( |
| 730 const std::wstring& exe_path, const std::wstring& archive_path, | 730 const std::wstring& exe_path, const std::wstring& archive_path, |
| 731 const std::wstring& install_temp_path, const std::wstring& prefs_path, | 731 const std::wstring& install_temp_path, const std::wstring& prefs_path, |
| 732 const DictionaryValue* prefs, const Version& new_version, | 732 const installer_util::MasterPreferences& prefs, const Version& new_version, |
| 733 const Version* installed_version) { | 733 const Version* installed_version) { |
| 734 bool system_install = false; | 734 bool system_install = false; |
| 735 installer_util::GetDistroBooleanPreference(prefs, | 735 prefs.GetBool(installer_util::master_preferences::kSystemLevel, |
| 736 installer_util::master_preferences::kSystemLevel, &system_install); | 736 &system_install); |
| 737 std::wstring install_path(GetChromeInstallPath(system_install)); | 737 std::wstring install_path(GetChromeInstallPath(system_install)); |
| 738 if (install_path.empty()) { | 738 if (install_path.empty()) { |
| 739 LOG(ERROR) << "Could not get installation destination path."; | 739 LOG(ERROR) << "Could not get installation destination path."; |
| 740 return installer_util::INSTALL_FAILED; | 740 return installer_util::INSTALL_FAILED; |
| 741 } | 741 } |
| 742 VLOG(1) << "install destination path: " << install_path; | 742 VLOG(1) << "install destination path: " << install_path; |
| 743 | 743 |
| 744 std::wstring src_path(install_temp_path); | 744 std::wstring src_path(install_temp_path); |
| 745 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); | 745 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); |
| 746 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir)); | 746 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir)); |
| 747 | 747 |
| 748 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 748 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 749 std::wstring current_version; | 749 std::wstring current_version; |
| 750 installer_util::InstallStatus result = InstallNewVersion(exe_path, | 750 installer_util::InstallStatus result = InstallNewVersion(exe_path, |
| 751 archive_path, src_path, install_path, install_temp_path, reg_root, | 751 archive_path, src_path, install_path, install_temp_path, reg_root, |
| 752 new_version, ¤t_version); | 752 new_version, ¤t_version); |
| 753 | 753 |
| 754 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 754 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 755 if (!dist->GetInstallReturnCode(result)) { | 755 if (!dist->GetInstallReturnCode(result)) { |
| 756 if (result == installer_util::FIRST_INSTALL_SUCCESS) | 756 if (result == installer_util::FIRST_INSTALL_SUCCESS) |
| 757 CopyPreferenceFileForFirstRun(system_install, prefs_path); | 757 CopyPreferenceFileForFirstRun(system_install, prefs_path); |
| 758 | 758 |
| 759 bool value = false; | 759 bool value = false; |
| 760 if (!installer_util::GetDistroBooleanPreference(prefs, | 760 if (!prefs.GetBool( |
| 761 installer_util::master_preferences::kDoNotCreateShortcuts, &value) || | 761 installer_util::master_preferences::kDoNotCreateShortcuts, |
| 762 !value) { | 762 &value) || !value) { |
| 763 bool create_all_shortcut = false; | 763 bool create_all_shortcut = false; |
| 764 installer_util::GetDistroBooleanPreference(prefs, | 764 prefs.GetBool(installer_util::master_preferences::kCreateAllShortcuts, |
| 765 installer_util::master_preferences::kCreateAllShortcuts, | 765 &create_all_shortcut); |
| 766 &create_all_shortcut); | |
| 767 bool alt_shortcut = false; | 766 bool alt_shortcut = false; |
| 768 installer_util::GetDistroBooleanPreference(prefs, | 767 prefs.GetBool(installer_util::master_preferences::kAltShortcutText, |
| 769 installer_util::master_preferences::kAltShortcutText, | 768 &alt_shortcut); |
| 770 &alt_shortcut); | |
| 771 if (!CreateOrUpdateChromeShortcuts(exe_path, install_path, | 769 if (!CreateOrUpdateChromeShortcuts(exe_path, install_path, |
| 772 new_version.GetString(), result, | 770 new_version.GetString(), result, |
| 773 system_install, create_all_shortcut, | 771 system_install, create_all_shortcut, |
| 774 alt_shortcut)) | 772 alt_shortcut)) { |
| 775 LOG(WARNING) << "Failed to create/update start menu shortcut."; | 773 LOG(WARNING) << "Failed to create/update start menu shortcut."; |
| 774 } |
| 776 | 775 |
| 777 bool make_chrome_default = false; | 776 bool make_chrome_default = false; |
| 778 installer_util::GetDistroBooleanPreference(prefs, | 777 prefs.GetBool(installer_util::master_preferences::kMakeChromeDefault, |
| 779 installer_util::master_preferences::kMakeChromeDefault, | 778 &make_chrome_default); |
| 780 &make_chrome_default); | |
| 781 | 779 |
| 782 // If this is not the user's first Chrome install, but they have chosen | 780 // If this is not the user's first Chrome install, but they have chosen |
| 783 // Chrome to become their default browser on the download page, we must | 781 // Chrome to become their default browser on the download page, we must |
| 784 // force it here because the master_preferences file will not get copied | 782 // force it here because the master_preferences file will not get copied |
| 785 // into the build. | 783 // into the build. |
| 786 bool force_chrome_default_for_user = false; | 784 bool force_chrome_default_for_user = false; |
| 787 if (result == installer_util::NEW_VERSION_UPDATED || | 785 if (result == installer_util::NEW_VERSION_UPDATED || |
| 788 result == installer_util::INSTALL_REPAIRED) { | 786 result == installer_util::INSTALL_REPAIRED) { |
| 789 installer_util::GetDistroBooleanPreference(prefs, | 787 prefs.GetBool( |
| 790 installer_util::master_preferences::kMakeChromeDefaultForUser, | 788 installer_util::master_preferences::kMakeChromeDefaultForUser, |
| 791 &force_chrome_default_for_user); | 789 &force_chrome_default_for_user); |
| 792 } | 790 } |
| 793 | 791 |
| 794 RegisterChromeOnMachine(install_path, system_install, | 792 RegisterChromeOnMachine(install_path, system_install, |
| 795 make_chrome_default || force_chrome_default_for_user); | 793 make_chrome_default || force_chrome_default_for_user); |
| 796 } | 794 } |
| 797 | 795 |
| 798 std::wstring latest_version_to_keep(new_version.GetString()); | 796 std::wstring latest_version_to_keep(new_version.GetString()); |
| 799 if (!current_version.empty()) | 797 if (!current_version.empty()) |
| 800 latest_version_to_keep.assign(current_version); | 798 latest_version_to_keep.assign(current_version); |
| 801 RemoveOldVersionDirs(install_path, latest_version_to_keep); | 799 RemoveOldVersionDirs(install_path, latest_version_to_keep); |
| 802 } | 800 } |
| 803 | 801 |
| 804 return result; | 802 return result; |
| 805 } | 803 } |
| OLD | NEW |