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/command_line.h" | |
14 #include "base/files/file_enumerator.h" | 15 #include "base/files/file_enumerator.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
20 #include "base/process/launch.h" | |
19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
21 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
22 #include "base/win/shortcut.h" | 24 #include "base/win/shortcut.h" |
23 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
24 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/installer/setup/install_worker.h" | 28 #include "chrome/installer/setup/install_worker.h" |
27 #include "chrome/installer/setup/installer_crash_reporting.h" | 29 #include "chrome/installer/setup/installer_crash_reporting.h" |
28 #include "chrome/installer/setup/setup_constants.h" | 30 #include "chrome/installer/setup/setup_constants.h" |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 make_chrome_default || force_chrome_default_for_user); | 675 make_chrome_default || force_chrome_default_for_user); |
674 | 676 |
675 if (!installer_state.system_install()) { | 677 if (!installer_state.system_install()) { |
676 DCHECK_EQ(chrome_product->distribution(), | 678 DCHECK_EQ(chrome_product->distribution(), |
677 BrowserDistribution::GetDistribution()); | 679 BrowserDistribution::GetDistribution()); |
678 UpdateDefaultBrowserBeaconForPath( | 680 UpdateDefaultBrowserBeaconForPath( |
679 installer_state.target_path().Append(installer::kChromeExe)); | 681 installer_state.target_path().Append(installer::kChromeExe)); |
680 } | 682 } |
681 } | 683 } |
682 | 684 |
685 // Delete files that belong to old versions of Chrome. If that fails during | |
686 // a not-in-use update, launch a --delete-old-version process. If this is an | |
687 // in-use update, a --delete-old-versions process will be launched when | |
688 // executables are renamed. | |
683 installer_state.SetStage(REMOVING_OLD_VERSIONS); | 689 installer_state.SetStage(REMOVING_OLD_VERSIONS); |
684 // TODO(fdoray): Launch a cleanup process when this fails during a not-in- | 690 if (!DeleteOldVersions(installer_state.target_path()) && |
685 // use update. crbug.com/451546 | 691 !base::PathExists( |
grt (UTC plus 2)
2016/09/13 08:10:40
rather than checking for new_chrome.exe again, you
fdoray
2016/09/13 21:34:54
Done.
| |
686 DeleteOldVersions(installer_state.target_path()); | 692 installer_state.target_path().Append(installer::kChromeNewExe))) { |
693 LaunchDeleteOldVersionsProcess(installer_state); | |
694 } | |
687 } | 695 } |
688 | 696 |
689 return result; | 697 return result; |
690 } | 698 } |
691 | 699 |
700 void LaunchDeleteOldVersionsProcess(const InstallerState& installer_state) { | |
701 base::LaunchOptions launch_options; | |
702 launch_options.start_hidden = true; | |
grt (UTC plus 2)
2016/09/13 08:10:40
i think it's prudent to use:
launch_options.forc
fdoray
2016/09/13 21:34:54
Done.
| |
703 // Make sure not to launch from a version directory. Otherwise, it won't be | |
704 // possible to delete it. | |
705 launch_options.current_directory = installer_state.target_path(); | |
706 base::CommandLine command_line(base::MakeAbsoluteFilePath( | |
707 base::CommandLine::ForCurrentProcess()->GetProgram())); | |
grt (UTC plus 2)
2016/09/13 08:10:40
the currently running setup.exe during an update i
fdoray
2016/09/13 21:34:54
Done.
| |
708 command_line.AppendSwitch(switches::kDeleteOldVersions); | |
grt (UTC plus 2)
2016/09/13 08:10:40
we generally try to use the command-line args that
fdoray
2016/09/13 21:34:54
Done.
| |
709 base::LaunchProcess(command_line, launch_options); | |
grt (UTC plus 2)
2016/09/13 08:10:40
logging around this would be useful. maybe:
VLOG
fdoray
2016/09/13 21:34:54
Done.
| |
710 } | |
711 | |
692 void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, | 712 void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, |
693 const installer::Product& chrome, | 713 const installer::Product& chrome, |
694 const base::Version& installed_version) { | 714 const base::Version& installed_version) { |
695 DCHECK(chrome.is_chrome()); | 715 DCHECK(chrome.is_chrome()); |
696 | 716 |
697 VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade."; | 717 VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade."; |
698 | 718 |
699 // Read master_preferences copied beside chrome.exe at install. | 719 // Read master_preferences copied beside chrome.exe at install. |
700 const MasterPreferences prefs( | 720 const MasterPreferences prefs( |
701 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); | 721 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 // Read master_preferences copied beside chrome.exe at install. | 800 // Read master_preferences copied beside chrome.exe at install. |
781 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 801 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
782 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 802 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
783 CreateOrUpdateShortcuts( | 803 CreateOrUpdateShortcuts( |
784 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 804 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
785 | 805 |
786 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 806 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
787 } | 807 } |
788 | 808 |
789 } // namespace installer | 809 } // namespace installer |
OLD | NEW |