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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 const base::Feature kPasswordFieldOnFocusPinging{ | 71 const base::Feature kPasswordFieldOnFocusPinging{ |
72 "PasswordFieldOnFocusPinging", base::FEATURE_DISABLED_BY_DEFAULT}; | 72 "PasswordFieldOnFocusPinging", base::FEATURE_DISABLED_BY_DEFAULT}; |
73 | 73 |
74 const base::Feature kProtectedPasswordEntryPinging{ | 74 const base::Feature kProtectedPasswordEntryPinging{ |
75 "ProtectedPasswordEntryPinging", base::FEATURE_DISABLED_BY_DEFAULT}; | 75 "ProtectedPasswordEntryPinging", base::FEATURE_DISABLED_BY_DEFAULT}; |
76 | 76 |
| 77 const base::Feature kPasswordProtectionInterstitial{ |
| 78 "PasswordProtectionInterstitial", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 79 |
77 const char kPasswordOnFocusRequestOutcomeHistogramName[] = | 80 const char kPasswordOnFocusRequestOutcomeHistogramName[] = |
78 "PasswordProtection.RequestOutcome.PasswordFieldOnFocus"; | 81 "PasswordProtection.RequestOutcome.PasswordFieldOnFocus"; |
79 const char kPasswordEntryRequestOutcomeHistogramName[] = | 82 const char kPasswordEntryRequestOutcomeHistogramName[] = |
80 "PasswordProtection.RequestOutcome.ProtectedPasswordEntry"; | 83 "PasswordProtection.RequestOutcome.ProtectedPasswordEntry"; |
81 | 84 |
82 PasswordProtectionService::PasswordProtectionService( | 85 PasswordProtectionService::PasswordProtectionService( |
83 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, | 86 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
84 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 87 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
85 HistoryService* history_service, | 88 HistoryService* history_service, |
86 HostContentSettingsMap* host_content_settings_map) | 89 HostContentSettingsMap* host_content_settings_map) |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 if (IsPingingEnabled(kPasswordFieldOnFocusPinging, &request_outcome) && | 315 if (IsPingingEnabled(kPasswordFieldOnFocusPinging, &request_outcome) && |
313 CanGetReputationOfURL(main_frame_url)) { | 316 CanGetReputationOfURL(main_frame_url)) { |
314 return true; | 317 return true; |
315 } | 318 } |
316 RecordNoPingingReason(feature, request_outcome); | 319 RecordNoPingingReason(feature, request_outcome); |
317 return false; | 320 return false; |
318 } | 321 } |
319 | 322 |
320 void PasswordProtectionService::RequestFinished( | 323 void PasswordProtectionService::RequestFinished( |
321 PasswordProtectionRequest* request, | 324 PasswordProtectionRequest* request, |
| 325 bool already_cached, |
322 std::unique_ptr<LoginReputationClientResponse> response) { | 326 std::unique_ptr<LoginReputationClientResponse> response) { |
323 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 327 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 328 DCHECK(request); |
324 | 329 |
325 DCHECK(request); | 330 if (response) { |
326 if (response) | 331 if (!already_cached) { |
327 CacheVerdict(request->main_frame_url(), response.get(), base::Time::Now()); | 332 CacheVerdict(request->main_frame_url(), response.get(), |
| 333 base::Time::Now()); |
| 334 } |
| 335 |
| 336 if (request->request_type() == |
| 337 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE && |
| 338 response->verdict_type() == LoginReputationClientResponse::PHISHING && |
| 339 base::FeatureList::IsEnabled(kPasswordProtectionInterstitial)) { |
| 340 ShowPhishingInterstitial(request->main_frame_url(), |
| 341 response->verdict_token(), |
| 342 request->web_contents()); |
| 343 } |
| 344 } |
328 | 345 |
329 // Finished processing this request. Remove it from pending list. | 346 // Finished processing this request. Remove it from pending list. |
330 for (auto it = requests_.begin(); it != requests_.end(); it++) { | 347 for (auto it = requests_.begin(); it != requests_.end(); it++) { |
331 if (it->get() == request) { | 348 if (it->get() == request) { |
332 requests_.erase(it); | 349 requests_.erase(it); |
333 break; | 350 break; |
334 } | 351 } |
335 } | 352 } |
336 } | 353 } |
337 | 354 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 if (is_password_entry_ping) { | 582 if (is_password_entry_ping) { |
566 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, reason, | 583 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, reason, |
567 MAX_OUTCOME); | 584 MAX_OUTCOME); |
568 } else { | 585 } else { |
569 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, | 586 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, |
570 reason, MAX_OUTCOME); | 587 reason, MAX_OUTCOME); |
571 } | 588 } |
572 } | 589 } |
573 | 590 |
574 } // namespace safe_browsing | 591 } // namespace safe_browsing |
OLD | NEW |