| OLD | NEW |
| (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 |
| 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 UMA_HISTOGRAM_COUNTS_1000( |
| 46 "PasswordProtection.NumberOfCachedVerdictBeforeShutdown", |
| 47 GetStoredVerdictCount()); |
| 48 } |
| 49 |
| 50 void ChromePasswordProtectionService::FillReferrerChain( |
| 51 const GURL& event_url, |
| 52 int event_tab_id, |
| 53 LoginReputationClientRequest::Frame* frame) { |
| 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 SafeBrowsingNavigationObserverManager::AttributionResult result = |
| 56 navigation_observer_manager_->IdentifyReferrerChainByEventURL( |
| 57 event_url, event_tab_id, kPasswordEventAttributionUserGestureLimit, |
| 58 frame->mutable_referrer_chain()); |
| 59 UMA_HISTOGRAM_COUNTS_100( |
| 60 "SafeBrowsing.ReferrerURLChainSize.PasswordEventAttribution", |
| 61 frame->referrer_chain().size()); |
| 62 UMA_HISTOGRAM_ENUMERATION( |
| 63 "SafeBrowsing.ReferrerAttributionResult.PasswordEventAttribution", result, |
| 64 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); |
| 65 } |
| 66 |
| 67 bool ChromePasswordProtectionService::IsExtendedReporting() { |
| 68 DCHECK(profile_); |
| 69 return IsExtendedReportingEnabled(*profile_->GetPrefs()); |
| 70 } |
| 71 |
| 72 bool ChromePasswordProtectionService::IsIncognito() { |
| 73 DCHECK(profile_); |
| 74 return profile_->IsOffTheRecord(); |
| 75 } |
| 76 |
| 77 bool ChromePasswordProtectionService::IsPingingEnabled() { |
| 78 return base::FeatureList::IsEnabled( |
| 79 ChromePasswordProtectionService::kPasswordProtectionPingOnly); |
| 80 } |
| 81 |
| 82 } // namespace safe_browsing |
| OLD | NEW |