OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/password_manager/core/browser/password_form_manager.h" | 5 #include "components/password_manager/core/browser/password_form_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 kMaxNumActionsTaken); | 257 kMaxNumActionsTaken); |
258 | 258 |
259 // Use the visible main frame URL at the time the PasswordFormManager | 259 // Use the visible main frame URL at the time the PasswordFormManager |
260 // is created, in case a navigation has already started and the | 260 // is created, in case a navigation has already started and the |
261 // visible URL has changed. | 261 // visible URL has changed. |
262 if (!is_main_frame_secure_) { | 262 if (!is_main_frame_secure_) { |
263 UMA_HISTOGRAM_ENUMERATION("PasswordManager.ActionsTakenOnNonSecureForm", | 263 UMA_HISTOGRAM_ENUMERATION("PasswordManager.ActionsTakenOnNonSecureForm", |
264 GetActionsTaken(), kMaxNumActionsTaken); | 264 GetActionsTaken(), kMaxNumActionsTaken); |
265 } | 265 } |
266 | 266 |
267 if (!observed_form_.origin.SchemeIsCryptographic()) { | 267 RecordHistogramsOnSuppressedAccounts(); |
268 UMA_HISTOGRAM_BOOLEAN( | |
269 "PasswordManager.QueryingSuppressedAccountsFinished", | |
270 form_fetcher_->DidCompleteQueryingSuppressedHTTPSForms()); | |
271 if (form_fetcher_->DidCompleteQueryingSuppressedHTTPSForms()) { | |
272 UMA_HISTOGRAM_ENUMERATION( | |
273 "PasswordManager.SuppressedAccount.Generated.HTTPSNotHTTP", | |
274 GetStatsForSuppressedHTTPSAccount(PasswordForm::TYPE_GENERATED), | |
275 kMaxSuppressedAccountStats); | |
276 UMA_HISTOGRAM_ENUMERATION( | |
277 "PasswordManager.SuppressedAccount.Manual.HTTPSNotHTTP", | |
278 GetStatsForSuppressedHTTPSAccount(PasswordForm::TYPE_MANUAL), | |
279 kMaxSuppressedAccountStats); | |
280 } | |
281 } | |
282 | 268 |
283 if (submit_result_ == kSubmitResultNotSubmitted) { | 269 if (submit_result_ == kSubmitResultNotSubmitted) { |
284 if (has_generated_password_) | 270 if (has_generated_password_) |
285 metrics_util::LogPasswordGenerationSubmissionEvent( | 271 metrics_util::LogPasswordGenerationSubmissionEvent( |
286 metrics_util::PASSWORD_NOT_SUBMITTED); | 272 metrics_util::PASSWORD_NOT_SUBMITTED); |
287 else if (generation_available_) | 273 else if (generation_available_) |
288 metrics_util::LogPasswordGenerationAvailableSubmissionEvent( | 274 metrics_util::LogPasswordGenerationAvailableSubmissionEvent( |
289 metrics_util::PASSWORD_NOT_SUBMITTED); | 275 metrics_util::PASSWORD_NOT_SUBMITTED); |
290 } | 276 } |
291 | 277 |
292 if (form_type_ != kFormTypeUnspecified) { | 278 if (form_type_ != kFormTypeUnspecified) { |
293 UMA_HISTOGRAM_ENUMERATION("PasswordManager.SubmittedFormType", form_type_, | 279 UMA_HISTOGRAM_ENUMERATION("PasswordManager.SubmittedFormType", form_type_, |
294 kFormTypeMax); | 280 kFormTypeMax); |
295 if (!is_main_frame_secure_) { | 281 if (!is_main_frame_secure_) { |
296 UMA_HISTOGRAM_ENUMERATION("PasswordManager.SubmittedNonSecureFormType", | 282 UMA_HISTOGRAM_ENUMERATION("PasswordManager.SubmittedNonSecureFormType", |
297 form_type_, kFormTypeMax); | 283 form_type_, kFormTypeMax); |
298 } | 284 } |
299 } | 285 } |
300 } | 286 } |
301 | 287 |
302 int PasswordFormManager::GetActionsTaken() const { | 288 int PasswordFormManager::GetActionsTaken() const { |
303 return user_action_ + | 289 return user_action_ + |
304 kUserActionMax * | 290 kUserActionMax * |
305 (manager_action_ + kManagerActionMax * submit_result_); | 291 (manager_action_ + kManagerActionMax * submit_result_); |
306 } | 292 } |
307 | 293 |
308 int PasswordFormManager::GetStatsForSuppressedHTTPSAccount( | 294 int PasswordFormManager::GetHistogramSampleForSuppressedAccounts( |
309 PasswordForm::Type type) const { | 295 const std::vector<const autofill::PasswordForm*> suppressed_forms, |
310 DCHECK(form_fetcher_->DidCompleteQueryingSuppressedHTTPSForms()); | 296 PasswordForm::Type manual_or_generated) const { |
297 DCHECK(form_fetcher_->DidCompleteQueryingSuppressedForms()); | |
311 | 298 |
312 SuppressedAccountExistence best_matching_account = kSuppressedAccountNone; | 299 SuppressedAccountExistence best_matching_account = kSuppressedAccountNone; |
313 for (const autofill::PasswordForm* form : | 300 for (const autofill::PasswordForm* form : suppressed_forms) { |
314 form_fetcher_->GetSuppressedHTTPSForms()) { | 301 if (form->type != manual_or_generated) |
315 if (form->type != type) | |
316 continue; | 302 continue; |
317 | 303 |
318 SuppressedAccountExistence current_account; | 304 SuppressedAccountExistence current_account; |
319 if (pending_credentials_.password_value.empty()) | 305 if (pending_credentials_.password_value.empty()) |
320 current_account = kSuppressedAccountExists; | 306 current_account = kSuppressedAccountExists; |
321 else if (form->username_value != pending_credentials_.username_value) | 307 else if (form->username_value != pending_credentials_.username_value) |
322 current_account = kSuppressedAccountExistsDifferentUsername; | 308 current_account = kSuppressedAccountExistsDifferentUsername; |
323 else if (form->password_value != pending_credentials_.password_value) | 309 else if (form->password_value != pending_credentials_.password_value) |
324 current_account = kSuppressedAccountExistsSameUsername; | 310 current_account = kSuppressedAccountExistsSameUsername; |
325 else | 311 else |
(...skipping 12 matching lines...) Expand all Loading... | |
338 // Encoding: most significant digit is the |best_matching_account|. | 324 // Encoding: most significant digit is the |best_matching_account|. |
339 int mixed_base_encoding = 0; | 325 int mixed_base_encoding = 0; |
340 mixed_base_encoding += best_matching_account; | 326 mixed_base_encoding += best_matching_account; |
341 (mixed_base_encoding *= kSubmitResultMax) += submit_result_; | 327 (mixed_base_encoding *= kSubmitResultMax) += submit_result_; |
342 (mixed_base_encoding *= kManagerActionNewMax) += manager_action_new; | 328 (mixed_base_encoding *= kManagerActionNewMax) += manager_action_new; |
343 (mixed_base_encoding *= kUserActionMax) += user_action_; | 329 (mixed_base_encoding *= kUserActionMax) += user_action_; |
344 DCHECK_LT(mixed_base_encoding, kMaxSuppressedAccountStats); | 330 DCHECK_LT(mixed_base_encoding, kMaxSuppressedAccountStats); |
345 return mixed_base_encoding; | 331 return mixed_base_encoding; |
346 } | 332 } |
347 | 333 |
334 void PasswordFormManager::RecordHistogramsOnSuppressedAccounts() const { | |
335 UMA_HISTOGRAM_BOOLEAN("PasswordManager.QueryingSuppressedAccountsFinished", | |
336 form_fetcher_->DidCompleteQueryingSuppressedForms()); | |
337 | |
338 if (!form_fetcher_->DidCompleteQueryingSuppressedForms()) | |
339 return; | |
340 | |
341 if (!observed_form_.origin.SchemeIsCryptographic()) { | |
342 UMA_HISTOGRAM_ENUMERATION( | |
343 "PasswordManager.SuppressedAccount.Generated.HTTPSNotHTTP", | |
344 GetHistogramSampleForSuppressedAccounts( | |
345 form_fetcher_->GetSuppressedHTTPSForms(), | |
346 PasswordForm::TYPE_GENERATED), | |
347 kMaxSuppressedAccountStats); | |
348 UMA_HISTOGRAM_ENUMERATION( | |
349 "PasswordManager.SuppressedAccount.Manual.HTTPSNotHTTP", | |
350 GetHistogramSampleForSuppressedAccounts( | |
351 form_fetcher_->GetSuppressedHTTPSForms(), | |
352 PasswordForm::TYPE_MANUAL), | |
353 kMaxSuppressedAccountStats); | |
354 } | |
355 | |
356 UMA_HISTOGRAM_ENUMERATION( | |
357 "PasswordManager.SuppressedAccount.Generated.PSLMatching", | |
dvadym
2017/05/30 14:17:00
What're the other reasons except http vs https whe
engedy
2017/05/30 14:21:25
That's a bit tricky. In these histograms, PSL matc
| |
358 GetHistogramSampleForSuppressedAccounts( | |
359 form_fetcher_->GetSuppressedPSLMatchingForms(), | |
360 PasswordForm::TYPE_GENERATED), | |
361 kMaxSuppressedAccountStats); | |
362 UMA_HISTOGRAM_ENUMERATION( | |
363 "PasswordManager.SuppressedAccount.Manual.PSLMatching", | |
364 GetHistogramSampleForSuppressedAccounts( | |
365 form_fetcher_->GetSuppressedPSLMatchingForms(), | |
366 PasswordForm::TYPE_MANUAL), | |
367 kMaxSuppressedAccountStats); | |
368 | |
369 UMA_HISTOGRAM_ENUMERATION( | |
370 "PasswordManager.SuppressedAccount.Generated.SameOrganizationName", | |
371 GetHistogramSampleForSuppressedAccounts( | |
372 form_fetcher_->GetSuppressedSameOrganizationNameForms(), | |
373 PasswordForm::TYPE_GENERATED), | |
374 kMaxSuppressedAccountStats); | |
375 UMA_HISTOGRAM_ENUMERATION( | |
376 "PasswordManager.SuppressedAccount.Manual.SameOrganizationName", | |
377 GetHistogramSampleForSuppressedAccounts( | |
378 form_fetcher_->GetSuppressedSameOrganizationNameForms(), | |
379 PasswordForm::TYPE_MANUAL), | |
380 kMaxSuppressedAccountStats); | |
381 } | |
382 | |
348 // static | 383 // static |
349 base::string16 PasswordFormManager::PasswordToSave(const PasswordForm& form) { | 384 base::string16 PasswordFormManager::PasswordToSave(const PasswordForm& form) { |
350 if (form.new_password_element.empty() || form.new_password_value.empty()) | 385 if (form.new_password_element.empty() || form.new_password_value.empty()) |
351 return form.password_value; | 386 return form.password_value; |
352 return form.new_password_value; | 387 return form.new_password_value; |
353 } | 388 } |
354 | 389 |
355 // TODO(crbug.com/700420): Refactor this function, to make comparison more | 390 // TODO(crbug.com/700420): Refactor this function, to make comparison more |
356 // reliable. | 391 // reliable. |
357 PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage( | 392 PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage( |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1465 credentials_to_update->back().password_value = | 1500 credentials_to_update->back().password_value = |
1466 pending_credentials_.password_value; | 1501 pending_credentials_.password_value; |
1467 } | 1502 } |
1468 } | 1503 } |
1469 } | 1504 } |
1470 | 1505 |
1471 return old_primary_key; | 1506 return old_primary_key; |
1472 } | 1507 } |
1473 | 1508 |
1474 } // namespace password_manager | 1509 } // namespace password_manager |
OLD | NEW |