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

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.cc

Issue 2952883002: Chrome Cleaner: Fix issue where a tagged profile could be reset multiple times (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.h" 5 #include "chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 Profile* profile, 89 Profile* profile,
90 std::unique_ptr<BrandcodedDefaultSettings> master_settings); 90 std::unique_ptr<BrandcodedDefaultSettings> master_settings);
91 91
92 // Removes the settings reset tag for |profile|. If there are no more 92 // Removes the settings reset tag for |profile|. If there are no more
93 // profiles to reset, invokes |done_callback_| and deletes this object. 93 // profiles to reset, invokes |done_callback_| and deletes this object.
94 void OnResetCompleted(Profile* profile); 94 void OnResetCompleted(Profile* profile);
95 95
96 // The profiles to be reset. 96 // The profiles to be reset.
97 std::vector<Profile*> profiles_to_reset_; 97 std::vector<Profile*> profiles_to_reset_;
98 98
99 // The ProfileResetter objects that are used to reset each profile. We need to
100 // hold on to these until each reset operation has been completed.
101 std::vector<std::unique_ptr<ProfileResetter>> profile_resetters_;
102
99 // The number of profiles that need to be reset. 103 // The number of profiles that need to be reset.
100 int num_pending_resets_; 104 int num_pending_resets_;
101 105
102 // The callback to be invoked once settings reset completes. 106 // The callback to be invoked once settings reset completes.
103 base::OnceClosure done_callback_; 107 base::OnceClosure done_callback_;
104 108
105 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate_; 109 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate_;
106 110
107 DISALLOW_COPY_AND_ASSIGN(SettingsResetter); 111 DISALLOW_COPY_AND_ASSIGN(SettingsResetter);
108 }; 112 };
(...skipping 24 matching lines...) Expand all
133 } 137 }
134 138
135 void SettingsResetter::OnFetchCompleted( 139 void SettingsResetter::OnFetchCompleted(
136 Profile* profile, 140 Profile* profile,
137 std::unique_ptr<BrandcodedDefaultSettings> master_settings) { 141 std::unique_ptr<BrandcodedDefaultSettings> master_settings) {
138 static const ProfileResetter::ResettableFlags kSettingsToReset = 142 static const ProfileResetter::ResettableFlags kSettingsToReset =
139 ProfileResetter::DEFAULT_SEARCH_ENGINE | ProfileResetter::HOMEPAGE | 143 ProfileResetter::DEFAULT_SEARCH_ENGINE | ProfileResetter::HOMEPAGE |
140 ProfileResetter::EXTENSIONS | ProfileResetter::STARTUP_PAGES | 144 ProfileResetter::EXTENSIONS | ProfileResetter::STARTUP_PAGES |
141 ProfileResetter::SHORTCUTS; 145 ProfileResetter::SHORTCUTS;
142 146
143 delegate_->GetProfileResetter(profile)->Reset( 147 profile_resetters_.push_back(delegate_->GetProfileResetter(profile));
148 profile_resetters_.back()->Reset(
ftirelo 2017/06/22 11:04:39 Would it make sense to DCHECK that this always hap
alito 2017/06/22 17:44:11 Done.
144 kSettingsToReset, std::move(master_settings), 149 kSettingsToReset, std::move(master_settings),
145 base::Bind(&SettingsResetter::OnResetCompleted, this, profile)); 150 base::Bind(&SettingsResetter::OnResetCompleted, this, profile));
146 } 151 }
147 152
148 void SettingsResetter::OnResetCompleted(Profile* profile) { 153 void SettingsResetter::OnResetCompleted(Profile* profile) {
149 DCHECK_LT(0, num_pending_resets_); 154 DCHECK_LT(0, num_pending_resets_);
150 155
151 RecordResetPending(false, profile); 156 RecordResetPending(false, profile);
152 157
153 --num_pending_resets_; 158 --num_pending_resets_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 237 }
233 238
234 // static 239 // static
235 void PostCleanupSettingsResetter::RegisterProfilePrefs( 240 void PostCleanupSettingsResetter::RegisterProfilePrefs(
236 user_prefs::PrefRegistrySyncable* registry) { 241 user_prefs::PrefRegistrySyncable* registry) {
237 DCHECK(registry); 242 DCHECK(registry);
238 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); 243 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false);
239 } 244 }
240 245
241 } // namespace safe_browsing 246 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698