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

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

Issue 2869253002: Add UMA metrics to phishguard pings (Closed)
Patch Set: resolve comments on histograms.xml Created 3 years, 7 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
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
71 bool ChromePasswordProtectionService::IsExtendedReporting() { 73 bool ChromePasswordProtectionService::IsExtendedReporting() {
72 return IsExtendedReportingEnabled(*profile_->GetPrefs()); 74 return IsExtendedReportingEnabled(*profile_->GetPrefs());
73 } 75 }
74 76
75 bool ChromePasswordProtectionService::IsIncognito() { 77 bool ChromePasswordProtectionService::IsIncognito() {
76 DCHECK(profile_); 78 DCHECK(profile_);
77 return profile_->IsOffTheRecord(); 79 return profile_->IsOffTheRecord();
78 } 80 }
79 81
80 bool ChromePasswordProtectionService::IsPingingEnabled( 82 bool ChromePasswordProtectionService::IsPingingEnabled(
81 const base::Feature& feature) { 83 const base::Feature& feature,
84 RequestOutcome* reason) {
85 DCHECK(feature.name == kProtectedPasswordEntryPinging.name ||
86 feature.name == kPasswordFieldOnFocusPinging.name);
82 if (!base::FeatureList::IsEnabled(feature)) { 87 if (!base::FeatureList::IsEnabled(feature)) {
88 *reason = DISABLED_DUE_TO_FEATURE_DISABLED;
83 return false; 89 return false;
84 } 90 }
85 91
86 bool allowed_incognito = 92 bool allowed_incognito =
87 base::GetFieldTrialParamByFeatureAsBool(feature, "incognito", false); 93 base::GetFieldTrialParamByFeatureAsBool(feature, "incognito", false);
88 if (IsIncognito() && !allowed_incognito) 94 if (IsIncognito() && !allowed_incognito) {
95 *reason = DISABLED_DUE_TO_INCOGNITO;
89 return false; 96 return false;
97 }
90 98
91 bool allowed_all_population = 99 bool allowed_all_population =
92 base::GetFieldTrialParamByFeatureAsBool(feature, "all_population", false); 100 base::GetFieldTrialParamByFeatureAsBool(feature, "all_population", false);
93 if (!allowed_all_population) { 101 if (!allowed_all_population) {
94 bool allowed_extended_reporting = base::GetFieldTrialParamByFeatureAsBool( 102 bool allowed_extended_reporting = base::GetFieldTrialParamByFeatureAsBool(
95 feature, "extended_reporting", false); 103 feature, "extended_reporting", false);
96 if (IsExtendedReporting() && allowed_extended_reporting) 104 if (IsExtendedReporting() && allowed_extended_reporting)
97 return true; // Ping enabled because this user opted in extended 105 return true; // Ping enabled because this user opted in extended
98 // reporting. 106 // reporting.
99 107
100 bool allowed_history_sync = 108 bool allowed_history_sync =
101 base::GetFieldTrialParamByFeatureAsBool(feature, "history_sync", false); 109 base::GetFieldTrialParamByFeatureAsBool(feature, "history_sync", false);
102 if (IsHistorySyncEnabled() && allowed_history_sync) 110 if (IsHistorySyncEnabled() && allowed_history_sync)
103 return true; 111 return true;
112
113 *reason = DISABLED_DUE_TO_USER_POPULATION;
104 } 114 }
105 115
106 return allowed_all_population; 116 return allowed_all_population;
107 } 117 }
108 118
109 bool ChromePasswordProtectionService::IsHistorySyncEnabled() { 119 bool ChromePasswordProtectionService::IsHistorySyncEnabled() {
110 browser_sync::ProfileSyncService* sync = 120 browser_sync::ProfileSyncService* sync =
111 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 121 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
112 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() && 122 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() &&
113 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); 123 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES);
114 } 124 }
115 125
116 ChromePasswordProtectionService::ChromePasswordProtectionService() 126 ChromePasswordProtectionService::ChromePasswordProtectionService()
117 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {} 127 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {}
118 } // namespace safe_browsing 128 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698