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 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 // (typical new install), the function creates package during install | 177 // (typical new install), the function creates package during install |
| 178 // and removes the whole directory during rollback. | 178 // and removes the whole directory during rollback. |
| 179 installer::InstallStatus InstallNewVersion( | 179 installer::InstallStatus InstallNewVersion( |
| 180 const installer::InstallationState& original_state, | 180 const installer::InstallationState& original_state, |
| 181 const installer::InstallerState& installer_state, | 181 const installer::InstallerState& installer_state, |
| 182 const base::FilePath& setup_path, | 182 const base::FilePath& setup_path, |
| 183 const base::FilePath& archive_path, | 183 const base::FilePath& archive_path, |
| 184 const base::FilePath& src_path, | 184 const base::FilePath& src_path, |
| 185 const base::FilePath& temp_path, | 185 const base::FilePath& temp_path, |
| 186 const Version& new_version, | 186 const Version& new_version, |
| 187 std::unique_ptr<Version>* current_version) { | 187 std::unique_ptr<Version>* current_version, |
| 188 bool is_downgrade_allowed) { | |
| 188 DCHECK(current_version); | 189 DCHECK(current_version); |
| 189 | 190 |
| 190 installer_state.UpdateStage(installer::BUILDING); | 191 installer_state.UpdateStage(installer::BUILDING); |
| 191 | 192 |
| 192 current_version->reset(installer_state.GetCurrentVersion(original_state)); | 193 current_version->reset(installer_state.GetCurrentVersion(original_state)); |
| 193 installer::SetCurrentVersionCrashKey(current_version->get()); | 194 installer::SetCurrentVersionCrashKey(current_version->get()); |
| 194 | 195 |
| 195 std::unique_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 196 std::unique_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
| 196 | 197 |
| 197 AddInstallWorkItems(original_state, | 198 AddInstallWorkItems(original_state, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 if (!current_version->get()) { | 230 if (!current_version->get()) { |
| 230 VLOG(1) << "First install of version " << new_version; | 231 VLOG(1) << "First install of version " << new_version; |
| 231 return installer::FIRST_INSTALL_SUCCESS; | 232 return installer::FIRST_INSTALL_SUCCESS; |
| 232 } | 233 } |
| 233 | 234 |
| 234 if (new_version == **current_version) { | 235 if (new_version == **current_version) { |
| 235 VLOG(1) << "Install repaired of version " << new_version; | 236 VLOG(1) << "Install repaired of version " << new_version; |
| 236 return installer::INSTALL_REPAIRED; | 237 return installer::INSTALL_REPAIRED; |
| 237 } | 238 } |
| 238 | 239 |
| 240 bool new_chrome_exe_exists = base::PathExists(new_chrome_exe); | |
| 239 if (new_version > **current_version) { | 241 if (new_version > **current_version) { |
| 240 if (base::PathExists(new_chrome_exe)) { | 242 if (new_chrome_exe_exists) { |
| 241 VLOG(1) << "Version updated to " << new_version | 243 VLOG(1) << "Version updated to " << new_version |
| 242 << " while running " << **current_version; | 244 << " while running " << **current_version; |
| 243 return installer::IN_USE_UPDATED; | 245 return installer::IN_USE_UPDATED; |
| 244 } | 246 } |
| 245 VLOG(1) << "Version updated to " << new_version; | 247 VLOG(1) << "Version updated to " << new_version; |
| 246 return installer::NEW_VERSION_UPDATED; | 248 return installer::NEW_VERSION_UPDATED; |
| 247 } | 249 } |
| 248 | 250 |
| 251 if (is_downgrade_allowed) { | |
| 252 if (new_chrome_exe_exists) { | |
| 253 VLOG(1) << "Version downgrade to " << new_version << " while running " | |
|
grt (UTC plus 2)
2016/04/28 20:13:45
"downgraded" sounds more better to me
zmin
2016/04/28 20:20:37
Done.
| |
| 254 << **current_version; | |
| 255 return installer::IN_USE_DOWNGRADE; | |
| 256 } | |
| 257 VLOG(1) << "Version downgrade to " << new_version; | |
| 258 return installer::OLD_VERSION_DOWNGRADE; | |
| 259 } | |
| 260 | |
| 249 LOG(ERROR) << "Not sure how we got here while updating" | 261 LOG(ERROR) << "Not sure how we got here while updating" |
| 250 << ", new version: " << new_version | 262 << ", new version: " << new_version |
| 251 << ", old version: " << **current_version; | 263 << ", old version: " << **current_version; |
| 252 | 264 |
| 253 return installer::INSTALL_FAILED; | 265 return installer::INSTALL_FAILED; |
| 254 } | 266 } |
| 255 | 267 |
| 256 // Returns the number of components in |file_path|. | 268 // Returns the number of components in |file_path|. |
| 257 size_t GetNumPathComponents(const base::FilePath& file_path) { | 269 size_t GetNumPathComponents(const base::FilePath& file_path) { |
| 258 std::vector<base::FilePath::StringType> components; | 270 std::vector<base::FilePath::StringType> components; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) | 587 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) |
| 576 << "Error accessing pending moves value."; | 588 << "Error accessing pending moves value."; |
| 577 | 589 |
| 578 // Create VisualElementManifest.xml in |src_path| (if required) so that it | 590 // Create VisualElementManifest.xml in |src_path| (if required) so that it |
| 579 // looks as if it had been extracted from the archive when calling | 591 // looks as if it had been extracted from the archive when calling |
| 580 // InstallNewVersion() below. | 592 // InstallNewVersion() below. |
| 581 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST); | 593 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST); |
| 582 CreateVisualElementsManifest(src_path, new_version); | 594 CreateVisualElementsManifest(src_path, new_version); |
| 583 | 595 |
| 584 std::unique_ptr<Version> existing_version; | 596 std::unique_ptr<Version> existing_version; |
| 585 InstallStatus result = InstallNewVersion(original_state, installer_state, | 597 InstallStatus result = |
| 586 setup_path, archive_path, src_path, install_temp_path, new_version, | 598 InstallNewVersion(original_state, installer_state, setup_path, |
| 587 &existing_version); | 599 archive_path, src_path, install_temp_path, new_version, |
| 600 &existing_version, IsDowngradeAllowed(prefs)); | |
| 588 | 601 |
| 589 // TODO(robertshield): Everything below this line should instead be captured | 602 // TODO(robertshield): Everything below this line should instead be captured |
| 590 // by WorkItems. | 603 // by WorkItems. |
| 591 if (!InstallUtil::GetInstallReturnCode(result)) { | 604 if (!InstallUtil::GetInstallReturnCode(result)) { |
| 592 installer_state.UpdateStage(installer::UPDATING_CHANNELS); | 605 installer_state.UpdateStage(installer::UPDATING_CHANNELS); |
| 593 | 606 |
| 594 // Update the modifiers on the channel values for the product(s) being | 607 // Update the modifiers on the channel values for the product(s) being |
| 595 // installed and for the binaries in case of multi-install. | 608 // installed and for the binaries in case of multi-install. |
| 596 installer_state.UpdateChannels(); | 609 installer_state.UpdateChannels(); |
| 597 | 610 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 | 652 |
| 640 bool make_chrome_default = false; | 653 bool make_chrome_default = false; |
| 641 prefs.GetBool(master_preferences::kMakeChromeDefault, | 654 prefs.GetBool(master_preferences::kMakeChromeDefault, |
| 642 &make_chrome_default); | 655 &make_chrome_default); |
| 643 | 656 |
| 644 // If this is not the user's first Chrome install, but they have chosen | 657 // If this is not the user's first Chrome install, but they have chosen |
| 645 // Chrome to become their default browser on the download page, we must | 658 // Chrome to become their default browser on the download page, we must |
| 646 // force it here because the master_preferences file will not get copied | 659 // force it here because the master_preferences file will not get copied |
| 647 // into the build. | 660 // into the build. |
| 648 bool force_chrome_default_for_user = false; | 661 bool force_chrome_default_for_user = false; |
| 649 if (result == NEW_VERSION_UPDATED || | 662 if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| 650 result == INSTALL_REPAIRED) { | 663 result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| 651 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, | 664 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| 652 &force_chrome_default_for_user); | 665 &force_chrome_default_for_user); |
| 653 } | 666 } |
| 654 | 667 |
| 655 RegisterChromeOnMachine(installer_state, *chrome_product, | 668 RegisterChromeOnMachine(installer_state, *chrome_product, |
| 656 make_chrome_default || force_chrome_default_for_user); | 669 make_chrome_default || force_chrome_default_for_user); |
| 657 | 670 |
| 658 if (!installer_state.system_install()) { | 671 if (!installer_state.system_install()) { |
| 659 DCHECK_EQ(chrome_product->distribution(), | 672 DCHECK_EQ(chrome_product->distribution(), |
| 660 BrowserDistribution::GetDistribution()); | 673 BrowserDistribution::GetDistribution()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 // Read master_preferences copied beside chrome.exe at install. | 775 // Read master_preferences copied beside chrome.exe at install. |
| 763 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 776 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 764 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 777 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 765 CreateOrUpdateShortcuts( | 778 CreateOrUpdateShortcuts( |
| 766 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 779 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 767 | 780 |
| 768 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 781 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 769 } | 782 } |
| 770 | 783 |
| 771 } // namespace installer | 784 } // namespace installer |
| OLD | NEW |