Index: components/safe_browsing/password_protection/password_protection_service.cc |
diff --git a/components/safe_browsing/password_protection/password_protection_service.cc b/components/safe_browsing/password_protection/password_protection_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..670f6f637c8ae143669e841926297a1ee2b15155 |
--- /dev/null |
+++ b/components/safe_browsing/password_protection/password_protection_service.cc |
@@ -0,0 +1,44 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/safe_browsing/password_protection/password_protection_service.h" |
+ |
+#include "base/bind.h" |
+#include "base/callback.h" |
+#include "base/metrics/histogram_macros.h" |
+#include "components/safe_browsing_db/database_manager.h" |
+#include "content/public/browser/browser_thread.h" |
+ |
+using content::BrowserThread; |
+ |
+namespace safe_browsing { |
+ |
+PasswordProtectionService::PasswordProtectionService( |
+ const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager) |
+ : database_manager_(database_manager) {} |
vakh (use Gerrit instead)
2017/03/01 23:25:19
Can the constructor be called on any thread?
Jialiu Lin
2017/03/02 00:53:06
In theory, it will only be created on UI thread du
|
+ |
+PasswordProtectionService::~PasswordProtectionService() {} |
+ |
+void PasswordProtectionService::RecordPasswordReuse(const GURL& url) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(database_manager_); |
+ if (!url.is_valid()) |
+ return; |
+ |
+ BrowserThread::PostTaskAndReplyWithResult( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&SafeBrowsingDatabaseManager::MatchCsdWhitelistUrl, |
+ database_manager_, url), |
+ base::Bind(&PasswordProtectionService::OnMatchCsdWhiteListResult, this)); |
+} |
+ |
+void PasswordProtectionService::OnMatchCsdWhiteListResult( |
+ bool match_whitelist) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ UMA_HISTOGRAM_BOOLEAN( |
+ "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist", |
+ match_whitelist); |
+} |
+ |
+} // namespace safe_browsing |