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

Side by Side Diff: chrome/browser/autofill/form_structure.cc

Issue 10669038: base: Remove dereference structure operator (i.e ->) from ScopedVector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/autofill/form_structure.h" 5 #include "chrome/browser/autofill/form_structure.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 encompassing_xml_element->AddElement(field_element); 879 encompassing_xml_element->AddElement(field_element);
880 } 880 }
881 } 881 }
882 return true; 882 return true;
883 } 883 }
884 884
885 void FormStructure::ParseAutocompletetypeAttributes(bool* found_attribute, 885 void FormStructure::ParseAutocompletetypeAttributes(bool* found_attribute,
886 bool* found_sections) { 886 bool* found_sections) {
887 *found_attribute = false; 887 *found_attribute = false;
888 *found_sections = false; 888 *found_sections = false;
889 for (std::vector<AutofillField*>::iterator field = fields_->begin(); 889 for (std::vector<AutofillField*>::iterator field = fields_.begin();
890 field != fields_->end(); ++field) { 890 field != fields_.end(); ++field) {
891 if ((*field)->autocomplete_type.empty()) 891 if ((*field)->autocomplete_type.empty())
892 continue; 892 continue;
893 893
894 *found_attribute = true; 894 *found_attribute = true;
895 std::vector<string16> types; 895 std::vector<string16> types;
896 Tokenize((*field)->autocomplete_type, ASCIIToUTF16(" "), &types); 896 Tokenize((*field)->autocomplete_type, ASCIIToUTF16(" "), &types);
897 897
898 // Look for a named section. 898 // Look for a named section.
899 const string16 kSectionPrefix = ASCIIToUTF16("section-"); 899 const string16 kSectionPrefix = ASCIIToUTF16("section-");
900 if (!types.empty() && StartsWith(types.front(), kSectionPrefix, true)) { 900 if (!types.empty() && StartsWith(types.front(), kSectionPrefix, true)) {
901 *found_sections = true; 901 *found_sections = true;
902 (*field)->set_section(types.front().substr(kSectionPrefix.size())); 902 (*field)->set_section(types.front().substr(kSectionPrefix.size()));
903 } 903 }
904 904
905 // Look for specified types. 905 // Look for specified types.
906 for (std::vector<string16>::const_iterator type = types.begin(); 906 for (std::vector<string16>::const_iterator type = types.begin();
907 type != types.end(); ++type) { 907 type != types.end(); ++type) {
908 if (UpdateFromAutocompleteType(*type, *field)) 908 if (UpdateFromAutocompleteType(*type, *field))
909 break; 909 break;
910 } 910 }
911 } 911 }
912 } 912 }
913 913
914 void FormStructure::IdentifySections(bool has_author_specified_sections) { 914 void FormStructure::IdentifySections(bool has_author_specified_sections) {
915 if (fields_.empty()) 915 if (fields_.empty())
916 return; 916 return;
917 917
918 if (!has_author_specified_sections) { 918 if (!has_author_specified_sections) {
919 // Name sections after the first field in the section. 919 // Name sections after the first field in the section.
920 string16 current_section = fields_->front()->unique_name(); 920 string16 current_section = fields_.front()->unique_name();
921 921
922 // Keep track of the types we've seen in this section. 922 // Keep track of the types we've seen in this section.
923 std::set<AutofillFieldType> seen_types; 923 std::set<AutofillFieldType> seen_types;
924 AutofillFieldType previous_type = UNKNOWN_TYPE; 924 AutofillFieldType previous_type = UNKNOWN_TYPE;
925 925
926 for (std::vector<AutofillField*>::iterator field = fields_->begin(); 926 for (std::vector<AutofillField*>::iterator field = fields_.begin();
927 field != fields_->end(); ++field) { 927 field != fields_.end(); ++field) {
928 const AutofillFieldType current_type = 928 const AutofillFieldType current_type =
929 AutofillType::GetEquivalentFieldType((*field)->type()); 929 AutofillType::GetEquivalentFieldType((*field)->type());
930 930
931 bool already_saw_current_type = seen_types.count(current_type) > 0; 931 bool already_saw_current_type = seen_types.count(current_type) > 0;
932 932
933 // Forms often ask for multiple phone numbers -- e.g. both a daytime and 933 // Forms often ask for multiple phone numbers -- e.g. both a daytime and
934 // evening phone number. Our phone number detection is also generally a 934 // evening phone number. Our phone number detection is also generally a
935 // little off. Hence, ignore this field type as a signal here. 935 // little off. Hence, ignore this field type as a signal here.
936 if (AutofillType(current_type).group() == AutofillType::PHONE) 936 if (AutofillType(current_type).group() == AutofillType::PHONE)
937 already_saw_current_type = false; 937 already_saw_current_type = false;
(...skipping 18 matching lines...) Expand all
956 current_section = (*field)->unique_name(); 956 current_section = (*field)->unique_name();
957 } 957 }
958 958
959 seen_types.insert(current_type); 959 seen_types.insert(current_type);
960 (*field)->set_section(current_section); 960 (*field)->set_section(current_section);
961 } 961 }
962 } 962 }
963 963
964 // Ensure that credit card and address fields are in separate sections. 964 // Ensure that credit card and address fields are in separate sections.
965 // This simplifies the section-aware logic in autofill_manager.cc. 965 // This simplifies the section-aware logic in autofill_manager.cc.
966 for (std::vector<AutofillField*>::iterator field = fields_->begin(); 966 for (std::vector<AutofillField*>::iterator field = fields_.begin();
967 field != fields_->end(); ++field) { 967 field != fields_.end(); ++field) {
968 AutofillType::FieldTypeGroup field_type_group = 968 AutofillType::FieldTypeGroup field_type_group =
969 AutofillType((*field)->type()).group(); 969 AutofillType((*field)->type()).group();
970 if (field_type_group == AutofillType::CREDIT_CARD) 970 if (field_type_group == AutofillType::CREDIT_CARD)
971 (*field)->set_section((*field)->section() + ASCIIToUTF16("-cc")); 971 (*field)->set_section((*field)->section() + ASCIIToUTF16("-cc"));
972 else 972 else
973 (*field)->set_section((*field)->section() + ASCIIToUTF16("-default")); 973 (*field)->set_section((*field)->section() + ASCIIToUTF16("-default"));
974 } 974 }
975 } 975 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager_unittest.cc ('k') | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698