Chromium Code Reviews| Index: chrome/installer/setup/install.cc |
| diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
| index fa288164c4e7f1f41909eda97527830f96ab2b52..66d1e17e1664e3f24453c0e5a4789b92b842aa91 100644 |
| --- a/chrome/installer/setup/install.cc |
| +++ b/chrome/installer/setup/install.cc |
| @@ -184,7 +184,8 @@ installer::InstallStatus InstallNewVersion( |
| const base::FilePath& src_path, |
| const base::FilePath& temp_path, |
| const Version& new_version, |
| - std::unique_ptr<Version>* current_version) { |
| + std::unique_ptr<Version>* current_version, |
| + const bool is_rollback_enabled) { |
|
Georges Khalil
2016/04/28 14:36:30
nit: change name to can_downgrade_version for cons
zmin
2016/04/28 15:02:30
Done.
|
| DCHECK(current_version); |
| installer_state.UpdateStage(installer::BUILDING); |
| @@ -236,8 +237,9 @@ installer::InstallStatus InstallNewVersion( |
| return installer::INSTALL_REPAIRED; |
| } |
| + bool is_new_chrome_exe_exists = base::PathExists(new_chrome_exe); |
| if (new_version > **current_version) { |
| - if (base::PathExists(new_chrome_exe)) { |
| + if (is_new_chrome_exe_exists) { |
| VLOG(1) << "Version updated to " << new_version |
| << " while running " << **current_version; |
| return installer::IN_USE_UPDATED; |
| @@ -246,6 +248,16 @@ installer::InstallStatus InstallNewVersion( |
| return installer::NEW_VERSION_UPDATED; |
| } |
| + if (is_rollback_enabled) { |
| + if (is_new_chrome_exe_exists) { |
| + VLOG(1) << "Version rollback to " << new_version << " while running " |
| + << **current_version; |
| + return installer::IN_USE_ROLLBACK; |
| + } |
| + VLOG(1) << "Version rollback to " << new_version; |
| + return installer::OLD_VERSION_ROLLBACK; |
| + } |
| + |
| LOG(ERROR) << "Not sure how we got here while updating" |
| << ", new version: " << new_version |
| << ", old version: " << **current_version; |
| @@ -582,9 +594,10 @@ InstallStatus InstallOrUpdateProduct( |
| CreateVisualElementsManifest(src_path, new_version); |
| std::unique_ptr<Version> existing_version; |
| - InstallStatus result = InstallNewVersion(original_state, installer_state, |
| - setup_path, archive_path, src_path, install_temp_path, new_version, |
| - &existing_version); |
| + InstallStatus result = |
| + InstallNewVersion(original_state, installer_state, setup_path, |
| + archive_path, src_path, install_temp_path, new_version, |
| + &existing_version, CanDowngradeVersion(prefs)); |
| // TODO(robertshield): Everything below this line should instead be captured |
| // by WorkItems. |
| @@ -646,8 +659,8 @@ InstallStatus InstallOrUpdateProduct( |
| // force it here because the master_preferences file will not get copied |
| // into the build. |
| bool force_chrome_default_for_user = false; |
| - if (result == NEW_VERSION_UPDATED || |
| - result == INSTALL_REPAIRED) { |
| + if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| + result == OLD_VERSION_ROLLBACK || result == IN_USE_ROLLBACK) { |
| prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| &force_chrome_default_for_user); |
| } |