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

Side by Side 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 unified diff | Download patch
OLDNEW
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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 26 matching lines...) Expand all
37 #include "chrome/installer/util/installation_state.h" 37 #include "chrome/installer/util/installation_state.h"
38 #include "chrome/installer/util/l10n_string_util.h" 38 #include "chrome/installer/util/l10n_string_util.h"
39 #include "chrome/installer/util/util_constants.h" 39 #include "chrome/installer/util/util_constants.h"
40 #include "chrome/installer/util/work_item_list.h" 40 #include "chrome/installer/util/work_item_list.h"
41 41
42 using base::win::RegKey; 42 using base::win::RegKey;
43 using installer::ProductState; 43 using installer::ProductState;
44 44
45 namespace { 45 namespace {
46 46
47 const wchar_t kRegDowngradeVersion[] = L"DowngrdeVersion";
47 const wchar_t kStageBinaryPatching[] = L"binary_patching"; 48 const wchar_t kStageBinaryPatching[] = L"binary_patching";
48 const wchar_t kStageBuilding[] = L"building"; 49 const wchar_t kStageBuilding[] = L"building";
49 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; 50 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch";
50 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs"; 51 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs";
51 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts"; 52 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts";
52 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching"; 53 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching";
53 const wchar_t kStageExecuting[] = L"executing"; 54 const wchar_t kStageExecuting[] = L"executing";
54 const wchar_t kStageFinishing[] = L"finishing"; 55 const wchar_t kStageFinishing[] = L"finishing";
55 const wchar_t kStagePreconditions[] = L"preconditions"; 56 const wchar_t kStagePreconditions[] = L"preconditions";
56 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy"; 57 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy";
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 621 }
621 622
622 // Populate |info| for |file|, returning true on success. 623 // Populate |info| for |file|, returning true on success.
623 // static 624 // static
624 bool InstallUtil::ProgramCompare::GetInfo(const base::File& file, 625 bool InstallUtil::ProgramCompare::GetInfo(const base::File& file,
625 BY_HANDLE_FILE_INFORMATION* info) { 626 BY_HANDLE_FILE_INFORMATION* info) {
626 DCHECK(file.IsValid()); 627 DCHECK(file.IsValid());
627 return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0; 628 return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0;
628 } 629 }
629 630
631 // static
632 base::Version InstallUtil::GetDowngradeVersion(
633 HKEY root,
634 const BrowserDistribution* dist) {
635 DCHECK(dist);
636 base::win::RegKey key;
637 base::string16 downgrade_version;
638 if (key.Open(root, dist->GetStateKey().c_str(),
639 KEY_QUERY_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS ||
640 key.ReadValue(kRegDowngradeVersion, &downgrade_version) !=
641 ERROR_SUCCESS) {
642 return base::Version();
643 }
644 return base::Version(base::UTF16ToASCII(downgrade_version));
645 }
646
647 // static
648 void InstallUtil::AddUpdateDowngradeVersionItem(
649 HKEY root,
650 const base::Version& current_version,
651 const base::Version& new_version,
652 const BrowserDistribution* dist,
653 WorkItemList* list) {
654 DCHECK(list);
655 DCHECK(dist);
656 base::Version downgrade_version = GetDowngradeVersion(root, dist);
657 if (current_version > new_version && !downgrade_version.IsValid()) {
658 list->AddSetRegValueWorkItem(
659 root, dist->GetStateKey(), KEY_WOW64_32KEY, kRegDowngradeVersion,
660 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.
661 } 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
662 downgrade_version <= new_version) {
663 list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(), KEY_WOW64_32KEY,
664 kRegDowngradeVersion);
665 }
666 }
667
630 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) 668 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match)
631 : ProgramCompare(path_to_match, ComparisonType::FILE) {} 669 : ProgramCompare(path_to_match, ComparisonType::FILE) {}
632 670
633 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match, 671 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match,
634 ComparisonType comparison_type) 672 ComparisonType comparison_type)
635 : path_to_match_(path_to_match), 673 : path_to_match_(path_to_match),
636 file_info_(), 674 file_info_(),
637 comparison_type_(comparison_type) { 675 comparison_type_(comparison_type) {
638 DCHECK(!path_to_match_.empty()); 676 DCHECK(!path_to_match_.empty());
639 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) { 677 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 716
679 // Open the program and see if it references the expected file. 717 // Open the program and see if it references the expected file.
680 base::File file; 718 base::File file;
681 BY_HANDLE_FILE_INFORMATION info = {}; 719 BY_HANDLE_FILE_INFORMATION info = {};
682 720
683 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) && 721 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) &&
684 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && 722 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber &&
685 info.nFileIndexHigh == file_info_.nFileIndexHigh && 723 info.nFileIndexHigh == file_info_.nFileIndexHigh &&
686 info.nFileIndexLow == file_info_.nFileIndexLow); 724 info.nFileIndexLow == file_info_.nFileIndexLow);
687 } 725 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698