Chromium Code Reviews| Index: components/autofill/core/browser/name_field.cc |
| diff --git a/components/autofill/core/browser/name_field.cc b/components/autofill/core/browser/name_field.cc |
| index 8532de13c3a1b1f7bd25d04c3a3b90fdd7856a2a..2b60b181153f2516d4d5e0528197b3288f1edaeb 100644 |
| --- a/components/autofill/core/browser/name_field.cc |
| +++ b/components/autofill/core/browser/name_field.cc |
| @@ -24,6 +24,7 @@ class FullNameField : public NameField { |
| protected: |
| // FormField: |
| bool ClassifyField(ServerFieldTypeMap* map) const override; |
| + size_t FieldCount() const override; |
| private: |
| explicit FullNameField(AutofillField* field); |
| @@ -45,6 +46,7 @@ class FirstLastNameField : public NameField { |
| protected: |
| // FormField: |
| bool ClassifyField(ServerFieldTypeMap* map) const override; |
| + size_t FieldCount() const override; |
| private: |
| FirstLastNameField(); |
| @@ -73,9 +75,16 @@ scoped_ptr<FormField> NameField::Parse(AutofillScanner* scanner) { |
| // This is overriden in concrete subclasses. |
| bool NameField::ClassifyField(ServerFieldTypeMap* map) const { |
| + NOTREACHED(); |
| return false; |
| } |
| +// This is overriden in concrete subclasses. |
|
Evan Stade
2015/01/21 22:52:50
nit: spelling
Lei Zhang
2015/01/22 08:07:37
Done.
|
| +size_t NameField::FieldCount() const { |
| + NOTREACHED(); |
| + return 0; |
| +} |
| + |
| // static |
| scoped_ptr<FullNameField> FullNameField::Parse(AutofillScanner* scanner) { |
| // Exclude e.g. "username" or "nickname" fields. |
| @@ -99,7 +108,12 @@ bool FullNameField::ClassifyField(ServerFieldTypeMap* map) const { |
| return AddClassification(field_, NAME_FULL, map); |
| } |
| +size_t FullNameField::FieldCount() const { |
| + return 1; |
| +} |
| + |
| FullNameField::FullNameField(AutofillField* field) : field_(field) { |
| + DCHECK(field); |
| } |
| scoped_ptr<FirstLastNameField> FirstLastNameField::ParseSpecificName( |
| @@ -214,4 +228,17 @@ bool FirstLastNameField::ClassifyField(ServerFieldTypeMap* map) const { |
| return ok; |
| } |
| +size_t FirstLastNameField::FieldCount() const { |
| + size_t count = 0; |
| + |
| + if (first_name_) |
| + ++count; |
| + if (middle_name_) |
| + ++count; |
| + if (last_name_) |
| + ++count; |
| + |
| + return count; |
| +} |
| + |
| } // namespace autofill |