OLD | NEW |
---|---|
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/barrier_closure.h" | 13 #include "base/barrier_closure.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/metrics/histogram_macros.h" | |
18 #include "base/sequence_checker.h" | 19 #include "base/sequence_checker.h" |
19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
20 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/profile_resetter/profile_resetter.h" | 23 #include "chrome/browser/profile_resetter/profile_resetter.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" | 26 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" |
26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 kSettingsToReset, std::move(master_settings), | 159 kSettingsToReset, std::move(master_settings), |
159 base::Bind(&SettingsResetter::OnResetCompleted, this, profile)); | 160 base::Bind(&SettingsResetter::OnResetCompleted, this, profile)); |
160 } | 161 } |
161 | 162 |
162 void SettingsResetter::OnResetCompleted(Profile* profile) { | 163 void SettingsResetter::OnResetCompleted(Profile* profile) { |
163 DCHECK_LT(0, num_pending_resets_); | 164 DCHECK_LT(0, num_pending_resets_); |
164 | 165 |
165 RecordResetPending(false, profile); | 166 RecordResetPending(false, profile); |
166 | 167 |
167 --num_pending_resets_; | 168 --num_pending_resets_; |
168 if (!num_pending_resets_) | 169 if (!num_pending_resets_) { |
csharp
2017/07/07 17:32:51
nit: No need for the braces since this is a single
ftirelo
2017/07/07 20:27:53
Done.
| |
169 std::move(done_callback_).Run(); | 170 std::move(done_callback_).Run(); |
171 } | |
170 } | 172 } |
171 | 173 |
172 // Returns true if there is information of a completed cleanup in the registry. | 174 // Returns true if there is information of a completed cleanup in the registry. |
173 bool CleanupCompletedFromRegistry() { | 175 bool CleanupCompletedFromRegistry() { |
174 base::string16 cleaner_key_path( | 176 base::string16 cleaner_key_path( |
175 chrome_cleaner::kSoftwareRemovalToolRegistryKey); | 177 chrome_cleaner::kSoftwareRemovalToolRegistryKey); |
176 cleaner_key_path.append(L"\\").append(chrome_cleaner::kCleanerSubKey); | 178 cleaner_key_path.append(L"\\").append(chrome_cleaner::kCleanerSubKey); |
177 | 179 |
178 base::win::RegKey srt_cleaner_key(HKEY_CURRENT_USER, cleaner_key_path.c_str(), | 180 base::win::RegKey srt_cleaner_key(HKEY_CURRENT_USER, cleaner_key_path.c_str(), |
179 KEY_QUERY_VALUE); | 181 KEY_QUERY_VALUE); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) { | 215 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) { |
214 return base::MakeUnique<ProfileResetter>(profile); | 216 return base::MakeUnique<ProfileResetter>(profile); |
215 } | 217 } |
216 | 218 |
217 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) { | 219 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) { |
218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 220 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
219 DCHECK(IsEnabled()); | 221 DCHECK(IsEnabled()); |
220 DCHECK(profile); | 222 DCHECK(profile); |
221 | 223 |
222 RecordResetPending(true, profile); | 224 RecordResetPending(true, profile); |
225 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.TaggedProfileForResetting", true); | |
223 } | 226 } |
224 | 227 |
225 void PostCleanupSettingsResetter::ResetTaggedProfiles( | 228 void PostCleanupSettingsResetter::ResetTaggedProfiles( |
226 std::vector<Profile*> profiles, | 229 std::vector<Profile*> profiles, |
227 base::OnceClosure done_callback, | 230 base::OnceClosure done_callback, |
228 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) { | 231 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) { |
229 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 232 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
230 DCHECK(IsEnabled()); | 233 DCHECK(IsEnabled()); |
231 DCHECK(delegate); | 234 DCHECK(delegate); |
232 | 235 |
233 std::vector<Profile*> profiles_to_reset; | 236 std::vector<Profile*> profiles_to_reset; |
234 if (!CopyProfilesToReset(profiles, &profiles_to_reset) || | 237 if (!CopyProfilesToReset(profiles, &profiles_to_reset) || |
235 !CleanupCompletedFromRegistry()) { | 238 !CleanupCompletedFromRegistry()) { |
236 std::move(done_callback).Run(); | 239 std::move(done_callback).Run(); |
237 return; | 240 return; |
238 } | 241 } |
239 | 242 |
243 UMA_HISTOGRAM_EXACT_LINEAR("SoftwareReporter.PostCleanupSettingsReset", | |
244 profiles_to_reset.size()); | |
245 | |
240 // The SettingsResetter object will self-delete once |done_callback| is | 246 // The SettingsResetter object will self-delete once |done_callback| is |
241 // invoked. | 247 // invoked. |
242 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset), | 248 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset), |
243 std::move(delegate), | 249 std::move(delegate), |
244 std::move(done_callback))) | 250 std::move(done_callback))) |
245 ->Run(); | 251 ->Run(); |
246 } | 252 } |
247 | 253 |
248 // static | 254 // static |
249 void PostCleanupSettingsResetter::RegisterProfilePrefs( | 255 void PostCleanupSettingsResetter::RegisterProfilePrefs( |
250 user_prefs::PrefRegistrySyncable* registry) { | 256 user_prefs::PrefRegistrySyncable* registry) { |
251 DCHECK(registry); | 257 DCHECK(registry); |
252 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); | 258 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); |
253 } | 259 } |
254 | 260 |
255 } // namespace safe_browsing | 261 } // namespace safe_browsing |
OLD | NEW |