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

Unified Diff: chrome/installer/util/install_util.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: cr 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/util/install_util.cc
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 8b6dfa75deab255b214ff5e749ab7e76949ad6a7..726947bd87046a4ab067705d294b3e4e7aa47c69 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -44,6 +44,7 @@ using installer::ProductState;
namespace {
+const wchar_t kRegDowngradeVersion[] = L"DowngrdeVersion";
const wchar_t kStageBinaryPatching[] = L"binary_patching";
const wchar_t kStageBuilding[] = L"building";
const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch";
@@ -627,6 +628,43 @@ bool InstallUtil::ProgramCompare::GetInfo(const base::File& file,
return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0;
}
+// static
+base::Version InstallUtil::GetDowngradeVersion(
+ HKEY root,
+ const BrowserDistribution* dist) {
+ DCHECK(dist);
+ base::win::RegKey key;
+ base::string16 downgrade_version;
+ if (key.Open(root, dist->GetStateKey().c_str(),
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS ||
+ key.ReadValue(kRegDowngradeVersion, &downgrade_version) !=
+ ERROR_SUCCESS) {
+ return base::Version();
+ }
+ return base::Version(base::UTF16ToASCII(downgrade_version));
+}
+
+// static
+void InstallUtil::AddUpdateDowngradeVersionItem(
+ HKEY root,
+ const base::Version& current_version,
+ const base::Version& new_version,
+ const BrowserDistribution* dist,
+ WorkItemList* list) {
+ DCHECK(list);
+ DCHECK(dist);
+ base::Version downgrade_version = GetDowngradeVersion(root, dist);
+ if (current_version > new_version && !downgrade_version.IsValid()) {
+ list->AddSetRegValueWorkItem(
+ root, dist->GetStateKey(), KEY_WOW64_32KEY, kRegDowngradeVersion,
+ base::ASCIIToUTF16(current_version.GetString()), false);
grt (UTC plus 2) 2016/05/20 15:25:05 false -> true since you want to overwrite if there
zmin 2016/05/20 16:33:05 Done.
+ } else if (current_version < new_version && downgrade_version.IsValid() &&
grt (UTC plus 2) 2016/05/20 15:25:05 |downgrade_version| will be invalid if either the
zmin 2016/05/20 16:33:05 That means for every upgrade(even for the ppl neve
grt (UTC plus 2) 2016/05/20 18:17:05 the cost of the delete is insignificant. strange t
+ downgrade_version <= new_version) {
+ list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(), KEY_WOW64_32KEY,
+ kRegDowngradeVersion);
+ }
+}
+
InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match)
: ProgramCompare(path_to_match, ComparisonType::FILE) {}

Powered by Google App Engine
This is Rietveld 408576698