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

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

Issue 7585020: Remove Autofill support for the ECML standard, as it is virtually unused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ECML files from the repository Created 9 years, 4 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
« no previous file with comments | « chrome/browser/autofill/form_field.h ('k') | chrome/browser/autofill/name_field.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/autofill/autofill_ecml.h"
17 #include "chrome/browser/autofill/address_field.h" 16 #include "chrome/browser/autofill/address_field.h"
18 #include "chrome/browser/autofill/autofill_field.h" 17 #include "chrome/browser/autofill/autofill_field.h"
19 #include "chrome/browser/autofill/autofill_regexes.h" 18 #include "chrome/browser/autofill/autofill_regexes.h"
20 #include "chrome/browser/autofill/autofill_scanner.h" 19 #include "chrome/browser/autofill/autofill_scanner.h"
21 #include "chrome/browser/autofill/credit_card_field.h" 20 #include "chrome/browser/autofill/credit_card_field.h"
22 #include "chrome/browser/autofill/email_field.h" 21 #include "chrome/browser/autofill/email_field.h"
23 #include "chrome/browser/autofill/field_types.h" 22 #include "chrome/browser/autofill/field_types.h"
24 #include "chrome/browser/autofill/form_structure.h" 23 #include "chrome/browser/autofill/form_structure.h"
25 #include "chrome/browser/autofill/name_field.h" 24 #include "chrome/browser/autofill/name_field.h"
26 #include "chrome/browser/autofill/phone_field.h" 25 #include "chrome/browser/autofill/phone_field.h"
27 #include "grit/autofill_resources.h" 26 #include "grit/autofill_resources.h"
28 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
29 28
30 namespace { 29 namespace {
31 30
32 using autofill::GetEcmlPattern;
33 using autofill::HasECMLField;
34
35 bool IsTextField(const string16& type) { 31 bool IsTextField(const string16& type) {
36 return type == ASCIIToUTF16("text"); 32 return type == ASCIIToUTF16("text");
37 } 33 }
38 34
39 bool IsEmailField(const string16& type) { 35 bool IsEmailField(const string16& type) {
40 return type == ASCIIToUTF16("email"); 36 return type == ASCIIToUTF16("email");
41 } 37 }
42 38
43 bool IsTelephoneField(const string16& type) { 39 bool IsTelephoneField(const string16& type) {
44 return type == ASCIIToUTF16("tel"); 40 return type == ASCIIToUTF16("tel");
45 } 41 }
46 42
47 bool IsSelectField(const string16& type) { 43 bool IsSelectField(const string16& type) {
48 return type == ASCIIToUTF16("select-one"); 44 return type == ASCIIToUTF16("select-one");
49 } 45 }
50 46
51 } // namespace 47 } // namespace
52 48
53 // static 49 // static
54 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields, 50 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields,
55 FieldTypeMap* map) { 51 FieldTypeMap* map) {
56 // First, check if there is at least one form field with an ECML name.
57 // If there is, then we will match an element only if it is in the standard.
58 bool is_ecml = HasECMLField(fields);
59
60 // Set up a working copy of the fields to be processed. 52 // Set up a working copy of the fields to be processed.
61 std::vector<const AutofillField*> remaining_fields(fields.size()); 53 std::vector<const AutofillField*> remaining_fields(fields.size());
62 std::copy(fields.begin(), fields.end(), remaining_fields.begin()); 54 std::copy(fields.begin(), fields.end(), remaining_fields.begin());
63 55
64 // Email pass. 56 // Email pass.
65 ParseFormFieldsPass(EmailField::Parse, is_ecml, &remaining_fields, map); 57 ParseFormFieldsPass(EmailField::Parse, &remaining_fields, map);
66 58
67 // Phone/fax pass. 59 // Phone/fax pass.
68 ParseFormFieldsPass(PhoneField::Parse, is_ecml, &remaining_fields, map); 60 ParseFormFieldsPass(PhoneField::Parse, &remaining_fields, map);
69 61
70 // Address pass. 62 // Address pass.
71 ParseFormFieldsPass(AddressField::Parse, is_ecml, &remaining_fields, map); 63 ParseFormFieldsPass(AddressField::Parse, &remaining_fields, map);
72 64
73 // Credit card pass. 65 // Credit card pass.
74 ParseFormFieldsPass(CreditCardField::Parse, is_ecml, &remaining_fields, map); 66 ParseFormFieldsPass(CreditCardField::Parse, &remaining_fields, map);
75 67
76 // Name pass. 68 // Name pass.
77 ParseFormFieldsPass(NameField::Parse, is_ecml, &remaining_fields, map); 69 ParseFormFieldsPass(NameField::Parse, &remaining_fields, map);
78 } 70 }
79 71
80 // static 72 // static
81 bool FormField::ParseField(AutofillScanner* scanner, 73 bool FormField::ParseField(AutofillScanner* scanner,
82 const string16& pattern, 74 const string16& pattern,
83 const AutofillField** match) { 75 const AutofillField** match) {
84 return ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT, match); 76 return ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT, match);
85 } 77 }
86 78
87 // static 79 // static
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if ((match_type & FormField::MATCH_VALUE) && 156 if ((match_type & FormField::MATCH_VALUE) &&
165 autofill::MatchesPattern(field->value, pattern)) { 157 autofill::MatchesPattern(field->value, pattern)) {
166 return true; 158 return true;
167 } 159 }
168 160
169 return false; 161 return false;
170 } 162 }
171 163
172 // static 164 // static
173 void FormField::ParseFormFieldsPass(ParseFunction parse, 165 void FormField::ParseFormFieldsPass(ParseFunction parse,
174 bool is_ecml,
175 std::vector<const AutofillField*>* fields, 166 std::vector<const AutofillField*>* fields,
176 FieldTypeMap* map) { 167 FieldTypeMap* map) {
177 // Store unmatched fields for further processing by the caller. 168 // Store unmatched fields for further processing by the caller.
178 std::vector<const AutofillField*> remaining_fields; 169 std::vector<const AutofillField*> remaining_fields;
179 170
180 AutofillScanner scanner(*fields); 171 AutofillScanner scanner(*fields);
181 while (!scanner.IsEnd()) { 172 while (!scanner.IsEnd()) {
182 scoped_ptr<FormField> form_field(parse(&scanner, is_ecml)); 173 scoped_ptr<FormField> form_field(parse(&scanner));
183 if (!form_field.get()) { 174 if (!form_field.get()) {
184 remaining_fields.push_back(scanner.Cursor()); 175 remaining_fields.push_back(scanner.Cursor());
185 scanner.Advance(); 176 scanner.Advance();
186 continue; 177 continue;
187 } 178 }
188 179
189 // Add entries into the map for each field type found in |form_field|. 180 // Add entries into the map for each field type found in |form_field|.
190 bool ok = form_field->ClassifyField(map); 181 bool ok = form_field->ClassifyField(map);
191 DCHECK(ok); 182 DCHECK(ok);
192 } 183 }
193 184
194 std::swap(*fields, remaining_fields); 185 std::swap(*fields, remaining_fields);
195 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_field.h ('k') | chrome/browser/autofill/name_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698