OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
| 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "components/safe_browsing_db/database_manager.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 |
| 13 using content::BrowserThread; |
| 14 |
| 15 namespace safe_browsing { |
| 16 |
| 17 PasswordProtectionService::PasswordProtectionService( |
| 18 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager) |
| 19 : database_manager_(database_manager), weak_factory_(this) { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 } |
| 22 |
| 23 PasswordProtectionService::~PasswordProtectionService() { |
| 24 weak_factory_.InvalidateWeakPtrs(); |
| 25 } |
| 26 |
| 27 void PasswordProtectionService::RecordPasswordReuse(const GURL& url) { |
| 28 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 29 DCHECK(database_manager_); |
| 30 if (!url.is_valid()) |
| 31 return; |
| 32 |
| 33 BrowserThread::PostTaskAndReplyWithResult( |
| 34 BrowserThread::IO, FROM_HERE, |
| 35 base::Bind(&SafeBrowsingDatabaseManager::MatchCsdWhitelistUrl, |
| 36 database_manager_, url), |
| 37 base::Bind(&PasswordProtectionService::OnMatchCsdWhiteListResult, |
| 38 GetWeakPtr())); |
| 39 } |
| 40 |
| 41 void PasswordProtectionService::OnMatchCsdWhiteListResult( |
| 42 bool match_whitelist) { |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 44 UMA_HISTOGRAM_BOOLEAN( |
| 45 "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist", |
| 46 match_whitelist); |
| 47 } |
| 48 |
| 49 } // namespace safe_browsing |
OLD | NEW |