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_autofill_agent.h" | 5 #include "components/autofill/content/renderer/password_autofill_agent.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 web_input_to_password_info_[iter->second].password_was_edited_last = true; | 720 web_input_to_password_info_[iter->second].password_was_edited_last = true; |
721 // Note that the suggested value of |mutable_element| was reset when its | 721 // Note that the suggested value of |mutable_element| was reset when its |
722 // value changed. | 722 // value changed. |
723 mutable_element.setAutofilled(false); | 723 mutable_element.setAutofilled(false); |
724 } | 724 } |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 bool PasswordAutofillAgent::FillSuggestion( | 728 bool PasswordAutofillAgent::FillSuggestion( |
729 const blink::WebFormControlElement& control_element, | 729 const blink::WebFormControlElement& control_element, |
730 const blink::WebString& username, | 730 const base::string16& username, |
731 const blink::WebString& password) { | 731 const base::string16& password) { |
732 // The element in context of the suggestion popup. | 732 // The element in context of the suggestion popup. |
733 const blink::WebInputElement* element = toWebInputElement(&control_element); | 733 const blink::WebInputElement* element = toWebInputElement(&control_element); |
734 if (!element) | 734 if (!element) |
735 return false; | 735 return false; |
736 | 736 |
737 blink::WebInputElement username_element; | 737 blink::WebInputElement username_element; |
738 blink::WebInputElement password_element; | 738 blink::WebInputElement password_element; |
739 PasswordInfo* password_info; | 739 PasswordInfo* password_info; |
740 | 740 |
741 if (!FindPasswordInfoForElement(*element, &username_element, | 741 if (!FindPasswordInfoForElement(*element, &username_element, |
742 &password_element, &password_info) || | 742 &password_element, &password_info) || |
743 (!username_element.isNull() && | 743 (!username_element.isNull() && |
744 !IsElementAutocompletable(username_element)) || | 744 !IsElementAutocompletable(username_element)) || |
745 !IsElementAutocompletable(password_element)) { | 745 !IsElementAutocompletable(password_element)) { |
746 return false; | 746 return false; |
747 } | 747 } |
748 | 748 |
749 password_info->password_was_edited_last = false; | 749 password_info->password_was_edited_last = false; |
750 if (element->isPasswordField()) { | 750 if (element->isPasswordField()) { |
751 password_info->password_field_suggestion_was_accepted = true; | 751 password_info->password_field_suggestion_was_accepted = true; |
752 password_info->password_field = password_element; | 752 password_info->password_field = password_element; |
753 } else if (!username_element.isNull()) { | 753 } else if (!username_element.isNull()) { |
754 username_element.setValue(username, true); | 754 username_element.setValue(blink::WebString(username), true); |
755 username_element.setAutofilled(true); | 755 username_element.setAutofilled(true); |
756 const base::string16 username_value = username; | 756 UpdateFieldValueAndPropertiesMaskMap(username_element, &username, |
757 UpdateFieldValueAndPropertiesMaskMap(username_element, &username_value, | |
758 FieldPropertiesFlags::AUTOFILLED, | 757 FieldPropertiesFlags::AUTOFILLED, |
759 &field_value_and_properties_map_); | 758 &field_value_and_properties_map_); |
760 } | 759 } |
761 | 760 |
762 password_element.setValue(password, true); | 761 password_element.setValue(blink::WebString(password), true); |
763 password_element.setAutofilled(true); | 762 password_element.setAutofilled(true); |
764 const base::string16 password_value = password; | 763 UpdateFieldValueAndPropertiesMaskMap(password_element, &password, |
765 UpdateFieldValueAndPropertiesMaskMap(password_element, &password_value, | |
766 FieldPropertiesFlags::AUTOFILLED, | 764 FieldPropertiesFlags::AUTOFILLED, |
767 &field_value_and_properties_map_); | 765 &field_value_and_properties_map_); |
768 | 766 |
769 blink::WebInputElement mutable_filled_element = *element; | 767 blink::WebInputElement mutable_filled_element = *element; |
770 mutable_filled_element.setSelectionRange(element->value().length(), | 768 mutable_filled_element.setSelectionRange(element->value().length(), |
771 element->value().length()); | 769 element->value().length()); |
772 | 770 |
773 return true; | 771 return true; |
774 } | 772 } |
775 | 773 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 !(provisionally_saved_form_->password_value.empty() && | 1530 !(provisionally_saved_form_->password_value.empty() && |
1533 provisionally_saved_form_->new_password_value.empty()); | 1531 provisionally_saved_form_->new_password_value.empty()); |
1534 } | 1532 } |
1535 | 1533 |
1536 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() { | 1534 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() { |
1537 DCHECK(autofill_agent_); | 1535 DCHECK(autofill_agent_); |
1538 return autofill_agent_->GetAutofillDriver(); | 1536 return autofill_agent_->GetAutofillDriver(); |
1539 } | 1537 } |
1540 | 1538 |
1541 } // namespace autofill | 1539 } // namespace autofill |
OLD | NEW |