| 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 #ifndef CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ | 6 #define CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" |
| 12 #include "chrome/browser/autofill/autofill_field.h" | 13 #include "chrome/browser/autofill/autofill_field.h" |
| 13 #include "chrome/browser/autofill/form_field.h" | 14 #include "chrome/browser/autofill/form_field.h" |
| 14 | 15 |
| 15 class AutofillScanner; | 16 class AutofillScanner; |
| 16 | 17 |
| 17 // A form field that can parse either a FullNameField or a FirstLastNameField. | 18 // A form field that can parse either a FullNameField or a FirstLastNameField. |
| 18 class NameField : public FormField { | 19 class NameField : public FormField { |
| 19 public: | 20 public: |
| 20 static NameField* Parse(AutofillScanner* scanner, bool is_ecml); | 21 static NameField* Parse(AutofillScanner* scanner, bool is_ecml); |
| 21 | 22 |
| 22 protected: | 23 protected: |
| 23 NameField() {} | 24 NameField() {} |
| 24 | 25 |
| 26 // FormField: |
| 27 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; |
| 28 |
| 25 private: | 29 private: |
| 30 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstMiddleLast); |
| 31 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstMiddleLast2); |
| 32 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstLast); |
| 33 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstLast2); |
| 34 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstLastMiddleWithSpaces); |
| 35 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstLastEmpty); |
| 36 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstMiddleLastEmpty); |
| 37 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, MiddleInitial); |
| 38 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, MiddleInitialAtEnd); |
| 39 FRIEND_TEST_ALL_PREFIXES(NameFieldTest, ECMLFirstMiddleLast); |
| 40 |
| 26 DISALLOW_COPY_AND_ASSIGN(NameField); | 41 DISALLOW_COPY_AND_ASSIGN(NameField); |
| 27 }; | 42 }; |
| 28 | 43 |
| 29 // A form field that can parse a full name field. | |
| 30 class FullNameField : public NameField { | |
| 31 public: | |
| 32 virtual bool GetFieldInfo(FieldTypeMap* field_type_map) const OVERRIDE; | |
| 33 | |
| 34 static FullNameField* Parse(AutofillScanner* scanner); | |
| 35 | |
| 36 private: | |
| 37 explicit FullNameField(const AutofillField* field); | |
| 38 | |
| 39 const AutofillField* field_; | |
| 40 DISALLOW_COPY_AND_ASSIGN(FullNameField); | |
| 41 }; | |
| 42 | |
| 43 // A form field that can parse a first and last name field. | |
| 44 class FirstLastNameField : public NameField { | |
| 45 public: | |
| 46 virtual bool GetFieldInfo(FieldTypeMap* field_type_map) const OVERRIDE; | |
| 47 | |
| 48 static FirstLastNameField* ParseSpecificName(AutofillScanner* scanner); | |
| 49 static FirstLastNameField* ParseComponentNames(AutofillScanner* scanner); | |
| 50 static FirstLastNameField* ParseEcmlName(AutofillScanner* scanner); | |
| 51 static FirstLastNameField* Parse(AutofillScanner* scanner, bool is_ecml); | |
| 52 | |
| 53 private: | |
| 54 FirstLastNameField(); | |
| 55 | |
| 56 const AutofillField* first_name_; | |
| 57 const AutofillField* middle_name_; // Optional. | |
| 58 const AutofillField* last_name_; | |
| 59 bool middle_initial_; // True if middle_name_ is a middle initial. | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(FirstLastNameField); | |
| 62 }; | |
| 63 | |
| 64 #endif // CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ | 44 #endif // CHROME_BROWSER_AUTOFILL_NAME_FIELD_H_ |
| OLD | NEW |