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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_request.cc

Issue 2911293003: Reland: Cache protected password entry and password on focus ping separately. (Closed)
Patch Set: Fix Crashes by Using GetDictionaryWithoutPathExpansion Created 3 years, 6 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 #include "components/safe_browsing/password_protection/password_protection_reque st.h" 4 #include "components/safe_browsing/password_protection/password_protection_reque st.h"
5 5
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "components/data_use_measurement/core/data_use_user_data.h" 9 #include "components/data_use_measurement/core/data_use_user_data.h"
10 #include "components/password_manager/core/browser/password_reuse_detector.h" 10 #include "components/password_manager/core/browser/password_reuse_detector.h"
(...skipping 18 matching lines...) Expand all
29 const std::string& saved_domain, 29 const std::string& saved_domain,
30 LoginReputationClientRequest::TriggerType type, 30 LoginReputationClientRequest::TriggerType type,
31 bool password_field_exists, 31 bool password_field_exists,
32 PasswordProtectionService* pps, 32 PasswordProtectionService* pps,
33 int request_timeout_in_ms) 33 int request_timeout_in_ms)
34 : web_contents_(web_contents), 34 : web_contents_(web_contents),
35 main_frame_url_(main_frame_url), 35 main_frame_url_(main_frame_url),
36 password_form_action_(password_form_action), 36 password_form_action_(password_form_action),
37 password_form_frame_url_(password_form_frame_url), 37 password_form_frame_url_(password_form_frame_url),
38 saved_domain_(saved_domain), 38 saved_domain_(saved_domain),
39 request_type_(type), 39 trigger_type_(type),
40 password_field_exists_(password_field_exists), 40 password_field_exists_(password_field_exists),
41 password_protection_service_(pps), 41 password_protection_service_(pps),
42 request_timeout_in_ms_(request_timeout_in_ms), 42 request_timeout_in_ms_(request_timeout_in_ms),
43 weakptr_factory_(this) { 43 weakptr_factory_(this) {
44 DCHECK_CURRENTLY_ON(BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
45 DCHECK(trigger_type_ == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE ||
46 trigger_type_ == LoginReputationClientRequest::PASSWORD_REUSE_EVENT);
45 } 47 }
46 48
47 PasswordProtectionRequest::~PasswordProtectionRequest() { 49 PasswordProtectionRequest::~PasswordProtectionRequest() {
48 weakptr_factory_.InvalidateWeakPtrs(); 50 weakptr_factory_.InvalidateWeakPtrs();
49 } 51 }
50 52
51 void PasswordProtectionRequest::Start() { 53 void PasswordProtectionRequest::Start() {
52 DCHECK_CURRENTLY_ON(BrowserThread::UI); 54 DCHECK_CURRENTLY_ON(BrowserThread::UI);
53 CheckWhitelistOnUIThread(); 55 CheckWhitelistOnUIThread();
54 } 56 }
(...skipping 23 matching lines...) Expand all
78 void PasswordProtectionRequest::CheckCachedVerdicts() { 80 void PasswordProtectionRequest::CheckCachedVerdicts() {
79 DCHECK_CURRENTLY_ON(BrowserThread::UI); 81 DCHECK_CURRENTLY_ON(BrowserThread::UI);
80 if (!password_protection_service_) { 82 if (!password_protection_service_) {
81 Finish(PasswordProtectionService::SERVICE_DESTROYED, nullptr); 83 Finish(PasswordProtectionService::SERVICE_DESTROYED, nullptr);
82 return; 84 return;
83 } 85 }
84 86
85 std::unique_ptr<LoginReputationClientResponse> cached_response = 87 std::unique_ptr<LoginReputationClientResponse> cached_response =
86 base::MakeUnique<LoginReputationClientResponse>(); 88 base::MakeUnique<LoginReputationClientResponse>();
87 auto verdict = password_protection_service_->GetCachedVerdict( 89 auto verdict = password_protection_service_->GetCachedVerdict(
88 main_frame_url_, cached_response.get()); 90 main_frame_url_, trigger_type_, cached_response.get());
89 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED) 91 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED)
90 Finish(PasswordProtectionService::RESPONSE_ALREADY_CACHED, 92 Finish(PasswordProtectionService::RESPONSE_ALREADY_CACHED,
91 std::move(cached_response)); 93 std::move(cached_response));
92 else 94 else
93 SendRequest(); 95 SendRequest();
94 } 96 }
95 97
96 void PasswordProtectionRequest::FillRequestProto() { 98 void PasswordProtectionRequest::FillRequestProto() {
97 request_proto_ = base::MakeUnique<LoginReputationClientRequest>(); 99 request_proto_ = base::MakeUnique<LoginReputationClientRequest>();
98 request_proto_->set_page_url(main_frame_url_.spec()); 100 request_proto_->set_page_url(main_frame_url_.spec());
99 request_proto_->set_trigger_type(request_type_); 101 request_proto_->set_trigger_type(trigger_type_);
100 password_protection_service_->FillUserPopulation(request_type_, 102 password_protection_service_->FillUserPopulation(trigger_type_,
101 request_proto_.get()); 103 request_proto_.get());
102 request_proto_->set_stored_verdict_cnt( 104 request_proto_->set_stored_verdict_cnt(
103 password_protection_service_->GetStoredVerdictCount()); 105 password_protection_service_->GetStoredVerdictCount(trigger_type_));
104 LoginReputationClientRequest::Frame* main_frame = 106 LoginReputationClientRequest::Frame* main_frame =
105 request_proto_->add_frames(); 107 request_proto_->add_frames();
106 main_frame->set_url(main_frame_url_.spec()); 108 main_frame->set_url(main_frame_url_.spec());
107 main_frame->set_frame_index(0 /* main frame */); 109 main_frame->set_frame_index(0 /* main frame */);
108 password_protection_service_->FillReferrerChain( 110 password_protection_service_->FillReferrerChain(
109 main_frame_url_, -1 /* tab id not available */, main_frame); 111 main_frame_url_, -1 /* tab id not available */, main_frame);
110 112
111 switch (request_type_) { 113 switch (trigger_type_) {
112 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: { 114 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: {
113 LoginReputationClientRequest::Frame::Form* password_form; 115 LoginReputationClientRequest::Frame::Form* password_form;
114 if (password_form_frame_url_ == main_frame_url_) { 116 if (password_form_frame_url_ == main_frame_url_) {
115 main_frame->set_has_password_field(true); 117 main_frame->set_has_password_field(true);
116 password_form = main_frame->add_forms(); 118 password_form = main_frame->add_forms();
117 } else { 119 } else {
118 LoginReputationClientRequest::Frame* password_frame = 120 LoginReputationClientRequest::Frame* password_frame =
119 request_proto_->add_frames(); 121 request_proto_->add_frames();
120 password_frame->set_url(password_form_frame_url_.spec()); 122 password_frame->set_url(password_form_frame_url_.spec());
121 password_frame->set_has_password_field(true); 123 password_frame->set_has_password_field(true);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 else 242 else
241 Finish(PasswordProtectionService::RESPONSE_MALFORMED, nullptr); 243 Finish(PasswordProtectionService::RESPONSE_MALFORMED, nullptr);
242 } 244 }
243 245
244 void PasswordProtectionRequest::Finish( 246 void PasswordProtectionRequest::Finish(
245 PasswordProtectionService::RequestOutcome outcome, 247 PasswordProtectionService::RequestOutcome outcome,
246 std::unique_ptr<LoginReputationClientResponse> response) { 248 std::unique_ptr<LoginReputationClientResponse> response) {
247 DCHECK_CURRENTLY_ON(BrowserThread::UI); 249 DCHECK_CURRENTLY_ON(BrowserThread::UI);
248 tracker_.TryCancelAll(); 250 tracker_.TryCancelAll();
249 251
250 if (request_type_ == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { 252 if (trigger_type_ == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) {
251 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, 253 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName,
252 outcome, PasswordProtectionService::MAX_OUTCOME); 254 outcome, PasswordProtectionService::MAX_OUTCOME);
253 } else { 255 } else {
254 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, 256 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName,
255 outcome, PasswordProtectionService::MAX_OUTCOME); 257 outcome, PasswordProtectionService::MAX_OUTCOME);
256 } 258 }
257 259
258 if (outcome == PasswordProtectionService::SUCCEEDED && response) { 260 if (outcome == PasswordProtectionService::SUCCEEDED && response) {
259 switch (request_type_) { 261 switch (trigger_type_) {
260 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: 262 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE:
261 UMA_HISTOGRAM_ENUMERATION( 263 UMA_HISTOGRAM_ENUMERATION(
262 "PasswordProtection.Verdict.PasswordFieldOnFocus", 264 "PasswordProtection.Verdict.PasswordFieldOnFocus",
263 response->verdict_type(), 265 response->verdict_type(),
264 LoginReputationClientResponse_VerdictType_VerdictType_MAX + 1); 266 LoginReputationClientResponse_VerdictType_VerdictType_MAX + 1);
265 break; 267 break;
266 case LoginReputationClientRequest::PASSWORD_REUSE_EVENT: 268 case LoginReputationClientRequest::PASSWORD_REUSE_EVENT:
267 UMA_HISTOGRAM_ENUMERATION( 269 UMA_HISTOGRAM_ENUMERATION(
268 "PasswordProtection.Verdict.ProtectedPasswordEntry", 270 "PasswordProtection.Verdict.ProtectedPasswordEntry",
269 response->verdict_type(), 271 response->verdict_type(),
(...skipping 13 matching lines...) Expand all
283 void PasswordProtectionRequest::Cancel(bool timed_out) { 285 void PasswordProtectionRequest::Cancel(bool timed_out) {
284 DCHECK_CURRENTLY_ON(BrowserThread::UI); 286 DCHECK_CURRENTLY_ON(BrowserThread::UI);
285 fetcher_.reset(); 287 fetcher_.reset();
286 288
287 Finish(timed_out ? PasswordProtectionService::TIMEDOUT 289 Finish(timed_out ? PasswordProtectionService::TIMEDOUT
288 : PasswordProtectionService::CANCELED, 290 : PasswordProtectionService::CANCELED,
289 nullptr); 291 nullptr);
290 } 292 }
291 293
292 } // namespace safe_browsing 294 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698