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

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

Issue 2715433004: [Password Manager] Check the success of extracting FormData in PasswordForm creation (Closed)
Patch Set: Fixed compilation error in tests 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc » ('j') | 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_form_conversion_utils.h" 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 return std::unique_ptr<PasswordForm>(); 673 return std::unique_ptr<PasswordForm>();
674 674
675 std::unique_ptr<PasswordForm> password_form(new PasswordForm()); 675 std::unique_ptr<PasswordForm> password_form(new PasswordForm());
676 password_form->action = form_util::GetCanonicalActionForForm(web_form); 676 password_form->action = form_util::GetCanonicalActionForForm(web_form);
677 if (!password_form->action.is_valid()) 677 if (!password_form->action.is_valid())
678 return std::unique_ptr<PasswordForm>(); 678 return std::unique_ptr<PasswordForm>();
679 679
680 SyntheticForm synthetic_form; 680 SyntheticForm synthetic_form;
681 PopulateSyntheticFormFromWebForm(web_form, &synthetic_form); 681 PopulateSyntheticFormFromWebForm(web_form, &synthetic_form);
682 682
683 WebFormElementToFormData(web_form, blink::WebFormControlElement(), 683 if (!WebFormElementToFormData(
684 field_value_and_properties_map, 684 web_form, blink::WebFormControlElement(),
685 form_util::EXTRACT_NONE, &password_form->form_data, 685 field_value_and_properties_map, form_util::EXTRACT_NONE,
686 NULL /* FormFieldData */); 686 &password_form->form_data, NULL /* FormFieldData */))
687 return std::unique_ptr<PasswordForm>();
687 688
688 if (!GetPasswordForm(synthetic_form, password_form.get(), 689 if (!GetPasswordForm(synthetic_form, password_form.get(),
689 field_value_and_properties_map, form_predictions)) 690 field_value_and_properties_map, form_predictions))
690 return std::unique_ptr<PasswordForm>(); 691 return std::unique_ptr<PasswordForm>();
691 692
692 return password_form; 693 return password_form;
693 } 694 }
694 695
695 std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( 696 std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements(
696 const WebFrame& frame, 697 const WebFrame& frame,
697 const FieldValueAndPropertiesMaskMap* field_value_and_properties_map, 698 const FieldValueAndPropertiesMaskMap* field_value_and_properties_map,
698 const FormsPredictionsMap* form_predictions) { 699 const FormsPredictionsMap* form_predictions) {
699 SyntheticForm synthetic_form; 700 SyntheticForm synthetic_form;
700 synthetic_form.control_elements = form_util::GetUnownedFormFieldElements( 701 synthetic_form.control_elements = form_util::GetUnownedFormFieldElements(
701 frame.document().all(), &synthetic_form.fieldsets); 702 frame.document().all(), &synthetic_form.fieldsets);
702 synthetic_form.document = frame.document(); 703 synthetic_form.document = frame.document();
703 704
704 if (synthetic_form.control_elements.empty()) 705 if (synthetic_form.control_elements.empty())
705 return std::unique_ptr<PasswordForm>(); 706 return std::unique_ptr<PasswordForm>();
706 707
707 std::unique_ptr<PasswordForm> password_form(new PasswordForm()); 708 std::unique_ptr<PasswordForm> password_form(new PasswordForm());
708 UnownedPasswordFormElementsAndFieldSetsToFormData( 709 if (!UnownedPasswordFormElementsAndFieldSetsToFormData(
709 synthetic_form.fieldsets, synthetic_form.control_elements, nullptr, 710 synthetic_form.fieldsets, synthetic_form.control_elements, nullptr,
710 frame.document(), field_value_and_properties_map, form_util::EXTRACT_NONE, 711 frame.document(), field_value_and_properties_map,
711 &password_form->form_data, nullptr /* FormFieldData */); 712 form_util::EXTRACT_NONE, &password_form->form_data,
713 nullptr /* FormFieldData */))
714 return std::unique_ptr<PasswordForm>();
712 if (!GetPasswordForm(synthetic_form, password_form.get(), 715 if (!GetPasswordForm(synthetic_form, password_form.get(),
713 field_value_and_properties_map, form_predictions)) 716 field_value_and_properties_map, form_predictions))
714 return std::unique_ptr<PasswordForm>(); 717 return std::unique_ptr<PasswordForm>();
715 718
716 // No actual action on the form, so use the the origin as the action. 719 // No actual action on the form, so use the the origin as the action.
717 password_form->action = password_form->origin; 720 password_form->action = password_form->origin;
718 721
719 return password_form; 722 return password_form;
720 } 723 }
721 724
722 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element, 725 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element,
723 const char* value_in_lowercase) { 726 const char* value_in_lowercase) {
724 base::string16 autocomplete_attribute( 727 base::string16 autocomplete_attribute(
725 element.getAttribute("autocomplete").utf16()); 728 element.getAttribute("autocomplete").utf16());
726 std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString( 729 std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString(
727 base::UTF16ToUTF8(autocomplete_attribute)); 730 base::UTF16ToUTF8(autocomplete_attribute));
728 731
729 return base::ContainsValue(tokens, value_in_lowercase); 732 return base::ContainsValue(tokens, value_in_lowercase);
730 } 733 }
731 734
732 } // namespace autofill 735 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698