Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" | 5 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/metrics/field_trial_params.h" | 8 #include "base/metrics/field_trial_params.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h" |
| 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "components/browser_sync/profile_sync_service.h" | 16 #include "components/browser_sync/profile_sync_service.h" |
| 17 #include "components/safe_browsing/password_protection/password_protection_reque st.h" | 17 #include "components/safe_browsing/password_protection/password_protection_reque st.h" |
| 18 #include "components/safe_browsing_db/database_manager.h" | 18 #include "components/safe_browsing_db/database_manager.h" |
| 19 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 19 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 | 22 |
| 23 namespace safe_browsing { | 23 namespace safe_browsing { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | |
| 26 // The number of user gestures we trace back for login event attribution. | 27 // The number of user gestures we trace back for login event attribution. |
| 27 const int kPasswordEventAttributionUserGestureLimit = 2; | 28 const int kPasswordEventAttributionUserGestureLimit = 2; |
| 28 } | 29 |
| 30 } // namespace | |
| 29 | 31 |
| 30 ChromePasswordProtectionService::ChromePasswordProtectionService( | 32 ChromePasswordProtectionService::ChromePasswordProtectionService( |
| 31 SafeBrowsingService* sb_service, | 33 SafeBrowsingService* sb_service, |
| 32 Profile* profile) | 34 Profile* profile) |
| 33 : PasswordProtectionService( | 35 : PasswordProtectionService( |
| 34 sb_service->database_manager(), | 36 sb_service->database_manager(), |
| 35 sb_service->url_request_context(), | 37 sb_service->url_request_context(), |
| 36 HistoryServiceFactory::GetForProfile( | 38 HistoryServiceFactory::GetForProfile( |
| 37 profile, | 39 profile, |
| 38 ServiceAccessType::EXPLICIT_ACCESS), | 40 ServiceAccessType::EXPLICIT_ACCESS), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 return IsExtendedReportingEnabled(*profile_->GetPrefs()); | 73 return IsExtendedReportingEnabled(*profile_->GetPrefs()); |
| 72 } | 74 } |
| 73 | 75 |
| 74 bool ChromePasswordProtectionService::IsIncognito() { | 76 bool ChromePasswordProtectionService::IsIncognito() { |
| 75 DCHECK(profile_); | 77 DCHECK(profile_); |
| 76 return profile_->IsOffTheRecord(); | 78 return profile_->IsOffTheRecord(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 bool ChromePasswordProtectionService::IsPingingEnabled( | 81 bool ChromePasswordProtectionService::IsPingingEnabled( |
| 80 const base::Feature& feature) { | 82 const base::Feature& feature) { |
| 83 bool is_password_entry_ping = | |
| 84 feature.name == kProtectedPasswordEntryPinging.name; | |
|
Nathan Parker
2017/05/11 23:36:31
Add a DCHECK() that feature is one of the two expe
Jialiu Lin
2017/05/12 02:12:32
Good point.
| |
| 81 if (!base::FeatureList::IsEnabled(feature)) { | 85 if (!base::FeatureList::IsEnabled(feature)) { |
| 86 if (is_password_entry_ping) { | |
| 87 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, | |
| 88 DISABLED_DUE_TO_FEATURE_DISABLED, MAX_OUTCOME); | |
| 89 } else { | |
| 90 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, | |
| 91 DISABLED_DUE_TO_FEATURE_DISABLED, MAX_OUTCOME); | |
| 92 } | |
| 82 return false; | 93 return false; |
| 83 } | 94 } |
| 84 | 95 |
| 85 bool allowed_incognito = | 96 bool allowed_incognito = |
| 86 base::GetFieldTrialParamByFeatureAsBool(feature, "incognito", false); | 97 base::GetFieldTrialParamByFeatureAsBool(feature, "incognito", false); |
| 87 if (IsIncognito() && !allowed_incognito) | 98 if (IsIncognito() && !allowed_incognito) { |
| 99 if (is_password_entry_ping) { | |
| 100 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, | |
|
Nathan Parker
2017/05/11 23:36:31
An idea (you decide if this is any better): You co
Jialiu Lin
2017/05/12 02:12:32
SG. code refactored.
| |
| 101 DISABLED_DUE_TO_INCOGNITO, MAX_OUTCOME); | |
| 102 } else { | |
| 103 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, | |
| 104 DISABLED_DUE_TO_INCOGNITO, MAX_OUTCOME); | |
| 105 } | |
| 88 return false; | 106 return false; |
| 107 } | |
| 89 | 108 |
| 90 bool allowed_all_population = | 109 bool allowed_all_population = |
| 91 base::GetFieldTrialParamByFeatureAsBool(feature, "all_population", false); | 110 base::GetFieldTrialParamByFeatureAsBool(feature, "all_population", false); |
| 92 if (!allowed_all_population) { | 111 if (!allowed_all_population) { |
| 93 bool allowed_extended_reporting = base::GetFieldTrialParamByFeatureAsBool( | 112 bool allowed_extended_reporting = base::GetFieldTrialParamByFeatureAsBool( |
| 94 feature, "extended_reporting", false); | 113 feature, "extended_reporting", false); |
| 95 if (IsExtendedReporting() && allowed_extended_reporting) | 114 if (IsExtendedReporting() && allowed_extended_reporting) |
| 96 return true; // Ping enabled because this user opted in extended | 115 return true; // Ping enabled because this user opted in extended |
| 97 // reporting. | 116 // reporting. |
| 98 | 117 |
| 99 bool allowed_history_sync = | 118 bool allowed_history_sync = |
| 100 base::GetFieldTrialParamByFeatureAsBool(feature, "history_sync", false); | 119 base::GetFieldTrialParamByFeatureAsBool(feature, "history_sync", false); |
| 101 if (IsHistorySyncEnabled() && allowed_history_sync) | 120 if (IsHistorySyncEnabled() && allowed_history_sync) |
| 102 return true; | 121 return true; |
| 122 | |
| 123 if (is_password_entry_ping) { | |
| 124 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, | |
| 125 DISABLED_DUE_TO_USER_POPULATION, MAX_OUTCOME); | |
| 126 } else { | |
| 127 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, | |
| 128 DISABLED_DUE_TO_USER_POPULATION, MAX_OUTCOME); | |
| 129 } | |
| 103 } | 130 } |
| 104 | 131 |
| 105 return allowed_all_population; | 132 return allowed_all_population; |
| 106 } | 133 } |
| 107 | 134 |
| 108 bool ChromePasswordProtectionService::IsHistorySyncEnabled() { | 135 bool ChromePasswordProtectionService::IsHistorySyncEnabled() { |
| 109 browser_sync::ProfileSyncService* sync = | 136 browser_sync::ProfileSyncService* sync = |
| 110 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 137 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
| 111 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() && | 138 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() && |
| 112 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); | 139 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); |
| 113 } | 140 } |
| 114 | 141 |
| 115 ChromePasswordProtectionService::ChromePasswordProtectionService() | 142 ChromePasswordProtectionService::ChromePasswordProtectionService() |
| 116 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {} | 143 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {} |
| 117 } // namespace safe_browsing | 144 } // namespace safe_browsing |
| OLD | NEW |