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/name_field.h" | 5 #include "components/autofill/core/browser/name_field.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_regex_constants.h" | 10 #include "components/autofill/core/browser/autofill_regex_constants.h" |
11 #include "components/autofill/core/browser/autofill_scanner.h" | 11 #include "components/autofill/core/browser/autofill_scanner.h" |
12 #include "components/autofill/core/browser/autofill_type.h" | 12 #include "components/autofill/core/browser/autofill_type.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 | 14 |
15 using base::UTF8ToUTF16; | 15 using base::UTF8ToUTF16; |
16 | 16 |
17 namespace autofill { | 17 namespace autofill { |
18 namespace { | 18 namespace { |
19 | 19 |
20 // A form field that can parse a full name field. | 20 // A form field that can parse a full name field. |
21 class FullNameField : public NameField { | 21 class FullNameField : public NameField { |
22 public: | 22 public: |
23 static FullNameField* Parse(AutofillScanner* scanner); | 23 static FullNameField* Parse(AutofillScanner* scanner); |
24 | 24 |
25 protected: | 25 protected: |
26 // FormField: | 26 // FormField: |
27 virtual bool ClassifyField(ServerFieldTypeMap* map) const override; | 27 bool ClassifyField(ServerFieldTypeMap* map) const override; |
28 | 28 |
29 private: | 29 private: |
30 explicit FullNameField(AutofillField* field); | 30 explicit FullNameField(AutofillField* field); |
31 | 31 |
32 AutofillField* field_; | 32 AutofillField* field_; |
33 | 33 |
34 DISALLOW_COPY_AND_ASSIGN(FullNameField); | 34 DISALLOW_COPY_AND_ASSIGN(FullNameField); |
35 }; | 35 }; |
36 | 36 |
37 // A form field that can parse a first and last name field. | 37 // A form field that can parse a first and last name field. |
38 class FirstLastNameField : public NameField { | 38 class FirstLastNameField : public NameField { |
39 public: | 39 public: |
40 static FirstLastNameField* ParseSpecificName(AutofillScanner* scanner); | 40 static FirstLastNameField* ParseSpecificName(AutofillScanner* scanner); |
41 static FirstLastNameField* ParseComponentNames(AutofillScanner* scanner); | 41 static FirstLastNameField* ParseComponentNames(AutofillScanner* scanner); |
42 static FirstLastNameField* Parse(AutofillScanner* scanner); | 42 static FirstLastNameField* Parse(AutofillScanner* scanner); |
43 | 43 |
44 protected: | 44 protected: |
45 // FormField: | 45 // FormField: |
46 virtual bool ClassifyField(ServerFieldTypeMap* map) const override; | 46 bool ClassifyField(ServerFieldTypeMap* map) const override; |
47 | 47 |
48 private: | 48 private: |
49 FirstLastNameField(); | 49 FirstLastNameField(); |
50 | 50 |
51 AutofillField* first_name_; | 51 AutofillField* first_name_; |
52 AutofillField* middle_name_; // Optional. | 52 AutofillField* middle_name_; // Optional. |
53 AutofillField* last_name_; | 53 AutofillField* last_name_; |
54 bool middle_initial_; // True if middle_name_ is a middle initial. | 54 bool middle_initial_; // True if middle_name_ is a middle initial. |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(FirstLastNameField); | 56 DISALLOW_COPY_AND_ASSIGN(FirstLastNameField); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 bool FirstLastNameField::ClassifyField(ServerFieldTypeMap* map) const { | 209 bool FirstLastNameField::ClassifyField(ServerFieldTypeMap* map) const { |
210 bool ok = AddClassification(first_name_, NAME_FIRST, map); | 210 bool ok = AddClassification(first_name_, NAME_FIRST, map); |
211 ok = ok && AddClassification(last_name_, NAME_LAST, map); | 211 ok = ok && AddClassification(last_name_, NAME_LAST, map); |
212 ServerFieldType type = middle_initial_ ? NAME_MIDDLE_INITIAL : NAME_MIDDLE; | 212 ServerFieldType type = middle_initial_ ? NAME_MIDDLE_INITIAL : NAME_MIDDLE; |
213 ok = ok && AddClassification(middle_name_, type, map); | 213 ok = ok && AddClassification(middle_name_, type, map); |
214 return ok; | 214 return ok; |
215 } | 215 } |
216 | 216 |
217 } // namespace autofill | 217 } // namespace autofill |
OLD | NEW |