| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) { | 214 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) { |
| 214 return base::MakeUnique<ProfileResetter>(profile); | 215 return base::MakeUnique<ProfileResetter>(profile); |
| 215 } | 216 } |
| 216 | 217 |
| 217 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) { | 218 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) { |
| 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 219 DCHECK(IsEnabled()); | 220 DCHECK(IsEnabled()); |
| 220 DCHECK(profile); | 221 DCHECK(profile); |
| 221 | 222 |
| 222 RecordResetPending(true, profile); | 223 RecordResetPending(true, profile); |
| 224 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.TaggedProfileForResetting", true); |
| 223 } | 225 } |
| 224 | 226 |
| 225 void PostCleanupSettingsResetter::ResetTaggedProfiles( | 227 void PostCleanupSettingsResetter::ResetTaggedProfiles( |
| 226 std::vector<Profile*> profiles, | 228 std::vector<Profile*> profiles, |
| 227 base::OnceClosure done_callback, | 229 base::OnceClosure done_callback, |
| 228 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) { | 230 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) { |
| 229 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 231 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 230 DCHECK(IsEnabled()); | 232 DCHECK(IsEnabled()); |
| 231 DCHECK(delegate); | 233 DCHECK(delegate); |
| 232 | 234 |
| 233 std::vector<Profile*> profiles_to_reset; | 235 std::vector<Profile*> profiles_to_reset; |
| 234 if (!CopyProfilesToReset(profiles, &profiles_to_reset) || | 236 if (!CopyProfilesToReset(profiles, &profiles_to_reset) || |
| 235 !CleanupCompletedFromRegistry()) { | 237 !CleanupCompletedFromRegistry()) { |
| 236 std::move(done_callback).Run(); | 238 std::move(done_callback).Run(); |
| 237 return; | 239 return; |
| 238 } | 240 } |
| 239 | 241 |
| 242 UMA_HISTOGRAM_EXACT_LINEAR("SoftwareReporter.PostCleanupSettingsReset", |
| 243 profiles_to_reset.size(), 10); |
| 244 |
| 240 // The SettingsResetter object will self-delete once |done_callback| is | 245 // The SettingsResetter object will self-delete once |done_callback| is |
| 241 // invoked. | 246 // invoked. |
| 242 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset), | 247 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset), |
| 243 std::move(delegate), | 248 std::move(delegate), |
| 244 std::move(done_callback))) | 249 std::move(done_callback))) |
| 245 ->Run(); | 250 ->Run(); |
| 246 } | 251 } |
| 247 | 252 |
| 248 // static | 253 // static |
| 249 void PostCleanupSettingsResetter::RegisterProfilePrefs( | 254 void PostCleanupSettingsResetter::RegisterProfilePrefs( |
| 250 user_prefs::PrefRegistrySyncable* registry) { | 255 user_prefs::PrefRegistrySyncable* registry) { |
| 251 DCHECK(registry); | 256 DCHECK(registry); |
| 252 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); | 257 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); |
| 253 } | 258 } |
| 254 | 259 |
| 255 } // namespace safe_browsing | 260 } // namespace safe_browsing |
| OLD | NEW |