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_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 <memory> | |
Mathieu
2016/04/04 13:36:16
same comment as for password_autofill_agent.cc
vabr (Chromium)
2016/04/04 14:29:04
Here it all derives from the header, so I agree to
| |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "components/autofill/content/renderer/form_autofill_util.h" | 19 #include "components/autofill/content/renderer/form_autofill_util.h" |
20 #include "components/autofill/core/common/password_form.h" | 20 #include "components/autofill/core/common/password_form.h" |
21 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 21 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
22 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
23 #include "third_party/WebKit/public/platform/WebString.h" | 23 #include "third_party/WebKit/public/platform/WebString.h" |
24 #include "third_party/WebKit/public/platform/WebVector.h" | 24 #include "third_party/WebKit/public/platform/WebVector.h" |
25 #include "third_party/WebKit/public/web/WebDocument.h" | 25 #include "third_party/WebKit/public/web/WebDocument.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 if (input->formControlName() == "continue" && | 626 if (input->formControlName() == "continue" && |
627 re2::RE2::PartialMatch(input->value().utf8(), | 627 re2::RE2::PartialMatch(input->value().utf8(), |
628 g_password_site_matcher.Get())) { | 628 g_password_site_matcher.Get())) { |
629 has_continue_field = true; | 629 has_continue_field = true; |
630 } | 630 } |
631 } | 631 } |
632 | 632 |
633 return has_rart_field && has_continue_field; | 633 return has_rart_field && has_continue_field; |
634 } | 634 } |
635 | 635 |
636 scoped_ptr<PasswordForm> CreatePasswordFormFromWebForm( | 636 std::unique_ptr<PasswordForm> CreatePasswordFormFromWebForm( |
637 const WebFormElement& web_form, | 637 const WebFormElement& web_form, |
638 const ModifiedValues* nonscript_modified_values, | 638 const ModifiedValues* nonscript_modified_values, |
639 const FormsPredictionsMap* form_predictions) { | 639 const FormsPredictionsMap* form_predictions) { |
640 if (web_form.isNull()) | 640 if (web_form.isNull()) |
641 return scoped_ptr<PasswordForm>(); | 641 return std::unique_ptr<PasswordForm>(); |
642 | 642 |
643 scoped_ptr<PasswordForm> password_form(new PasswordForm()); | 643 std::unique_ptr<PasswordForm> password_form(new PasswordForm()); |
644 password_form->action = form_util::GetCanonicalActionForForm(web_form); | 644 password_form->action = form_util::GetCanonicalActionForForm(web_form); |
645 if (!password_form->action.is_valid()) | 645 if (!password_form->action.is_valid()) |
646 return scoped_ptr<PasswordForm>(); | 646 return std::unique_ptr<PasswordForm>(); |
647 | 647 |
648 SyntheticForm synthetic_form; | 648 SyntheticForm synthetic_form; |
649 PopulateSyntheticFormFromWebForm(web_form, &synthetic_form); | 649 PopulateSyntheticFormFromWebForm(web_form, &synthetic_form); |
650 | 650 |
651 WebFormElementToFormData(web_form, blink::WebFormControlElement(), | 651 WebFormElementToFormData(web_form, blink::WebFormControlElement(), |
652 form_util::EXTRACT_NONE, &password_form->form_data, | 652 form_util::EXTRACT_NONE, &password_form->form_data, |
653 NULL /* FormFieldData */); | 653 NULL /* FormFieldData */); |
654 | 654 |
655 if (!GetPasswordForm(synthetic_form, password_form.get(), | 655 if (!GetPasswordForm(synthetic_form, password_form.get(), |
656 nonscript_modified_values, form_predictions)) | 656 nonscript_modified_values, form_predictions)) |
657 return scoped_ptr<PasswordForm>(); | 657 return std::unique_ptr<PasswordForm>(); |
658 | 658 |
659 return password_form; | 659 return password_form; |
660 } | 660 } |
661 | 661 |
662 scoped_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( | 662 std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( |
663 const WebFrame& frame, | 663 const WebFrame& frame, |
664 const ModifiedValues* nonscript_modified_values, | 664 const ModifiedValues* nonscript_modified_values, |
665 const FormsPredictionsMap* form_predictions) { | 665 const FormsPredictionsMap* form_predictions) { |
666 SyntheticForm synthetic_form; | 666 SyntheticForm synthetic_form; |
667 synthetic_form.control_elements = form_util::GetUnownedFormFieldElements( | 667 synthetic_form.control_elements = form_util::GetUnownedFormFieldElements( |
668 frame.document().all(), &synthetic_form.fieldsets); | 668 frame.document().all(), &synthetic_form.fieldsets); |
669 synthetic_form.document = frame.document(); | 669 synthetic_form.document = frame.document(); |
670 | 670 |
671 if (synthetic_form.control_elements.empty()) | 671 if (synthetic_form.control_elements.empty()) |
672 return scoped_ptr<PasswordForm>(); | 672 return std::unique_ptr<PasswordForm>(); |
673 | 673 |
674 scoped_ptr<PasswordForm> password_form(new PasswordForm()); | 674 std::unique_ptr<PasswordForm> password_form(new PasswordForm()); |
675 UnownedPasswordFormElementsAndFieldSetsToFormData( | 675 UnownedPasswordFormElementsAndFieldSetsToFormData( |
676 synthetic_form.fieldsets, synthetic_form.control_elements, nullptr, | 676 synthetic_form.fieldsets, synthetic_form.control_elements, nullptr, |
677 frame.document(), form_util::EXTRACT_NONE, &password_form->form_data, | 677 frame.document(), form_util::EXTRACT_NONE, &password_form->form_data, |
678 nullptr /* FormFieldData */); | 678 nullptr /* FormFieldData */); |
679 if (!GetPasswordForm(synthetic_form, password_form.get(), | 679 if (!GetPasswordForm(synthetic_form, password_form.get(), |
680 nonscript_modified_values, form_predictions)) | 680 nonscript_modified_values, form_predictions)) |
681 return scoped_ptr<PasswordForm>(); | 681 return std::unique_ptr<PasswordForm>(); |
682 | 682 |
683 // No actual action on the form, so use the the origin as the action. | 683 // No actual action on the form, so use the the origin as the action. |
684 password_form->action = password_form->origin; | 684 password_form->action = password_form->origin; |
685 | 685 |
686 return password_form; | 686 return password_form; |
687 } | 687 } |
688 | 688 |
689 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element, | 689 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element, |
690 const char* value_in_lowercase) { | 690 const char* value_in_lowercase) { |
691 return base::LowerCaseEqualsASCII( | 691 return base::LowerCaseEqualsASCII( |
692 base::StringPiece16(element.getAttribute("autocomplete")), | 692 base::StringPiece16(element.getAttribute("autocomplete")), |
693 value_in_lowercase); | 693 value_in_lowercase); |
694 } | 694 } |
695 | 695 |
696 } // namespace autofill | 696 } // namespace autofill |
OLD | NEW |