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