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

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: nit 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 "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 20 matching lines...) Expand all
31 : web_contents_(web_contents), 31 : web_contents_(web_contents),
32 main_frame_url_(main_frame_url), 32 main_frame_url_(main_frame_url),
33 password_form_action_(password_form_action), 33 password_form_action_(password_form_action),
34 password_form_frame_url_(password_form_frame_url), 34 password_form_frame_url_(password_form_frame_url),
35 saved_domain_(saved_domain), 35 saved_domain_(saved_domain),
36 request_type_(type), 36 request_type_(type),
37 password_protection_service_(pps), 37 password_protection_service_(pps),
38 request_timeout_in_ms_(request_timeout_in_ms), 38 request_timeout_in_ms_(request_timeout_in_ms),
39 weakptr_factory_(this) { 39 weakptr_factory_(this) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 40 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 DCHECK(request_type_ == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE ||
42 request_type_ == LoginReputationClientRequest::PASSWORD_REUSE_EVENT);
41 } 43 }
42 44
43 PasswordProtectionRequest::~PasswordProtectionRequest() { 45 PasswordProtectionRequest::~PasswordProtectionRequest() {
44 weakptr_factory_.InvalidateWeakPtrs(); 46 weakptr_factory_.InvalidateWeakPtrs();
45 } 47 }
46 48
47 void PasswordProtectionRequest::Start() { 49 void PasswordProtectionRequest::Start() {
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); 50 DCHECK_CURRENTLY_ON(BrowserThread::UI);
49 CheckWhitelistOnUIThread(); 51 CheckWhitelistOnUIThread();
50 } 52 }
(...skipping 23 matching lines...) Expand all
74 void PasswordProtectionRequest::CheckCachedVerdicts() { 76 void PasswordProtectionRequest::CheckCachedVerdicts() {
75 DCHECK_CURRENTLY_ON(BrowserThread::UI); 77 DCHECK_CURRENTLY_ON(BrowserThread::UI);
76 if (!password_protection_service_) { 78 if (!password_protection_service_) {
77 Finish(PasswordProtectionService::SERVICE_DESTROYED, nullptr); 79 Finish(PasswordProtectionService::SERVICE_DESTROYED, nullptr);
78 return; 80 return;
79 } 81 }
80 82
81 std::unique_ptr<LoginReputationClientResponse> cached_response = 83 std::unique_ptr<LoginReputationClientResponse> cached_response =
82 base::MakeUnique<LoginReputationClientResponse>(); 84 base::MakeUnique<LoginReputationClientResponse>();
83 auto verdict = password_protection_service_->GetCachedVerdict( 85 auto verdict = password_protection_service_->GetCachedVerdict(
84 main_frame_url_, cached_response.get()); 86 main_frame_url_, request_type(), cached_response.get());
lpz 2017/06/08 15:18:33 nit: request_type_ for consistency with the rest o
Jialiu Lin 2017/06/08 20:47:30 Done.
85 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED) 87 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED)
86 Finish(PasswordProtectionService::RESPONSE_ALREADY_CACHED, 88 Finish(PasswordProtectionService::RESPONSE_ALREADY_CACHED,
87 std::move(cached_response)); 89 std::move(cached_response));
88 else 90 else
89 SendRequest(); 91 SendRequest();
90 } 92 }
91 93
92 void PasswordProtectionRequest::FillRequestProto() { 94 void PasswordProtectionRequest::FillRequestProto() {
93 request_proto_ = base::MakeUnique<LoginReputationClientRequest>(); 95 request_proto_ = base::MakeUnique<LoginReputationClientRequest>();
94 request_proto_->set_page_url(main_frame_url_.spec()); 96 request_proto_->set_page_url(main_frame_url_.spec());
95 request_proto_->set_trigger_type(request_type_); 97 request_proto_->set_trigger_type(request_type_);
96 password_protection_service_->FillUserPopulation(request_type_, 98 password_protection_service_->FillUserPopulation(request_type_,
97 request_proto_.get()); 99 request_proto_.get());
98 request_proto_->set_stored_verdict_cnt( 100 request_proto_->set_stored_verdict_cnt(
99 password_protection_service_->GetStoredVerdictCount()); 101 password_protection_service_->GetStoredVerdictCount(request_type_));
100 LoginReputationClientRequest::Frame* main_frame = 102 LoginReputationClientRequest::Frame* main_frame =
101 request_proto_->add_frames(); 103 request_proto_->add_frames();
102 main_frame->set_url(main_frame_url_.spec()); 104 main_frame->set_url(main_frame_url_.spec());
103 main_frame->set_frame_index(0 /* main frame */); 105 main_frame->set_frame_index(0 /* main frame */);
104 password_protection_service_->FillReferrerChain( 106 password_protection_service_->FillReferrerChain(
105 main_frame_url_, -1 /* tab id not available */, main_frame); 107 main_frame_url_, -1 /* tab id not available */, main_frame);
106 108
107 switch (request_type_) { 109 switch (request_type_) {
108 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: { 110 case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: {
109 LoginReputationClientRequest::Frame::Form* password_form; 111 LoginReputationClientRequest::Frame::Form* password_form;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void PasswordProtectionRequest::Cancel(bool timed_out) { 277 void PasswordProtectionRequest::Cancel(bool timed_out) {
276 DCHECK_CURRENTLY_ON(BrowserThread::UI); 278 DCHECK_CURRENTLY_ON(BrowserThread::UI);
277 fetcher_.reset(); 279 fetcher_.reset();
278 280
279 Finish(timed_out ? PasswordProtectionService::TIMEDOUT 281 Finish(timed_out ? PasswordProtectionService::TIMEDOUT
280 : PasswordProtectionService::CANCELED, 282 : PasswordProtectionService::CANCELED,
281 nullptr); 283 nullptr);
282 } 284 }
283 285
284 } // namespace safe_browsing 286 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698