Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2309)

Unified Diff: chrome/installer/setup/install.cc

Issue 1986823002: Reset user data directory and disk cache directory after downgrade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add code in mini_installer Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/install.cc
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index af9662322892c2eaff4361005cd3f522f3cc7383..1251fa6900c22e1cea2cf31be140ce4084091f14 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -19,6 +19,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/win/registry.h"
#include "base/win/shortcut.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_constants.h"
@@ -287,6 +288,29 @@ base::FilePath TruncatePath(const base::FilePath& file_path,
return truncated_file_path;
}
+base::string16 GetDowngradeVersionPath() {
+ 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
+ base::string16(google_update::kChromeUpgradeCode);
+}
+
+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
+ DCHECK(existing_version);
+ base::win::RegKey key(root, GetDowngradeVersionPath().c_str(),
+ KEY_QUERY_VALUE | KEY_SET_VALUE);
+ if (!key.HasValue(google_update::kRegDowngradeVersion))
+ key.WriteValue(google_update::kRegDowngradeVersion,
+ base::ASCIIToUTF16(existing_version->GetString()).c_str());
+}
+
+void RemoveDowngradeVersion(HKEY root, const base::Version& new_version) {
+ base::win::RegKey key(root, GetDowngradeVersionPath().c_str(),
+ KEY_QUERY_VALUE | KEY_SET_VALUE);
+ base::string16 downgrade_version;
+ if (key.ReadValue(google_update::kRegDowngradeVersion, &downgrade_version) ==
+ ERROR_SUCCESS &&
+ base::Version(base::UTF16ToASCII(downgrade_version)) <= new_version)
+ key.DeleteValue(google_update::kRegDowngradeVersion);
+}
grt (UTC plus 2) 2016/05/19 03:24:18 nit: blank line after this
zmin 2016/05/19 23:08:03 Done.
} // namespace
namespace installer {
@@ -665,6 +689,11 @@ InstallStatus InstallOrUpdateProduct(
&force_chrome_default_for_user);
}
+ if (result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE)
+ AddDowngradeVersion(installer_state.root_key(), existing_version.get());
+ else if (result == NEW_VERSION_UPDATED || result == IN_USE_UPDATED)
+ RemoveDowngradeVersion(installer_state.root_key(), new_version);
+
RegisterChromeOnMachine(installer_state, *chrome_product,
make_chrome_default || force_chrome_default_for_user);

Powered by Google App Engine
This is Rietveld 408576698