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

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

Issue 2317983002: Enable manual password autofilling if the username field is read-only. (Closed)
Patch Set: Add IsAutocompletable check. Small tests refactoring. Created 4 years, 3 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
« no previous file with comments | « chrome/renderer/autofill/password_autofill_agent_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 const blink::WebInputElement* element = toWebInputElement(&control_element); 696 const blink::WebInputElement* element = toWebInputElement(&control_element);
697 if (!element) 697 if (!element)
698 return false; 698 return false;
699 699
700 blink::WebInputElement username_element; 700 blink::WebInputElement username_element;
701 blink::WebInputElement password_element; 701 blink::WebInputElement password_element;
702 PasswordInfo* password_info; 702 PasswordInfo* password_info;
703 703
704 if (!FindPasswordInfoForElement(*element, &username_element, 704 if (!FindPasswordInfoForElement(*element, &username_element,
705 &password_element, &password_info) || 705 &password_element, &password_info) ||
706 (!username_element.isNull() &&
707 !IsElementAutocompletable(username_element)) ||
708 !IsElementAutocompletable(password_element)) { 706 !IsElementAutocompletable(password_element)) {
709 return false; 707 return false;
710 } 708 }
711 709
712 password_info->password_was_edited_last = false; 710 password_info->password_was_edited_last = false;
713 if (element->isPasswordField()) { 711 if (element->isPasswordField()) {
714 password_info->password_field_suggestion_was_accepted = true; 712 password_info->password_field_suggestion_was_accepted = true;
715 password_info->password_field = password_element; 713 password_info->password_field = password_element;
716 } else if (!username_element.isNull()) { 714 } else if (!username_element.isNull() &&
715 IsElementAutocompletable(username_element)) {
717 username_element.setValue(blink::WebString(username), true); 716 username_element.setValue(blink::WebString(username), true);
718 username_element.setAutofilled(true); 717 username_element.setAutofilled(true);
719 UpdateFieldValueAndPropertiesMaskMap(username_element, &username, 718 UpdateFieldValueAndPropertiesMaskMap(username_element, &username,
720 FieldPropertiesFlags::AUTOFILLED, 719 FieldPropertiesFlags::AUTOFILLED,
721 &field_value_and_properties_map_); 720 &field_value_and_properties_map_);
722 } 721 }
723 722
724 password_element.setValue(blink::WebString(password), true); 723 password_element.setValue(blink::WebString(password), true);
725 password_element.setAutofilled(true); 724 password_element.setAutofilled(true);
726 UpdateFieldValueAndPropertiesMaskMap(password_element, &password, 725 UpdateFieldValueAndPropertiesMaskMap(password_element, &password,
(...skipping 15 matching lines...) Expand all
742 const blink::WebInputElement* element = toWebInputElement(&control_element); 741 const blink::WebInputElement* element = toWebInputElement(&control_element);
743 if (!element) 742 if (!element)
744 return false; 743 return false;
745 744
746 blink::WebInputElement username_element; 745 blink::WebInputElement username_element;
747 blink::WebInputElement password_element; 746 blink::WebInputElement password_element;
748 PasswordInfo* password_info; 747 PasswordInfo* password_info;
749 748
750 if (!FindPasswordInfoForElement(*element, &username_element, 749 if (!FindPasswordInfoForElement(*element, &username_element,
751 &password_element, &password_info) || 750 &password_element, &password_info) ||
752 (!username_element.isNull() &&
753 !IsElementAutocompletable(username_element)) ||
754 !IsElementAutocompletable(password_element)) { 751 !IsElementAutocompletable(password_element)) {
755 return false; 752 return false;
756 } 753 }
757 754
758 if (!element->isPasswordField() && !username_element.isNull()) { 755 if (!element->isPasswordField() && !username_element.isNull() &&
756 IsElementAutocompletable(username_element)) {
759 if (username_query_prefix_.empty()) 757 if (username_query_prefix_.empty())
760 username_query_prefix_ = username_element.value(); 758 username_query_prefix_ = username_element.value();
761 759
762 was_username_autofilled_ = username_element.isAutofilled(); 760 was_username_autofilled_ = username_element.isAutofilled();
763 username_element.setSuggestedValue(username); 761 username_element.setSuggestedValue(username);
764 username_element.setAutofilled(true); 762 username_element.setAutofilled(true);
765 form_util::PreviewSuggestion(username_element.suggestedValue(), 763 form_util::PreviewSuggestion(username_element.suggestedValue(),
766 username_query_prefix_, &username_element); 764 username_query_prefix_, &username_element);
767 } 765 }
768 was_password_autofilled_ = password_element.isAutofilled(); 766 was_password_autofilled_ = password_element.isAutofilled();
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 !(provisionally_saved_form_->password_value.empty() && 1491 !(provisionally_saved_form_->password_value.empty() &&
1494 provisionally_saved_form_->new_password_value.empty()); 1492 provisionally_saved_form_->new_password_value.empty());
1495 } 1493 }
1496 1494
1497 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() { 1495 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() {
1498 DCHECK(autofill_agent_); 1496 DCHECK(autofill_agent_);
1499 return autofill_agent_->GetAutofillDriver(); 1497 return autofill_agent_->GetAutofillDriver();
1500 } 1498 }
1501 1499
1502 } // namespace autofill 1500 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/password_autofill_agent_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698