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 |
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/address_field.h" | 16 #include "chrome/browser/autofill/address_field.h" |
17 #include "chrome/browser/autofill/autofill_field.h" | 17 #include "chrome/browser/autofill/autofill_field.h" |
18 #include "chrome/browser/autofill/autofill_regexes.h" | 18 #include "chrome/browser/autofill/autofill_regexes.h" |
19 #include "chrome/browser/autofill/autofill_scanner.h" | 19 #include "chrome/browser/autofill/autofill_scanner.h" |
20 #include "chrome/browser/autofill/credit_card_field.h" | 20 #include "chrome/browser/autofill/credit_card_field.h" |
21 #include "chrome/browser/autofill/email_field.h" | 21 #include "chrome/browser/autofill/email_field.h" |
22 #include "chrome/browser/autofill/field_types.h" | 22 #include "chrome/browser/autofill/field_types.h" |
23 #include "chrome/browser/autofill/form_structure.h" | 23 #include "chrome/browser/autofill/form_structure.h" |
24 #include "chrome/browser/autofill/name_field.h" | 24 #include "chrome/browser/autofill/name_field.h" |
25 #include "chrome/browser/autofill/phone_field.h" | 25 #include "chrome/browser/autofill/phone_field.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 bool IsTextField(const string16& type) { | 30 bool IsTextField(const std::string& type) { |
31 return type == ASCIIToUTF16("text"); | 31 return type == "text"; |
32 } | 32 } |
33 | 33 |
34 bool IsEmailField(const string16& type) { | 34 bool IsEmailField(const std::string& type) { |
35 return type == ASCIIToUTF16("email"); | 35 return type == "email"; |
36 } | 36 } |
37 | 37 |
38 bool IsTelephoneField(const string16& type) { | 38 bool IsTelephoneField(const std::string& type) { |
39 return type == ASCIIToUTF16("tel"); | 39 return type == "tel"; |
40 } | 40 } |
41 | 41 |
42 bool IsSelectField(const string16& type) { | 42 bool IsSelectField(const std::string& type) { |
43 return type == ASCIIToUTF16("select-one"); | 43 return type == "select-one"; |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 // static | 48 // static |
49 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields, | 49 void FormField::ParseFormFields(const std::vector<AutofillField*>& fields, |
50 FieldTypeMap* map) { | 50 FieldTypeMap* map) { |
51 // Set up a working copy of the fields to be processed. | 51 // Set up a working copy of the fields to be processed. |
52 std::vector<const AutofillField*> remaining_fields(fields.size()); | 52 std::vector<const AutofillField*> remaining_fields(fields.size()); |
53 std::copy(fields.begin(), fields.end(), remaining_fields.begin()); | 53 std::copy(fields.begin(), fields.end(), remaining_fields.begin()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 continue; | 176 continue; |
177 } | 177 } |
178 | 178 |
179 // Add entries into the map for each field type found in |form_field|. | 179 // Add entries into the map for each field type found in |form_field|. |
180 bool ok = form_field->ClassifyField(map); | 180 bool ok = form_field->ClassifyField(map); |
181 DCHECK(ok); | 181 DCHECK(ok); |
182 } | 182 } |
183 | 183 |
184 std::swap(*fields, remaining_fields); | 184 std::swap(*fields, remaining_fields); |
185 } | 185 } |
OLD | NEW |