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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 for (std::vector<AutofillField*>::iterator field = fields_.begin(); | 1211 for (std::vector<AutofillField*>::iterator field = fields_.begin(); |
1212 field != fields_.end(); ++field) { | 1212 field != fields_.end(); ++field) { |
1213 const AutofillFieldType current_type = | 1213 const AutofillFieldType current_type = |
1214 AutofillType::GetEquivalentFieldType((*field)->type()); | 1214 AutofillType::GetEquivalentFieldType((*field)->type()); |
1215 | 1215 |
1216 bool already_saw_current_type = seen_types.count(current_type) > 0; | 1216 bool already_saw_current_type = seen_types.count(current_type) > 0; |
1217 | 1217 |
1218 // Forms often ask for multiple phone numbers -- e.g. both a daytime and | 1218 // Forms often ask for multiple phone numbers -- e.g. both a daytime and |
1219 // evening phone number. Our phone number detection is also generally a | 1219 // evening phone number. Our phone number detection is also generally a |
1220 // little off. Hence, ignore this field type as a signal here. | 1220 // little off. Hence, ignore this field type as a signal here. |
1221 if (AutofillType(current_type).group() == AutofillType::PHONE_HOME) | 1221 if (AutofillType(current_type).group() == PHONE_HOME) |
1222 already_saw_current_type = false; | 1222 already_saw_current_type = false; |
1223 | 1223 |
1224 // Some forms have adjacent fields of the same type. Two common examples: | 1224 // Some forms have adjacent fields of the same type. Two common examples: |
1225 // * Forms with two email fields, where the second is meant to "confirm" | 1225 // * Forms with two email fields, where the second is meant to "confirm" |
1226 // the first. | 1226 // the first. |
1227 // * Forms with a <select> menu for states in some countries, and a | 1227 // * Forms with a <select> menu for states in some countries, and a |
1228 // freeform <input> field for states in other countries. (Usually, | 1228 // freeform <input> field for states in other countries. (Usually, |
1229 // only one of these two will be visible for any given choice of | 1229 // only one of these two will be visible for any given choice of |
1230 // country.) | 1230 // country.) |
1231 // Generally, adjacent fields of the same type belong in the same logical | 1231 // Generally, adjacent fields of the same type belong in the same logical |
(...skipping 11 matching lines...) Expand all Loading... |
1243 | 1243 |
1244 seen_types.insert(current_type); | 1244 seen_types.insert(current_type); |
1245 (*field)->set_section(UTF16ToUTF8(current_section)); | 1245 (*field)->set_section(UTF16ToUTF8(current_section)); |
1246 } | 1246 } |
1247 } | 1247 } |
1248 | 1248 |
1249 // Ensure that credit card and address fields are in separate sections. | 1249 // Ensure that credit card and address fields are in separate sections. |
1250 // This simplifies the section-aware logic in autofill_manager.cc. | 1250 // This simplifies the section-aware logic in autofill_manager.cc. |
1251 for (std::vector<AutofillField*>::iterator field = fields_.begin(); | 1251 for (std::vector<AutofillField*>::iterator field = fields_.begin(); |
1252 field != fields_.end(); ++field) { | 1252 field != fields_.end(); ++field) { |
1253 AutofillType::FieldTypeGroup field_type_group = | 1253 FieldTypeGroup field_type_group = AutofillType((*field)->type()).group(); |
1254 AutofillType((*field)->type()).group(); | 1254 if (field_type_group == CREDIT_CARD) |
1255 if (field_type_group == AutofillType::CREDIT_CARD) | |
1256 (*field)->set_section((*field)->section() + "-cc"); | 1255 (*field)->set_section((*field)->section() + "-cc"); |
1257 else | 1256 else |
1258 (*field)->set_section((*field)->section() + "-default"); | 1257 (*field)->set_section((*field)->section() + "-default"); |
1259 } | 1258 } |
1260 } | 1259 } |
1261 | 1260 |
1262 } // namespace autofill | 1261 } // namespace autofill |
OLD | NEW |