Chromium Code Reviews| 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/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1164 app_locale, | 1164 app_locale, |
| 1165 field(i)); | 1165 field(i)); |
| 1166 filled_something = true; | 1166 filled_something = true; |
| 1167 break; | 1167 break; |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 } | 1170 } |
| 1171 return filled_something; | 1171 return filled_something; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 std::set<base::string16> FormStructure::PossibleValues(ServerFieldType type) { | |
| 1175 std::set<base::string16> values; | |
| 1176 AutofillType target_type(type); | |
| 1177 for (std::vector<AutofillField*>::iterator iter = fields_.begin(); | |
| 1178 iter != fields_.end(); ++iter) { | |
| 1179 AutofillField* field = *iter; | |
| 1180 if (field->Type().GetStorableType() != target_type.GetStorableType() || | |
| 1181 field->Type().group() != target_type.group()) { | |
|
Ilya Sherman
2014/03/03 23:55:54
Optional nit: Maybe it makes sense to add an IsEqu
Evan Stade
2014/03/04 00:11:30
Using IsEquivalentTo would just force the next dev
| |
| 1182 continue; | |
| 1183 } | |
| 1184 | |
| 1185 // No option values; anything goes. | |
| 1186 if (field->option_values.empty()) | |
| 1187 return std::set<base::string16>(); | |
| 1188 | |
| 1189 values.insert(field->option_values.begin(), field->option_values.end()); | |
| 1190 values.insert(field->option_contents.begin(), field->option_contents.end()); | |
| 1191 } | |
| 1192 | |
| 1193 return values; | |
| 1194 } | |
| 1195 | |
| 1174 void FormStructure::IdentifySections(bool has_author_specified_sections) { | 1196 void FormStructure::IdentifySections(bool has_author_specified_sections) { |
| 1175 if (fields_.empty()) | 1197 if (fields_.empty()) |
| 1176 return; | 1198 return; |
| 1177 | 1199 |
| 1178 if (!has_author_specified_sections) { | 1200 if (!has_author_specified_sections) { |
| 1179 // Name sections after the first field in the section. | 1201 // Name sections after the first field in the section. |
| 1180 base::string16 current_section = fields_.front()->unique_name(); | 1202 base::string16 current_section = fields_.front()->unique_name(); |
| 1181 | 1203 |
| 1182 // Keep track of the types we've seen in this section. | 1204 // Keep track of the types we've seen in this section. |
| 1183 std::set<ServerFieldType> seen_types; | 1205 std::set<ServerFieldType> seen_types; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1226 field != fields_.end(); ++field) { | 1248 field != fields_.end(); ++field) { |
| 1227 FieldTypeGroup field_type_group = (*field)->Type().group(); | 1249 FieldTypeGroup field_type_group = (*field)->Type().group(); |
| 1228 if (field_type_group == CREDIT_CARD) | 1250 if (field_type_group == CREDIT_CARD) |
| 1229 (*field)->set_section((*field)->section() + "-cc"); | 1251 (*field)->set_section((*field)->section() + "-cc"); |
| 1230 else | 1252 else |
| 1231 (*field)->set_section((*field)->section() + "-default"); | 1253 (*field)->set_section((*field)->section() + "-default"); |
| 1232 } | 1254 } |
| 1233 } | 1255 } |
| 1234 | 1256 |
| 1235 } // namespace autofill | 1257 } // namespace autofill |
| OLD | NEW |