Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/win/registry.h" | |
| 22 #include "base/win/shortcut.h" | 23 #include "base/win/shortcut.h" |
| 23 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
| 24 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/installer/setup/install_worker.h" | 27 #include "chrome/installer/setup/install_worker.h" |
| 27 #include "chrome/installer/setup/installer_crash_reporting.h" | 28 #include "chrome/installer/setup/installer_crash_reporting.h" |
| 28 #include "chrome/installer/setup/setup_constants.h" | 29 #include "chrome/installer/setup/setup_constants.h" |
| 29 #include "chrome/installer/setup/setup_util.h" | 30 #include "chrome/installer/setup/setup_util.h" |
| 30 #include "chrome/installer/setup/update_active_setup_version_work_item.h" | 31 #include "chrome/installer/setup/update_active_setup_version_work_item.h" |
| 31 #include "chrome/installer/util/beacons.h" | 32 #include "chrome/installer/util/beacons.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 std::vector<base::FilePath::StringType> components; | 281 std::vector<base::FilePath::StringType> components; |
| 281 file_path.GetComponents(&components); | 282 file_path.GetComponents(&components); |
| 282 if (components.size() <= num_components) | 283 if (components.size() <= num_components) |
| 283 return file_path; | 284 return file_path; |
| 284 base::FilePath truncated_file_path; | 285 base::FilePath truncated_file_path; |
| 285 for (size_t i = 0; i < num_components; ++i) | 286 for (size_t i = 0; i < num_components; ++i) |
| 286 truncated_file_path = truncated_file_path.Append(components[i]); | 287 truncated_file_path = truncated_file_path.Append(components[i]); |
| 287 return truncated_file_path; | 288 return truncated_file_path; |
| 288 } | 289 } |
| 289 | 290 |
| 291 base::string16 GetDowngradeVersionPath() { | |
| 292 return base::string16(L"Software\\Google\\Update\\ClientState\\") + | |
|
grt (UTC plus 2)
2016/05/19 03:24:18
use BrowserDistribution::GetStateKey() for this ra
zmin
2016/05/19 23:08:03
Done. Also changed in user_profiles_cleanup.cc
| |
| 293 base::string16(google_update::kChromeUpgradeCode); | |
| 294 } | |
| 295 | |
| 296 void AddDowngradeVersion(HKEY root, const base::Version* existing_version) { | |
|
grt (UTC plus 2)
2016/05/19 03:24:18
is it possible to do this work somewhere in AddIns
| |
| 297 DCHECK(existing_version); | |
| 298 base::win::RegKey key(root, GetDowngradeVersionPath().c_str(), | |
| 299 KEY_QUERY_VALUE | KEY_SET_VALUE); | |
| 300 if (!key.HasValue(google_update::kRegDowngradeVersion)) | |
| 301 key.WriteValue(google_update::kRegDowngradeVersion, | |
| 302 base::ASCIIToUTF16(existing_version->GetString()).c_str()); | |
| 303 } | |
| 304 | |
| 305 void RemoveDowngradeVersion(HKEY root, const base::Version& new_version) { | |
| 306 base::win::RegKey key(root, GetDowngradeVersionPath().c_str(), | |
| 307 KEY_QUERY_VALUE | KEY_SET_VALUE); | |
| 308 base::string16 downgrade_version; | |
| 309 if (key.ReadValue(google_update::kRegDowngradeVersion, &downgrade_version) == | |
| 310 ERROR_SUCCESS && | |
| 311 base::Version(base::UTF16ToASCII(downgrade_version)) <= new_version) | |
| 312 key.DeleteValue(google_update::kRegDowngradeVersion); | |
| 313 } | |
|
grt (UTC plus 2)
2016/05/19 03:24:18
nit: blank line after this
zmin
2016/05/19 23:08:03
Done.
| |
| 290 } // namespace | 314 } // namespace |
| 291 | 315 |
| 292 namespace installer { | 316 namespace installer { |
| 293 | 317 |
| 294 void UpdatePerUserShortcutsInLocation( | 318 void UpdatePerUserShortcutsInLocation( |
| 295 const ShellUtil::ShortcutLocation shortcut_location, | 319 const ShellUtil::ShortcutLocation shortcut_location, |
| 296 BrowserDistribution* dist, | 320 BrowserDistribution* dist, |
| 297 const base::FilePath& old_target_dir, | 321 const base::FilePath& old_target_dir, |
| 298 const base::FilePath& old_target_name_suffix, | 322 const base::FilePath& old_target_name_suffix, |
| 299 const base::FilePath& new_target_path) { | 323 const base::FilePath& new_target_path) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 // Chrome to become their default browser on the download page, we must | 682 // Chrome to become their default browser on the download page, we must |
| 659 // force it here because the master_preferences file will not get copied | 683 // force it here because the master_preferences file will not get copied |
| 660 // into the build. | 684 // into the build. |
| 661 bool force_chrome_default_for_user = false; | 685 bool force_chrome_default_for_user = false; |
| 662 if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || | 686 if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| 663 result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { | 687 result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| 664 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, | 688 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| 665 &force_chrome_default_for_user); | 689 &force_chrome_default_for_user); |
| 666 } | 690 } |
| 667 | 691 |
| 692 if (result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) | |
| 693 AddDowngradeVersion(installer_state.root_key(), existing_version.get()); | |
| 694 else if (result == NEW_VERSION_UPDATED || result == IN_USE_UPDATED) | |
| 695 RemoveDowngradeVersion(installer_state.root_key(), new_version); | |
| 696 | |
| 668 RegisterChromeOnMachine(installer_state, *chrome_product, | 697 RegisterChromeOnMachine(installer_state, *chrome_product, |
| 669 make_chrome_default || force_chrome_default_for_user); | 698 make_chrome_default || force_chrome_default_for_user); |
| 670 | 699 |
| 671 if (!installer_state.system_install()) { | 700 if (!installer_state.system_install()) { |
| 672 DCHECK_EQ(chrome_product->distribution(), | 701 DCHECK_EQ(chrome_product->distribution(), |
| 673 BrowserDistribution::GetDistribution()); | 702 BrowserDistribution::GetDistribution()); |
| 674 UpdateDefaultBrowserBeaconForPath( | 703 UpdateDefaultBrowserBeaconForPath( |
| 675 installer_state.target_path().Append(installer::kChromeExe)); | 704 installer_state.target_path().Append(installer::kChromeExe)); |
| 676 } | 705 } |
| 677 } | 706 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 // Read master_preferences copied beside chrome.exe at install. | 804 // Read master_preferences copied beside chrome.exe at install. |
| 776 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 805 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 777 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 806 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 778 CreateOrUpdateShortcuts( | 807 CreateOrUpdateShortcuts( |
| 779 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 808 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 780 | 809 |
| 781 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 810 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 782 } | 811 } |
| 783 | 812 |
| 784 } // namespace installer | 813 } // namespace installer |
| OLD | NEW |