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

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: nit 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/metrics/histogram_macros.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/history/history_service_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
12 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
13 #include "components/safe_browsing_db/safe_browsing_prefs.h"
14
15 using content::BrowserThread;
16
17 namespace safe_browsing {
18
19 namespace {
20 // The number of user gestures we trace back for login event attribution.
21 const int kPasswordEventAttributionUserGestureLimit = 2;
22 }
23
24 const base::Feature
25 ChromePasswordProtectionService::kPasswordProtectionPingOnly{
26 "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.
27
28 ChromePasswordProtectionService::ChromePasswordProtectionService(
29 SafeBrowsingService* sb_service,
30 Profile* profile)
31 : PasswordProtectionService(
32 sb_service->database_manager(),
33 sb_service->url_request_context(),
34 HistoryServiceFactory::GetForProfile(
35 profile,
36 ServiceAccessType::EXPLICIT_ACCESS),
37 HostContentSettingsMapFactory::GetForProfile(profile)),
38 profile_(profile),
39 navigation_observer_manager_(sb_service->navigation_observer_manager()) {
40 DCHECK(profile_);
41 }
42
43 ChromePasswordProtectionService::~ChromePasswordProtectionService() {}
44
45 void ChromePasswordProtectionService::FillReferrerChain(
46 const GURL& event_url,
47 int event_tab_id,
48 LoginReputationClientRequest::Frame* frame) {
49 DCHECK_CURRENTLY_ON(BrowserThread::UI);
50 // TODO(jialiul): Update function name when https://crrev.com/2777853005
51 // is landed.
52 SafeBrowsingNavigationObserverManager::AttributionResult result =
53 navigation_observer_manager_->IdentifyReferrerChainForDownload(
54 event_url, event_tab_id, kPasswordEventAttributionUserGestureLimit,
55 frame->mutable_referrer_chain());
56 UMA_HISTOGRAM_COUNTS_100(
57 "SafeBrowsing.ReferrerURLChainSize.PasswordEventAttribution",
58 frame->referrer_chain().size());
59 UMA_HISTOGRAM_ENUMERATION(
60 "SafeBrowsing.ReferrerAttributionResult.PasswordEventAttribution", result,
61 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
62 }
63
64 bool ChromePasswordProtectionService::IsExtendedReporting() {
65 DCHECK(profile_);
66 return IsExtendedReportingEnabled(*profile_->GetPrefs());
67 }
68
69 bool ChromePasswordProtectionService::IsIncognito() {
70 DCHECK(profile_);
71 return profile_->IsOffTheRecord();
72 }
73
74 bool ChromePasswordProtectionService::IsPingingEnabled() {
75 return base::FeatureList::IsEnabled(
76 ChromePasswordProtectionService::kPasswordProtectionPingOnly);
77 }
78
79 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698