Chromium Code Reviews| Index: components/autofill/content/renderer/password_autofill_agent.cc |
| diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc |
| index f0dcefd80475482fc096bf1c14839fd18cab75d4..6fcc4e9e10af884818300135ce3e45879086a60f 100644 |
| --- a/components/autofill/content/renderer/password_autofill_agent.cc |
| +++ b/components/autofill/content/renderer/password_autofill_agent.cc |
| @@ -17,6 +17,7 @@ |
| #include "components/autofill/content/renderer/renderer_save_password_progress_logger.h" |
| #include "components/autofill/core/common/autofill_constants.h" |
| #include "components/autofill/core/common/autofill_switches.h" |
| +#include "components/autofill/core/common/autofill_util.h" |
| #include "components/autofill/core/common/form_field_data.h" |
| #include "components/autofill/core/common/password_form.h" |
| #include "components/autofill/core/common/password_form_fill_data.h" |
| @@ -225,7 +226,8 @@ bool DoUsernamesMatch(const base::string16& username1, |
| bool exact_match) { |
| if (exact_match) |
| return username1 == username2; |
| - return base::StartsWith(username1, username2, true); |
| + return base::StartsWith(username1, username2, true) || |
| + ContainsTokenThatStartsWith(username1, username2, true); |
| } |
| // Returns |true| if the given element is editable. Otherwise, returns |false|. |
| @@ -413,11 +415,8 @@ bool FillUserNameAndPassword( |
| username_element->setValue(username, true); |
| nonscript_modified_values[*username_element] = username; |
| username_element->setAutofilled(true); |
| - |
| - if (set_selection) { |
| - username_element->setSelectionRange(current_username.length(), |
| - username.length()); |
| - } |
| + if (set_selection) |
| + PreviewSuggestion(username_element, username, current_username); |
| } else if (current_username != username) { |
| // If the username can't be filled and it doesn't match a saved password |
| // as is, don't autofill a password. |
| @@ -795,10 +794,8 @@ bool PasswordAutofillAgent::PreviewSuggestion( |
| username_selection_start_ = username_element.selectionStart(); |
| username_element.setSuggestedValue(username); |
| username_element.setAutofilled(true); |
| - username_element.setSelectionRange( |
| - username_selection_start_, |
| - username_element.suggestedValue().length()); |
| - |
| + ::autofill::PreviewSuggestion(&username_element, username, |
|
please use gerrit instead
2015/06/30 19:06:23
You should pass in username_element.suggestedValue
Pritam Nikam
2015/07/01 17:26:00
Done.
|
| + username_element.value()); |
| was_password_autofilled_ = password_info->password_field.isAutofilled(); |
| password_info->password_field.setSuggestedValue(password); |
| password_info->password_field.setAutofilled(true); |