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

Unified Diff: components/safe_browsing/password_protection/password_protection_service.cc

Issue 2720643003: Call CSD whitelist checking on UI thread and record UMA (Closed)
Patch Set: change source_set name Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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..d0331fc4d30f12a84578b937d2c861b52006be93
--- /dev/null
+++ b/components/safe_browsing/password_protection/password_protection_service.cc
@@ -0,0 +1,49 @@
+// 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), weak_factory_(this) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
+
+PasswordProtectionService::~PasswordProtectionService() {
+ weak_factory_.InvalidateWeakPtrs();
+}
+
+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,
+ GetWeakPtr()));
+}
+
+void PasswordProtectionService::OnMatchCsdWhiteListResult(
+ bool match_whitelist) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ UMA_HISTOGRAM_BOOLEAN(
+ "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist",
+ match_whitelist);
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698