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 "components/safe_browsing/password_protection/password_protection_servi
ce.h" | 5 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 const base::Feature kPasswordFieldOnFocusPinging{ | 67 const base::Feature kPasswordFieldOnFocusPinging{ |
68 "PasswordFieldOnFocusPinging", base::FEATURE_DISABLED_BY_DEFAULT}; | 68 "PasswordFieldOnFocusPinging", base::FEATURE_DISABLED_BY_DEFAULT}; |
69 | 69 |
70 const base::Feature kProtectedPasswordEntryPinging{ | 70 const base::Feature kProtectedPasswordEntryPinging{ |
71 "ProtectedPasswordEntryPinging", base::FEATURE_DISABLED_BY_DEFAULT}; | 71 "ProtectedPasswordEntryPinging", base::FEATURE_DISABLED_BY_DEFAULT}; |
72 | 72 |
| 73 const char kPasswordOnFocusRequestOutcomeHistogramName[] = |
| 74 "PasswordProtection.RequestOutcome.PasswordFieldOnFocus"; |
| 75 const char kPasswordEntryRequestOutcomeHistogramName[] = |
| 76 "PasswordProtection.RequestOutcome.ProtectedPasswordEntry"; |
| 77 |
73 PasswordProtectionService::PasswordProtectionService( | 78 PasswordProtectionService::PasswordProtectionService( |
74 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, | 79 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
75 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 80 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
76 HistoryService* history_service, | 81 HistoryService* history_service, |
77 HostContentSettingsMap* host_content_settings_map) | 82 HostContentSettingsMap* host_content_settings_map) |
78 : stored_verdict_count_(-1), | 83 : stored_verdict_count_(-1), |
79 database_manager_(database_manager), | 84 database_manager_(database_manager), |
80 request_context_getter_(request_context_getter), | 85 request_context_getter_(request_context_getter), |
81 history_service_observer_(this), | 86 history_service_observer_(this), |
82 content_settings_(host_content_settings_map), | 87 content_settings_(host_content_settings_map), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 270 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
266 scoped_refptr<PasswordProtectionRequest> request( | 271 scoped_refptr<PasswordProtectionRequest> request( |
267 new PasswordProtectionRequest(main_frame_url, password_form_action, | 272 new PasswordProtectionRequest(main_frame_url, password_form_action, |
268 password_form_frame_url, type, this, | 273 password_form_frame_url, type, this, |
269 GetRequestTimeoutInMS())); | 274 GetRequestTimeoutInMS())); |
270 DCHECK(request); | 275 DCHECK(request); |
271 request->Start(); | 276 request->Start(); |
272 requests_.insert(std::move(request)); | 277 requests_.insert(std::move(request)); |
273 } | 278 } |
274 | 279 |
275 void PasswordProtectionService::MaybeStartLowReputationRequest( | 280 void PasswordProtectionService::MaybeStartPasswordFieldOnFocusRequest( |
276 const GURL& main_frame_url, | 281 const GURL& main_frame_url, |
277 const GURL& password_form_action, | 282 const GURL& password_form_action, |
278 const GURL& password_form_frame_url) { | 283 const GURL& password_form_frame_url) { |
279 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 284 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
280 if (!IsPingingEnabled(kPasswordFieldOnFocusPinging)) | 285 RequestOutcome request_outcome; |
| 286 if (!IsPingingEnabled(kPasswordFieldOnFocusPinging, &request_outcome)) { |
| 287 RecordPingingDisabledReason(kPasswordFieldOnFocusPinging, request_outcome); |
281 return; | 288 return; |
| 289 } |
282 | 290 |
283 // Skip URLs that we can't get a reliable reputation for. | 291 // Skip URLs that we can't get a reliable reputation for. |
284 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { | 292 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { |
285 return; | 293 return; |
286 } | 294 } |
287 | 295 |
288 StartRequest(main_frame_url, password_form_action, password_form_frame_url, | 296 StartRequest(main_frame_url, password_form_action, password_form_frame_url, |
289 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); | 297 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); |
290 } | 298 } |
291 | 299 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 const std::string serialized_proto(verdict->SerializeAsString()); | 541 const std::string serialized_proto(verdict->SerializeAsString()); |
534 const std::vector<char> verdict_blob(serialized_proto.begin(), | 542 const std::vector<char> verdict_blob(serialized_proto.begin(), |
535 serialized_proto.end()); | 543 serialized_proto.end()); |
536 std::unique_ptr<base::Value> binary_value = | 544 std::unique_ptr<base::Value> binary_value = |
537 base::MakeUnique<base::Value>(verdict_blob); | 545 base::MakeUnique<base::Value>(verdict_blob); |
538 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); | 546 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); |
539 result->Set(kVerdictProto, std::move(binary_value)); | 547 result->Set(kVerdictProto, std::move(binary_value)); |
540 return result; | 548 return result; |
541 } | 549 } |
542 | 550 |
| 551 void PasswordProtectionService::RecordPingingDisabledReason( |
| 552 const base::Feature& feature, |
| 553 RequestOutcome reason) { |
| 554 DCHECK(feature.name == kProtectedPasswordEntryPinging.name || |
| 555 feature.name == kPasswordFieldOnFocusPinging.name); |
| 556 |
| 557 bool is_password_entry_ping = |
| 558 feature.name == kProtectedPasswordEntryPinging.name; |
| 559 |
| 560 if (is_password_entry_ping) { |
| 561 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, reason, |
| 562 MAX_OUTCOME); |
| 563 } else { |
| 564 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, |
| 565 reason, MAX_OUTCOME); |
| 566 } |
| 567 } |
| 568 |
543 } // namespace safe_browsing | 569 } // namespace safe_browsing |
OLD | NEW |