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..43b77ec55233c0e4c5e3f25897c05a28617c3ebd 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, |
| + bool is_downgrade_allowed) { |
| DCHECK(current_version); |
| installer_state.UpdateStage(installer::BUILDING); |
| @@ -236,8 +237,9 @@ installer::InstallStatus InstallNewVersion( |
| return installer::INSTALL_REPAIRED; |
| } |
| + bool new_chrome_exe_exists = base::PathExists(new_chrome_exe); |
| if (new_version > **current_version) { |
| - if (base::PathExists(new_chrome_exe)) { |
| + if (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_downgrade_allowed) { |
| + if (new_chrome_exe_exists) { |
| + 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.
|
| + << **current_version; |
| + return installer::IN_USE_DOWNGRADE; |
| + } |
| + VLOG(1) << "Version downgrade to " << new_version; |
| + return installer::OLD_VERSION_DOWNGRADE; |
| + } |
| + |
| 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, IsDowngradeAllowed(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_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| &force_chrome_default_for_user); |
| } |