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

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

Issue 2929533002: Fill has_password_field for password reuse ping (Closed)
Patch Set: fix broken test due to rebase 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 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 265 }
266 } 266 }
267 } 267 }
268 268
269 void PasswordProtectionService::StartRequest( 269 void PasswordProtectionService::StartRequest(
270 WebContents* web_contents, 270 WebContents* web_contents,
271 const GURL& main_frame_url, 271 const GURL& main_frame_url,
272 const GURL& password_form_action, 272 const GURL& password_form_action,
273 const GURL& password_form_frame_url, 273 const GURL& password_form_frame_url,
274 const std::string& saved_domain, 274 const std::string& saved_domain,
275 LoginReputationClientRequest::TriggerType type) { 275 LoginReputationClientRequest::TriggerType type,
276 bool password_field_exists) {
276 DCHECK_CURRENTLY_ON(BrowserThread::UI); 277 DCHECK_CURRENTLY_ON(BrowserThread::UI);
277 scoped_refptr<PasswordProtectionRequest> request( 278 scoped_refptr<PasswordProtectionRequest> request(
278 new PasswordProtectionRequest(web_contents, main_frame_url, 279 new PasswordProtectionRequest(
279 password_form_action, 280 web_contents, main_frame_url, password_form_action,
280 password_form_frame_url, saved_domain, type, 281 password_form_frame_url, saved_domain, type, password_field_exists,
281 this, GetRequestTimeoutInMS())); 282 this, GetRequestTimeoutInMS()));
282 DCHECK(request); 283 DCHECK(request);
283 request->Start(); 284 request->Start();
284 requests_.insert(std::move(request)); 285 requests_.insert(std::move(request));
285 } 286 }
286 287
287 void PasswordProtectionService::MaybeStartPasswordFieldOnFocusRequest( 288 void PasswordProtectionService::MaybeStartPasswordFieldOnFocusRequest(
288 WebContents* web_contents, 289 WebContents* web_contents,
289 const GURL& main_frame_url, 290 const GURL& main_frame_url,
290 const GURL& password_form_action, 291 const GURL& password_form_action,
291 const GURL& password_form_frame_url) { 292 const GURL& password_form_frame_url) {
292 DCHECK_CURRENTLY_ON(BrowserThread::UI); 293 DCHECK_CURRENTLY_ON(BrowserThread::UI);
293 if (CanSendPing(kPasswordFieldOnFocusPinging, main_frame_url)) { 294 if (CanSendPing(kPasswordFieldOnFocusPinging, main_frame_url)) {
294 StartRequest(web_contents, main_frame_url, password_form_action, 295 StartRequest(web_contents, main_frame_url, password_form_action,
295 password_form_frame_url, 296 password_form_frame_url,
296 std::string(), /* saved_domain: not used for this type */ 297 std::string(), /* saved_domain: not used for this type */
297 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); 298 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, true);
298 } 299 }
299 } 300 }
300 301
301 void PasswordProtectionService::MaybeStartProtectedPasswordEntryRequest( 302 void PasswordProtectionService::MaybeStartProtectedPasswordEntryRequest(
302 WebContents* web_contents, 303 WebContents* web_contents,
303 const GURL& main_frame_url, 304 const GURL& main_frame_url,
304 const std::string& saved_domain) { 305 const std::string& saved_domain,
306 bool password_field_exists) {
305 DCHECK_CURRENTLY_ON(BrowserThread::UI); 307 DCHECK_CURRENTLY_ON(BrowserThread::UI);
306 if (CanSendPing(kProtectedPasswordEntryPinging, main_frame_url)) { 308 if (CanSendPing(kProtectedPasswordEntryPinging, main_frame_url)) {
307 StartRequest(web_contents, main_frame_url, GURL(), GURL(), saved_domain, 309 StartRequest(web_contents, main_frame_url, GURL(), GURL(), saved_domain,
308 LoginReputationClientRequest::PASSWORD_REUSE_EVENT); 310 LoginReputationClientRequest::PASSWORD_REUSE_EVENT,
311 password_field_exists);
309 } 312 }
310 } 313 }
311 314
312 bool PasswordProtectionService::CanSendPing(const base::Feature& feature, 315 bool PasswordProtectionService::CanSendPing(const base::Feature& feature,
313 const GURL& main_frame_url) { 316 const GURL& main_frame_url) {
314 RequestOutcome request_outcome = URL_NOT_VALID_FOR_REPUTATION_COMPUTING; 317 RequestOutcome request_outcome = URL_NOT_VALID_FOR_REPUTATION_COMPUTING;
315 if (IsPingingEnabled(kPasswordFieldOnFocusPinging, &request_outcome) && 318 if (IsPingingEnabled(kPasswordFieldOnFocusPinging, &request_outcome) &&
316 CanGetReputationOfURL(main_frame_url)) { 319 CanGetReputationOfURL(main_frame_url)) {
317 return true; 320 return true;
318 } 321 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 if (is_password_entry_ping) { 585 if (is_password_entry_ping) {
583 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, reason, 586 UMA_HISTOGRAM_ENUMERATION(kPasswordEntryRequestOutcomeHistogramName, reason,
584 MAX_OUTCOME); 587 MAX_OUTCOME);
585 } else { 588 } else {
586 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName, 589 UMA_HISTOGRAM_ENUMERATION(kPasswordOnFocusRequestOutcomeHistogramName,
587 reason, MAX_OUTCOME); 590 reason, MAX_OUTCOME);
588 } 591 }
589 } 592 }
590 593
591 } // namespace safe_browsing 594 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698