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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if (password.empty()) | 453 if (password.empty()) |
454 return false; | 454 return false; |
455 | 455 |
456 // TODO(tkent): Check maxlength and pattern for both username and password | 456 // TODO(tkent): Check maxlength and pattern for both username and password |
457 // fields. | 457 // fields. |
458 | 458 |
459 // Input matches the username, fill in required values. | 459 // Input matches the username, fill in required values. |
460 if (!username_element->isNull() && | 460 if (!username_element->isNull() && |
461 IsElementAutocompletable(*username_element)) { | 461 IsElementAutocompletable(*username_element)) { |
462 // TODO(crbug.com/507714): Why not setSuggestedValue? | 462 // TODO(crbug.com/507714): Why not setSuggestedValue? |
463 username_element->setValue(blink::WebString::fromUTF16(username), true); | 463 username_element->setAutofillValue(blink::WebString::fromUTF16(username)); |
464 UpdateFieldValueAndPropertiesMaskMap(*username_element, &username, | 464 UpdateFieldValueAndPropertiesMaskMap(*username_element, &username, |
465 FieldPropertiesFlags::AUTOFILLED, | 465 FieldPropertiesFlags::AUTOFILLED, |
466 field_value_and_properties_map); | 466 field_value_and_properties_map); |
467 username_element->setAutofilled(true); | 467 username_element->setAutofilled(true); |
468 if (logger) | 468 if (logger) |
469 logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element); | 469 logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element); |
470 if (set_selection) { | 470 if (set_selection) { |
471 form_util::PreviewSuggestion(username, current_username, | 471 form_util::PreviewSuggestion(username, current_username, |
472 username_element); | 472 username_element); |
473 } | 473 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // select to fill the password element, so the password element must be marked | 548 // select to fill the password element, so the password element must be marked |
549 // as autofilled and the fill step should also be skipped if the user is not | 549 // as autofilled and the fill step should also be skipped if the user is not |
550 // in the "no highlighting" group. | 550 // in the "no highlighting" group. |
551 // | 551 // |
552 // In all other cases, do nothing. | 552 // In all other cases, do nothing. |
553 bool form_has_fillable_username = !username_field_name.empty() && | 553 bool form_has_fillable_username = !username_field_name.empty() && |
554 IsElementAutocompletable(username_element); | 554 IsElementAutocompletable(username_element); |
555 | 555 |
556 if (form_has_fillable_username && username_element.value().isEmpty()) { | 556 if (form_has_fillable_username && username_element.value().isEmpty()) { |
557 // TODO(tkent): Check maxlength and pattern. | 557 // TODO(tkent): Check maxlength and pattern. |
558 username_element.setValue( | 558 username_element.setAutofillValue( |
559 blink::WebString::fromUTF16(fill_data.username_field.value), true); | 559 blink::WebString::fromUTF16(fill_data.username_field.value)); |
560 } | 560 } |
561 | 561 |
562 // Fill if we have an exact match for the username. Note that this sets | 562 // Fill if we have an exact match for the username. Note that this sets |
563 // username to autofilled. | 563 // username to autofilled. |
564 return FillUserNameAndPassword( | 564 return FillUserNameAndPassword( |
565 &username_element, &password_element, fill_data, | 565 &username_element, &password_element, fill_data, |
566 true /* exact_username_match */, false /* set_selection */, | 566 true /* exact_username_match */, false /* set_selection */, |
567 field_value_and_properties_map, registration_callback, logger); | 567 field_value_and_properties_map, registration_callback, logger); |
568 } | 568 } |
569 | 569 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 } | 653 } |
654 | 654 |
655 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() { | 655 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() { |
656 was_user_gesture_seen_ = false; | 656 was_user_gesture_seen_ = false; |
657 elements_.clear(); | 657 elements_.clear(); |
658 } | 658 } |
659 | 659 |
660 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue( | 660 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue( |
661 blink::WebInputElement* element) { | 661 blink::WebInputElement* element) { |
662 if (!element->isNull() && !element->suggestedValue().isEmpty()) | 662 if (!element->isNull() && !element->suggestedValue().isEmpty()) |
663 element->setValue(element->suggestedValue(), true); | 663 element->setAutofillValue(element->suggestedValue()); |
664 } | 664 } |
665 | 665 |
666 bool PasswordAutofillAgent::TextDidChangeInTextField( | 666 bool PasswordAutofillAgent::TextDidChangeInTextField( |
667 const blink::WebInputElement& element) { | 667 const blink::WebInputElement& element) { |
668 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 | 668 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 |
669 blink::WebInputElement mutable_element = element; // We need a non-const. | 669 blink::WebInputElement mutable_element = element; // We need a non-const. |
670 mutable_element.setAutofilled(false); | 670 mutable_element.setAutofilled(false); |
671 | 671 |
672 WebInputToPasswordInfoMap::iterator iter = | 672 WebInputToPasswordInfoMap::iterator iter = |
673 web_input_to_password_info_.find(element); | 673 web_input_to_password_info_.find(element); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 !IsElementAutocompletable(password_element)) { | 746 !IsElementAutocompletable(password_element)) { |
747 return false; | 747 return false; |
748 } | 748 } |
749 | 749 |
750 password_info->password_was_edited_last = false; | 750 password_info->password_was_edited_last = false; |
751 if (element->isPasswordField()) { | 751 if (element->isPasswordField()) { |
752 password_info->password_field_suggestion_was_accepted = true; | 752 password_info->password_field_suggestion_was_accepted = true; |
753 password_info->password_field = password_element; | 753 password_info->password_field = password_element; |
754 } else if (!username_element.isNull() && | 754 } else if (!username_element.isNull() && |
755 IsElementAutocompletable(username_element)) { | 755 IsElementAutocompletable(username_element)) { |
756 username_element.setValue(blink::WebString::fromUTF16(username), true); | 756 username_element.setAutofillValue(blink::WebString::fromUTF16(username)); |
757 username_element.setAutofilled(true); | 757 username_element.setAutofilled(true); |
758 UpdateFieldValueAndPropertiesMaskMap(username_element, &username, | 758 UpdateFieldValueAndPropertiesMaskMap(username_element, &username, |
759 FieldPropertiesFlags::AUTOFILLED, | 759 FieldPropertiesFlags::AUTOFILLED, |
760 &field_value_and_properties_map_); | 760 &field_value_and_properties_map_); |
761 } | 761 } |
762 | 762 |
763 password_element.setValue(blink::WebString::fromUTF16(password), true); | 763 password_element.setAutofillValue(blink::WebString::fromUTF16(password)); |
764 password_element.setAutofilled(true); | 764 password_element.setAutofilled(true); |
765 UpdateFieldValueAndPropertiesMaskMap(password_element, &password, | 765 UpdateFieldValueAndPropertiesMaskMap(password_element, &password, |
766 FieldPropertiesFlags::AUTOFILLED, | 766 FieldPropertiesFlags::AUTOFILLED, |
767 &field_value_and_properties_map_); | 767 &field_value_and_properties_map_); |
768 | 768 |
769 blink::WebInputElement mutable_filled_element = *element; | 769 blink::WebInputElement mutable_filled_element = *element; |
770 mutable_filled_element.setSelectionRange(element->value().length(), | 770 mutable_filled_element.setSelectionRange(element->value().length(), |
771 element->value().length()); | 771 element->value().length()); |
772 | 772 |
773 return true; | 773 return true; |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1602 PasswordAutofillAgent::GetPasswordManagerDriver() { |
1603 if (!password_manager_driver_) { | 1603 if (!password_manager_driver_) { |
1604 render_frame()->GetRemoteInterfaces()->GetInterface( | 1604 render_frame()->GetRemoteInterfaces()->GetInterface( |
1605 mojo::MakeRequest(&password_manager_driver_)); | 1605 mojo::MakeRequest(&password_manager_driver_)); |
1606 } | 1606 } |
1607 | 1607 |
1608 return password_manager_driver_; | 1608 return password_manager_driver_; |
1609 } | 1609 } |
1610 | 1610 |
1611 } // namespace autofill | 1611 } // namespace autofill |
OLD | NEW |