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

Unified Diff: chrome/browser/safe_browsing/chrome_password_protection_service.cc

Issue 2783773002: Link PasswordProtectionService to Profile and SB Service (Closed)
Patch Set: nit Created 3 years, 9 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: chrome/browser/safe_browsing/chrome_password_protection_service.cc
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service.cc b/chrome/browser/safe_browsing/chrome_password_protection_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..412dd8a15c8fa091103e05969b802e11a5e4781e
--- /dev/null
+++ b/chrome/browser/safe_browsing/chrome_password_protection_service.cc
@@ -0,0 +1,79 @@
+// 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 "chrome/browser/safe_browsing/chrome_password_protection_service.h"
+
+#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
+#include "chrome/browser/history/history_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h"
+#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "components/safe_browsing_db/safe_browsing_prefs.h"
+
+using content::BrowserThread;
+
+namespace safe_browsing {
+
+namespace {
+// The number of user gestures we trace back for login event attribution.
+const int kPasswordEventAttributionUserGestureLimit = 2;
+}
+
+const base::Feature
+ ChromePasswordProtectionService::kPasswordProtectionPingOnly{
+ "PasswordProtectionPingOnly", base::FEATURE_DISABLED_BY_DEFAULT};
Nathan Parker 2017/03/30 21:38:12 Do you imagine we'd later add something like "Pass
Jialiu Lin 2017/03/30 23:23:04 Yes. that's my plan.
+
+ChromePasswordProtectionService::ChromePasswordProtectionService(
+ SafeBrowsingService* sb_service,
+ Profile* profile)
+ : PasswordProtectionService(
+ sb_service->database_manager(),
+ sb_service->url_request_context(),
+ HistoryServiceFactory::GetForProfile(
+ profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ HostContentSettingsMapFactory::GetForProfile(profile)),
+ profile_(profile),
+ navigation_observer_manager_(sb_service->navigation_observer_manager()) {
+ DCHECK(profile_);
+}
+
+ChromePasswordProtectionService::~ChromePasswordProtectionService() {}
+
+void ChromePasswordProtectionService::FillReferrerChain(
+ const GURL& event_url,
+ int event_tab_id,
+ LoginReputationClientRequest::Frame* frame) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ // TODO(jialiul): Update function name when https://crrev.com/2777853005
+ // is landed.
+ SafeBrowsingNavigationObserverManager::AttributionResult result =
+ navigation_observer_manager_->IdentifyReferrerChainForDownload(
+ event_url, event_tab_id, kPasswordEventAttributionUserGestureLimit,
+ frame->mutable_referrer_chain());
+ UMA_HISTOGRAM_COUNTS_100(
+ "SafeBrowsing.ReferrerURLChainSize.PasswordEventAttribution",
+ frame->referrer_chain().size());
+ UMA_HISTOGRAM_ENUMERATION(
+ "SafeBrowsing.ReferrerAttributionResult.PasswordEventAttribution", result,
+ SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
+}
+
+bool ChromePasswordProtectionService::IsExtendedReporting() {
+ DCHECK(profile_);
+ return IsExtendedReportingEnabled(*profile_->GetPrefs());
+}
+
+bool ChromePasswordProtectionService::IsIncognito() {
+ DCHECK(profile_);
+ return profile_->IsOffTheRecord();
+}
+
+bool ChromePasswordProtectionService::IsPingingEnabled() {
+ return base::FeatureList::IsEnabled(
+ ChromePasswordProtectionService::kPasswordProtectionPingOnly);
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698