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

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

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

Powered by Google App Engine
This is Rietveld 408576698