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

Side by Side Diff: chrome/browser/safe_browsing/chrome_password_protection_service.cc

Issue 2783773002: Link PasswordProtectionService to Profile and SB Service (Closed)
Patch Set: rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(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 "chrome/browser/safe_browsing/chrome_password_protection_service.h"
6
7 #include "base/feature_list.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
14 #include "components/safe_browsing_db/safe_browsing_prefs.h"
15
16 using content::BrowserThread;
17
18 namespace safe_browsing {
19
20 namespace {
21 // The number of user gestures we trace back for login event attribution.
22 const int kPasswordEventAttributionUserGestureLimit = 2;
23 }
24
25 const base::Feature
Nathan Parker 2017/04/05 18:05:22 Nit: Could this be declared here rather than in th
Jialiu Lin 2017/04/05 18:48:25 Sure. Removed from .h
26 ChromePasswordProtectionService::kPasswordProtectionPingOnly{
27 "PasswordProtectionPingOnly", base::FEATURE_DISABLED_BY_DEFAULT};
28
29 ChromePasswordProtectionService::ChromePasswordProtectionService(
30 SafeBrowsingService* sb_service,
31 Profile* profile)
32 : PasswordProtectionService(
33 sb_service->database_manager(),
34 sb_service->url_request_context(),
35 HistoryServiceFactory::GetForProfile(
36 profile,
37 ServiceAccessType::EXPLICIT_ACCESS),
38 HostContentSettingsMapFactory::GetForProfile(profile)),
39 profile_(profile),
40 navigation_observer_manager_(sb_service->navigation_observer_manager()) {
41 DCHECK(profile_);
42 }
43
44 ChromePasswordProtectionService::~ChromePasswordProtectionService() {}
45
46 void ChromePasswordProtectionService::FillReferrerChain(
47 const GURL& event_url,
48 int event_tab_id,
49 LoginReputationClientRequest::Frame* frame) {
50 DCHECK_CURRENTLY_ON(BrowserThread::UI);
51 SafeBrowsingNavigationObserverManager::AttributionResult result =
52 navigation_observer_manager_->IdentifyReferrerChainByEventURL(
53 event_url, event_tab_id, kPasswordEventAttributionUserGestureLimit,
54 frame->mutable_referrer_chain());
55 UMA_HISTOGRAM_COUNTS_100(
56 "SafeBrowsing.ReferrerURLChainSize.PasswordEventAttribution",
57 frame->referrer_chain().size());
58 UMA_HISTOGRAM_ENUMERATION(
59 "SafeBrowsing.ReferrerAttributionResult.PasswordEventAttribution", result,
60 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
61 }
62
63 bool ChromePasswordProtectionService::IsExtendedReporting() {
64 DCHECK(profile_);
Nathan Parker 2017/04/05 18:05:22 nit: I'm pretty sure the DCHECKs here are not help
Jialiu Lin 2017/04/05 18:48:25 DCHECK removed.
65 return IsExtendedReportingEnabled(*profile_->GetPrefs());
66 }
67
68 bool ChromePasswordProtectionService::IsIncognito() {
69 DCHECK(profile_);
70 return profile_->IsOffTheRecord();
71 }
72
73 bool ChromePasswordProtectionService::IsPingingEnabled() {
74 return base::FeatureList::IsEnabled(
75 ChromePasswordProtectionService::kPasswordProtectionPingOnly);
76 }
77
78 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698