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