diff options
author | dvadym <dvadym@chromium.org> | 2015-01-07 01:27:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-07 09:28:33 +0000 |
commit | 1cdd1996e8a560bce1a366aea34d20727b9e148e (patch) | |
tree | 66341c7d479bd29ba16e258be12fcfbb066c872c /components/autofill | |
parent | 9ade510cebe925b283837fbe210cc7eafb14660a (diff) | |
download | chromium_src-1cdd1996e8a560bce1a366aea34d20727b9e148e.zip chromium_src-1cdd1996e8a560bce1a366aea34d20727b9e148e.tar.gz chromium_src-1cdd1996e8a560bce1a366aea34d20727b9e148e.tar.bz2 |
Save autofilled not last typed username in PasswordManager
In http://crbug.com/405574 it was implemented that last typed username and password are stored on TextChanged event before JavaScript can change them. There is a problem when username is autofilled. Since autofilling doesn't raise TextChange event, we can't save autofilled value. This CL will keep the current value of the username field if it's prepended by the characters the user has typed before.
BUG=444775
Review URL: https://codereview.chromium.org/825653002
Cr-Commit-Position: refs/heads/master@{#310257}
Diffstat (limited to 'components/autofill')
-rw-r--r-- | components/autofill/content/renderer/password_form_conversion_utils.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc index 0aac01b..52c510a6 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils.cc +++ b/components/autofill/content/renderer/password_form_conversion_utils.cc @@ -197,11 +197,18 @@ void GetPasswordForm(const WebFormElement& form, if (!username_element.isNull()) { password_form->username_element = username_element.nameForAutofill(); - blink::WebString username_value = username_element.value(); + base::string16 username_value = username_element.value(); if (user_modified_elements != nullptr) { auto username_iterator = user_modified_elements->find(username_element); - if (username_iterator != user_modified_elements->end()) - username_value = username_iterator->second; + if (username_iterator != user_modified_elements->end()) { + base::string16 typed_username_value = username_iterator->second; + if (!StartsWith(username_value, typed_username_value, false)) { + // We check that |username_value| was not obtained by autofilling + // |typed_username_value|. In case when it was, |typed_username_value| + // is incomplete, so we should leave autofilled value. + username_value = typed_username_value; + } + } } password_form->username_value = username_value; } |