OLD | NEW |
---|---|
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_field.h" | 5 #include "chrome/browser/autofill/form_field.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 } | 38 } |
39 | 39 |
40 bool IsTelephoneField(const std::string& type) { | 40 bool IsTelephoneField(const std::string& type) { |
41 return type == "tel"; | 41 return type == "tel"; |
42 } | 42 } |
43 | 43 |
44 bool IsSelectField(const std::string& type) { | 44 bool IsSelectField(const std::string& type) { |
45 return type == "select-one"; | 45 return type == "select-one"; |
46 } | 46 } |
47 | 47 |
48 bool IsCheckable(const AutofillField* field) { | |
49 return field->is_checkable; | |
50 } | |
51 | |
48 } // namespace | 52 } // namespace |
49 | 53 |
50 // static | 54 // static |
51 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields, | 55 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields, |
52 FieldTypeMap* map) { | 56 FieldTypeMap* map) { |
53 // Set up a working copy of the fields to be processed. | 57 // Set up a working copy of the fields to be processed. |
54 std::vector<const AutofillField*> remaining_fields(fields.size()); | 58 std::vector<const AutofillField*> remaining_fields(fields.size()); |
55 std::copy(fields.begin(), fields.end(), remaining_fields.begin()); | 59 std::copy(fields.begin(), fields.end(), remaining_fields.begin()); |
56 | 60 |
61 // Ignore checkable fields as they interfere with parsers assuming context. | |
62 // Eg., while parsing address, "Is PO box" checkbox after ADDRESS_LINE1 | |
63 // interferes with correctly understanding ADDRESS_LINE2. | |
64 remaining_fields.erase( | |
65 std::remove_if(remaining_fields.begin(), remaining_fields.end(), | |
66 IsCheckable), remaining_fields.end()); | |
Ilya Sherman
2012/12/18 04:32:40
nit: Please move the "remaining_fields.end()" argu
Raman Kakilate
2012/12/18 04:37:32
Done.
| |
67 | |
57 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 68 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
58 bool parse_new_field_types = | 69 bool parse_new_field_types = |
59 command_line.HasSwitch(switches::kEnableNewAutofillHeuristics); | 70 command_line.HasSwitch(switches::kEnableNewAutofillHeuristics); |
60 | 71 |
61 // Email pass. | 72 // Email pass. |
62 ParseFormFieldsPass(EmailField::Parse, parse_new_field_types, | 73 ParseFormFieldsPass(EmailField::Parse, parse_new_field_types, |
63 &remaining_fields, map); | 74 &remaining_fields, map); |
64 | 75 |
65 // Phone pass. | 76 // Phone pass. |
66 ParseFormFieldsPass(PhoneField::Parse, parse_new_field_types, | 77 ParseFormFieldsPass(PhoneField::Parse, parse_new_field_types, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 continue; | 199 continue; |
189 } | 200 } |
190 | 201 |
191 // Add entries into the map for each field type found in |form_field|. | 202 // Add entries into the map for each field type found in |form_field|. |
192 bool ok = form_field->ClassifyField(map); | 203 bool ok = form_field->ClassifyField(map); |
193 DCHECK(ok); | 204 DCHECK(ok); |
194 } | 205 } |
195 | 206 |
196 std::swap(*fields, remaining_fields); | 207 std::swap(*fields, remaining_fields); |
197 } | 208 } |
OLD | NEW |