Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 2750323003: [Password Manager] Replace WebInputElement.setValue with WebInputElement.setAutofillValue (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 if (password.empty()) 449 if (password.empty())
450 return false; 450 return false;
451 451
452 // TODO(tkent): Check maxlength and pattern for both username and password 452 // TODO(tkent): Check maxlength and pattern for both username and password
453 // fields. 453 // fields.
454 454
455 // Input matches the username, fill in required values. 455 // Input matches the username, fill in required values.
456 if (!username_element->isNull() && 456 if (!username_element->isNull() &&
457 IsElementAutocompletable(*username_element)) { 457 IsElementAutocompletable(*username_element)) {
458 // TODO(crbug.com/507714): Why not setSuggestedValue? 458 // TODO(crbug.com/507714): Why not setSuggestedValue?
459 username_element->setValue(blink::WebString::fromUTF16(username), true); 459 username_element->setAutofillValue(blink::WebString::fromUTF16(username));
460 UpdateFieldValueAndPropertiesMaskMap(*username_element, &username, 460 UpdateFieldValueAndPropertiesMaskMap(*username_element, &username,
461 FieldPropertiesFlags::AUTOFILLED, 461 FieldPropertiesFlags::AUTOFILLED,
462 field_value_and_properties_map); 462 field_value_and_properties_map);
463 username_element->setAutofilled(true); 463 username_element->setAutofilled(true);
464 if (logger) 464 if (logger)
465 logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element); 465 logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element);
466 if (set_selection) { 466 if (set_selection) {
467 form_util::PreviewSuggestion(username, current_username, 467 form_util::PreviewSuggestion(username, current_username,
468 username_element); 468 username_element);
469 } 469 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // select to fill the password element, so the password element must be marked 544 // select to fill the password element, so the password element must be marked
545 // as autofilled and the fill step should also be skipped if the user is not 545 // as autofilled and the fill step should also be skipped if the user is not
546 // in the "no highlighting" group. 546 // in the "no highlighting" group.
547 // 547 //
548 // In all other cases, do nothing. 548 // In all other cases, do nothing.
549 bool form_has_fillable_username = !username_field_name.empty() && 549 bool form_has_fillable_username = !username_field_name.empty() &&
550 IsElementAutocompletable(username_element); 550 IsElementAutocompletable(username_element);
551 551
552 if (form_has_fillable_username && username_element.value().isEmpty()) { 552 if (form_has_fillable_username && username_element.value().isEmpty()) {
553 // TODO(tkent): Check maxlength and pattern. 553 // TODO(tkent): Check maxlength and pattern.
554 username_element.setValue( 554 username_element.setAutofillValue(
555 blink::WebString::fromUTF16(fill_data.username_field.value), true); 555 blink::WebString::fromUTF16(fill_data.username_field.value));
556 } 556 }
557 557
558 // Fill if we have an exact match for the username. Note that this sets 558 // Fill if we have an exact match for the username. Note that this sets
559 // username to autofilled. 559 // username to autofilled.
560 return FillUserNameAndPassword( 560 return FillUserNameAndPassword(
561 &username_element, &password_element, fill_data, 561 &username_element, &password_element, fill_data,
562 true /* exact_username_match */, false /* set_selection */, 562 true /* exact_username_match */, false /* set_selection */,
563 field_value_and_properties_map, registration_callback, logger); 563 field_value_and_properties_map, registration_callback, logger);
564 } 564 }
565 565
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 649 }
650 650
651 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() { 651 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() {
652 was_user_gesture_seen_ = false; 652 was_user_gesture_seen_ = false;
653 elements_.clear(); 653 elements_.clear();
654 } 654 }
655 655
656 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue( 656 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue(
657 blink::WebInputElement* element) { 657 blink::WebInputElement* element) {
658 if (!element->isNull() && !element->suggestedValue().isEmpty()) 658 if (!element->isNull() && !element->suggestedValue().isEmpty())
659 element->setValue(element->suggestedValue(), true); 659 element->setAutofillValue(element->suggestedValue());
660 } 660 }
661 661
662 bool PasswordAutofillAgent::TextDidChangeInTextField( 662 bool PasswordAutofillAgent::TextDidChangeInTextField(
663 const blink::WebInputElement& element) { 663 const blink::WebInputElement& element) {
664 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 664 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083
665 blink::WebInputElement mutable_element = element; // We need a non-const. 665 blink::WebInputElement mutable_element = element; // We need a non-const.
666 mutable_element.setAutofilled(false); 666 mutable_element.setAutofilled(false);
667 667
668 WebInputToPasswordInfoMap::iterator iter = 668 WebInputToPasswordInfoMap::iterator iter =
669 web_input_to_password_info_.find(element); 669 web_input_to_password_info_.find(element);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 !IsElementAutocompletable(password_element)) { 741 !IsElementAutocompletable(password_element)) {
742 return false; 742 return false;
743 } 743 }
744 744
745 password_info->password_was_edited_last = false; 745 password_info->password_was_edited_last = false;
746 if (element->isPasswordField()) { 746 if (element->isPasswordField()) {
747 password_info->password_field_suggestion_was_accepted = true; 747 password_info->password_field_suggestion_was_accepted = true;
748 password_info->password_field = password_element; 748 password_info->password_field = password_element;
749 } else if (!username_element.isNull() && 749 } else if (!username_element.isNull() &&
750 IsElementAutocompletable(username_element)) { 750 IsElementAutocompletable(username_element)) {
751 username_element.setValue(blink::WebString::fromUTF16(username), true); 751 username_element.setAutofillValue(blink::WebString::fromUTF16(username));
752 username_element.setAutofilled(true); 752 username_element.setAutofilled(true);
753 UpdateFieldValueAndPropertiesMaskMap(username_element, &username, 753 UpdateFieldValueAndPropertiesMaskMap(username_element, &username,
754 FieldPropertiesFlags::AUTOFILLED, 754 FieldPropertiesFlags::AUTOFILLED,
755 &field_value_and_properties_map_); 755 &field_value_and_properties_map_);
756 } 756 }
757 757
758 password_element.setValue(blink::WebString::fromUTF16(password), true); 758 password_element.setAutofillValue(blink::WebString::fromUTF16(password));
759 password_element.setAutofilled(true); 759 password_element.setAutofilled(true);
760 UpdateFieldValueAndPropertiesMaskMap(password_element, &password, 760 UpdateFieldValueAndPropertiesMaskMap(password_element, &password,
761 FieldPropertiesFlags::AUTOFILLED, 761 FieldPropertiesFlags::AUTOFILLED,
762 &field_value_and_properties_map_); 762 &field_value_and_properties_map_);
763 763
764 blink::WebInputElement mutable_filled_element = *element; 764 blink::WebInputElement mutable_filled_element = *element;
765 mutable_filled_element.setSelectionRange(element->value().length(), 765 mutable_filled_element.setSelectionRange(element->value().length(),
766 element->value().length()); 766 element->value().length());
767 767
768 return true; 768 return true;
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 PasswordAutofillAgent::GetPasswordManagerDriver() { 1598 PasswordAutofillAgent::GetPasswordManagerDriver() {
1599 if (!password_manager_driver_) { 1599 if (!password_manager_driver_) {
1600 render_frame()->GetRemoteInterfaces()->GetInterface( 1600 render_frame()->GetRemoteInterfaces()->GetInterface(
1601 mojo::MakeRequest(&password_manager_driver_)); 1601 mojo::MakeRequest(&password_manager_driver_));
1602 } 1602 }
1603 1603
1604 return password_manager_driver_; 1604 return password_manager_driver_;
1605 } 1605 }
1606 1606
1607 } // namespace autofill 1607 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698