| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/content/renderer/password_form_conversion_utils.h" | 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "components/autofill/content/renderer/form_autofill_util.h" | 13 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 13 #include "components/autofill/core/common/form_data_predictions.h" | 14 #include "components/autofill/core/common/form_data_predictions.h" |
| 14 #include "components/autofill/core/common/password_form.h" | 15 #include "components/autofill/core/common/password_form.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/web/WebDocument.h" | 17 #include "third_party/WebKit/public/web/WebDocument.h" |
| 17 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 18 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 18 #include "third_party/WebKit/public/web/WebInputElement.h" | 19 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 19 #include "third_party/icu/source/i18n/unicode/regex.h" | 20 #include "third_party/icu/source/i18n/unicode/regex.h" |
| 20 | 21 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 base::string16 typed_username_value = username_iterator->second; | 362 base::string16 typed_username_value = username_iterator->second; |
| 362 if (!StartsWith(username_value, typed_username_value, false)) { | 363 if (!StartsWith(username_value, typed_username_value, false)) { |
| 363 // We check that |username_value| was not obtained by autofilling | 364 // We check that |username_value| was not obtained by autofilling |
| 364 // |typed_username_value|. In case when it was, |typed_username_value| | 365 // |typed_username_value|. In case when it was, |typed_username_value| |
| 365 // is incomplete, so we should leave autofilled value. | 366 // is incomplete, so we should leave autofilled value. |
| 366 username_value = typed_username_value; | 367 username_value = typed_username_value; |
| 367 } | 368 } |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 password_form->username_value = username_value; | 371 password_form->username_value = username_value; |
| 372 } else { |
| 373 // To get a better idea on how forms without a username field look like, |
| 374 // report the total number of text and password fields. |
| 375 UMA_HISTOGRAM_COUNTS_100( |
| 376 "PasswordManager.EmptyUsernames.TextAndPasswordFieldCount", |
| 377 layout_sequence.size()); |
| 371 } | 378 } |
| 372 | 379 |
| 373 WebInputElement password; | 380 WebInputElement password; |
| 374 WebInputElement new_password; | 381 WebInputElement new_password; |
| 375 if (!LocateSpecificPasswords(passwords, &password, &new_password)) | 382 if (!LocateSpecificPasswords(passwords, &password, &new_password)) |
| 376 return; | 383 return; |
| 377 | 384 |
| 378 password_form->action = GetCanonicalActionForForm(form); | 385 password_form->action = GetCanonicalActionForForm(form); |
| 379 if (!password_form->action.is_valid()) | 386 if (!password_form->action.is_valid()) |
| 380 return; | 387 return; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 WebFormElementToFormData(web_form, | 463 WebFormElementToFormData(web_form, |
| 457 blink::WebFormControlElement(), | 464 blink::WebFormControlElement(), |
| 458 EXTRACT_NONE, | 465 EXTRACT_NONE, |
| 459 &password_form->form_data, | 466 &password_form->form_data, |
| 460 NULL /* FormFieldData */); | 467 NULL /* FormFieldData */); |
| 461 | 468 |
| 462 return password_form.Pass(); | 469 return password_form.Pass(); |
| 463 } | 470 } |
| 464 | 471 |
| 465 } // namespace autofill | 472 } // namespace autofill |
| OLD | NEW |