Chromium Code Reviews| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), | 254 CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), |
| 255 std::move(verdict_dictionary)); | 255 std::move(verdict_dictionary)); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 void PasswordProtectionService::StartRequest( | 260 void PasswordProtectionService::StartRequest( |
| 261 const GURL& main_frame_url, | 261 const GURL& main_frame_url, |
| 262 const GURL& password_form_action, | 262 const GURL& password_form_action, |
| 263 const GURL& password_form_frame_url, | 263 const GURL& password_form_frame_url, |
| 264 const std::string& legitimate_domain, | |
| 264 LoginReputationClientRequest::TriggerType type) { | 265 LoginReputationClientRequest::TriggerType type) { |
| 265 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 266 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 266 scoped_refptr<PasswordProtectionRequest> request( | 267 scoped_refptr<PasswordProtectionRequest> request( |
| 267 new PasswordProtectionRequest(main_frame_url, password_form_action, | 268 new PasswordProtectionRequest(main_frame_url, password_form_action, |
| 268 password_form_frame_url, type, this, | 269 password_form_frame_url, legitimate_domain, |
| 269 GetRequestTimeoutInMS())); | 270 type, this, GetRequestTimeoutInMS())); |
| 270 DCHECK(request); | 271 DCHECK(request); |
| 271 request->Start(); | 272 request->Start(); |
| 272 requests_.insert(std::move(request)); | 273 requests_.insert(std::move(request)); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void PasswordProtectionService::MaybeStartLowReputationRequest( | 276 void PasswordProtectionService::MaybeStartLowReputationRequest( |
| 276 const GURL& main_frame_url, | 277 const GURL& main_frame_url, |
| 277 const GURL& password_form_action, | 278 const GURL& password_form_action, |
| 278 const GURL& password_form_frame_url) { | 279 const GURL& password_form_frame_url) { |
| 279 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 280 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 280 if (!IsPingingEnabled(kPasswordFieldOnFocusPinging)) | 281 if (!IsPingingEnabled(kPasswordFieldOnFocusPinging)) |
| 281 return; | 282 return; |
| 282 | 283 |
| 283 // Skip URLs that we can't get a reliable reputation for. | 284 // Skip URLs that we can't get a reliable reputation for. |
| 284 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { | 285 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { |
| 285 return; | 286 return; |
| 286 } | 287 } |
| 287 | 288 |
| 288 StartRequest(main_frame_url, password_form_action, password_form_frame_url, | 289 StartRequest(main_frame_url, password_form_action, password_form_frame_url, |
| 290 std::string(), | |
|
Nathan Parker
2017/05/12 22:28:00
/* legitimate_domain: not used for this type */
Jialiu Lin
2017/05/13 00:24:12
Done.
| |
| 289 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); | 291 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); |
| 290 } | 292 } |
| 291 | 293 |
| 294 void PasswordProtectionService::MaybeStartProtectedPasswordEntryRequest( | |
| 295 const GURL& main_frame_url, | |
| 296 const std::string& legitimate_domain) { | |
| 297 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 298 if (!IsPingingEnabled(kProtectedPasswordEntryPinging)) | |
| 299 return; | |
| 300 | |
| 301 // Skip URLs that we can't get a reliable reputation for. | |
| 302 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { | |
| 303 return; | |
| 304 } | |
| 305 | |
| 306 StartRequest(main_frame_url, GURL(), GURL(), legitimate_domain, | |
| 307 LoginReputationClientRequest::PASSWORD_REUSE_EVENT); | |
| 308 } | |
| 309 | |
| 292 void PasswordProtectionService::RequestFinished( | 310 void PasswordProtectionService::RequestFinished( |
| 293 PasswordProtectionRequest* request, | 311 PasswordProtectionRequest* request, |
| 294 std::unique_ptr<LoginReputationClientResponse> response) { | 312 std::unique_ptr<LoginReputationClientResponse> response) { |
| 295 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 313 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 296 | 314 |
| 297 DCHECK(request); | 315 DCHECK(request); |
| 298 // TODO(jialiul): We don't cache verdict for incognito mode for now. | 316 // TODO(jialiul): We don't cache verdict for incognito mode for now. |
| 299 // Later we may consider temporarily caching verdict. | 317 // Later we may consider temporarily caching verdict. |
| 300 if (response && !IsIncognito()) | 318 if (response && !IsIncognito()) |
| 301 CacheVerdict(request->main_frame_url(), response.get(), base::Time::Now()); | 319 CacheVerdict(request->main_frame_url(), response.get(), base::Time::Now()); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 const std::vector<char> verdict_blob(serialized_proto.begin(), | 552 const std::vector<char> verdict_blob(serialized_proto.begin(), |
| 535 serialized_proto.end()); | 553 serialized_proto.end()); |
| 536 std::unique_ptr<base::Value> binary_value = | 554 std::unique_ptr<base::Value> binary_value = |
| 537 base::MakeUnique<base::Value>(verdict_blob); | 555 base::MakeUnique<base::Value>(verdict_blob); |
| 538 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); | 556 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); |
| 539 result->Set(kVerdictProto, std::move(binary_value)); | 557 result->Set(kVerdictProto, std::move(binary_value)); |
| 540 return result; | 558 return result; |
| 541 } | 559 } |
| 542 | 560 |
| 543 } // namespace safe_browsing | 561 } // namespace safe_browsing |
| OLD | NEW |