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

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

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove extra line change in autofill_scanner.cc Created 8 years 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 (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
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 remove_if(remaining_fields.begin(), remaining_fields.end(), IsCheckable),
66 remaining_fields.end());
Ilya Sherman 2012/12/17 22:33:27 Please add test coverage for this.
Raman Kakilate 2012/12/18 01:54:04 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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698