| 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 #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/safe_browsing_db/database_manager.h" | 10 #include "components/safe_browsing_db/database_manager.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 weakptr_factory_(this) { | 34 weakptr_factory_(this) { |
| 35 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 35 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 36 } | 36 } |
| 37 | 37 |
| 38 PasswordProtectionRequest::~PasswordProtectionRequest() { | 38 PasswordProtectionRequest::~PasswordProtectionRequest() { |
| 39 weakptr_factory_.InvalidateWeakPtrs(); | 39 weakptr_factory_.InvalidateWeakPtrs(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void PasswordProtectionRequest::Start() { | 42 void PasswordProtectionRequest::Start() { |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 43 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 44 // Initially we only send ping for Safe Browsing Extended Reporting users when | |
| 45 // they are not in incognito mode. We may loose these conditions later. | |
| 46 if (password_protection_service_->IsIncognito()) { | |
| 47 Finish(RequestOutcome::INCOGNITO, nullptr); | |
| 48 return; | |
| 49 } | |
| 50 if (!password_protection_service_->IsExtendedReporting()) { | |
| 51 Finish(RequestOutcome::NO_EXTENDED_REPORTING, nullptr); | |
| 52 return; | |
| 53 } | |
| 54 | |
| 55 CheckWhitelistOnUIThread(); | 44 CheckWhitelistOnUIThread(); |
| 56 } | 45 } |
| 57 | 46 |
| 58 void PasswordProtectionRequest::CheckWhitelistOnUIThread() { | 47 void PasswordProtectionRequest::CheckWhitelistOnUIThread() { |
| 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 60 bool* match_whitelist = new bool(false); | 49 bool* match_whitelist = new bool(false); |
| 61 tracker_.PostTaskAndReply( | 50 tracker_.PostTaskAndReply( |
| 62 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), FROM_HERE, | 51 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), FROM_HERE, |
| 63 base::Bind(&PasswordProtectionService::CheckCsdWhitelistOnIOThread, | 52 base::Bind(&PasswordProtectionService::CheckCsdWhitelistOnIOThread, |
| 64 base::Unretained(password_protection_service_), | 53 base::Unretained(password_protection_service_), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED) | 79 if (verdict != LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED) |
| 91 Finish(RequestOutcome::RESPONSE_ALREADY_CACHED, std::move(cached_response)); | 80 Finish(RequestOutcome::RESPONSE_ALREADY_CACHED, std::move(cached_response)); |
| 92 else | 81 else |
| 93 SendRequest(); | 82 SendRequest(); |
| 94 } | 83 } |
| 95 | 84 |
| 96 void PasswordProtectionRequest::FillRequestProto() { | 85 void PasswordProtectionRequest::FillRequestProto() { |
| 97 request_proto_ = base::MakeUnique<LoginReputationClientRequest>(); | 86 request_proto_ = base::MakeUnique<LoginReputationClientRequest>(); |
| 98 request_proto_->set_page_url(main_frame_url_.spec()); | 87 request_proto_->set_page_url(main_frame_url_.spec()); |
| 99 request_proto_->set_trigger_type(request_type_); | 88 request_proto_->set_trigger_type(request_type_); |
| 89 password_protection_service_->FillUserPopulation(request_type_, |
| 90 request_proto_.get()); |
| 100 request_proto_->set_stored_verdict_cnt( | 91 request_proto_->set_stored_verdict_cnt( |
| 101 password_protection_service_->GetStoredVerdictCount()); | 92 password_protection_service_->GetStoredVerdictCount()); |
| 102 LoginReputationClientRequest::Frame* main_frame = | 93 LoginReputationClientRequest::Frame* main_frame = |
| 103 request_proto_->add_frames(); | 94 request_proto_->add_frames(); |
| 104 main_frame->set_url(main_frame_url_.spec()); | 95 main_frame->set_url(main_frame_url_.spec()); |
| 105 main_frame->set_frame_index(0 /* main frame */); | 96 main_frame->set_frame_index(0 /* main frame */); |
| 106 password_protection_service_->FillReferrerChain( | 97 password_protection_service_->FillReferrerChain( |
| 107 main_frame_url_, -1 /* tab id not available */, main_frame); | 98 main_frame_url_, -1 /* tab id not available */, main_frame); |
| 108 LoginReputationClientRequest::Frame::Form* password_form; | 99 LoginReputationClientRequest::Frame::Form* password_form; |
| 109 if (password_form_frame_url_ == main_frame_url_) { | 100 if (password_form_frame_url_ == main_frame_url_) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 217 } |
| 227 | 218 |
| 228 void PasswordProtectionRequest::Cancel(bool timed_out) { | 219 void PasswordProtectionRequest::Cancel(bool timed_out) { |
| 229 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 220 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 230 fetcher_.reset(); | 221 fetcher_.reset(); |
| 231 | 222 |
| 232 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr); | 223 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr); |
| 233 } | 224 } |
| 234 | 225 |
| 235 } // namespace safe_browsing | 226 } // namespace safe_browsing |
| OLD | NEW |