| 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "components/autofill/core/browser/autofill_type.h" | 13 #include "components/autofill/core/browser/autofill_type.h" |
| 14 #include "components/autofill/core/browser/form_field.h" | 14 #include "components/autofill/core/browser/form_field.h" |
| 15 | 15 |
| 16 namespace autofill { | 16 namespace autofill { |
| 17 | 17 |
| 18 class AutofillField; | 18 class AutofillField; |
| 19 class AutofillScanner; | 19 class AutofillScanner; |
| 20 | 20 |
| 21 class CreditCardField : public FormField { | 21 class CreditCardField : public FormField { |
| 22 public: | 22 public: |
| 23 virtual ~CreditCardField(); |
| 23 static FormField* Parse(AutofillScanner* scanner); | 24 static FormField* Parse(AutofillScanner* scanner); |
| 24 | 25 |
| 25 protected: | 26 protected: |
| 26 // FormField: | 27 // FormField: |
| 27 virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE; | 28 virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 friend class CreditCardFieldTest; | 31 friend class CreditCardFieldTest; |
| 31 | 32 |
| 32 CreditCardField(); | 33 CreditCardField(); |
| 33 | 34 |
| 34 // For the combined expiration field we return |exp_year_type_|; otherwise if | 35 // For the combined expiration field we return |exp_year_type_|; otherwise if |
| 35 // |expiration_year_| is having year with |max_length| of 2-digits we return | 36 // |expiration_year_| is having year with |max_length| of 2-digits we return |
| 36 // |CREDIT_CARD_EXP_2_DIGIT_YEAR|; otherwise |CREDIT_CARD_EXP_4_DIGIT_YEAR|. | 37 // |CREDIT_CARD_EXP_2_DIGIT_YEAR|; otherwise |CREDIT_CARD_EXP_4_DIGIT_YEAR|. |
| 37 ServerFieldType GetExpirationYearType() const; | 38 ServerFieldType GetExpirationYearType() const; |
| 38 | 39 |
| 39 const AutofillField* cardholder_; // Optional. | 40 AutofillField* cardholder_; // Optional. |
| 40 | 41 |
| 41 // Occasionally pages have separate fields for the cardholder's first and | 42 // Occasionally pages have separate fields for the cardholder's first and |
| 42 // last names; for such pages |cardholder_| holds the first name field and | 43 // last names; for such pages |cardholder_| holds the first name field and |
| 43 // we store the last name field here. | 44 // we store the last name field here. |
| 44 // (We could store an embedded |NameField| object here, but we don't do so | 45 // (We could store an embedded |NameField| object here, but we don't do so |
| 45 // because the text patterns for matching a cardholder name are different | 46 // because the text patterns for matching a cardholder name are different |
| 46 // than for ordinary names, and because cardholder names never have titles, | 47 // than for ordinary names, and because cardholder names never have titles, |
| 47 // middle names or suffixes.) | 48 // middle names or suffixes.) |
| 48 const AutofillField* cardholder_last_; | 49 AutofillField* cardholder_last_; |
| 49 | 50 |
| 50 // TODO(jhawkins): Parse the select control. | 51 // TODO(jhawkins): Parse the select control. |
| 51 const AutofillField* type_; // Optional. | 52 AutofillField* type_; // Optional. |
| 52 const AutofillField* number_; // Required. | 53 std::vector<AutofillField*> numbers_; // Required. |
| 53 | 54 |
| 54 // The 3-digit card verification number; we don't currently fill this. | 55 // The 3-digit card verification number; we don't currently fill this. |
| 55 const AutofillField* verification_; | 56 AutofillField* verification_; |
| 56 | 57 |
| 57 // Either |expiration_date_| or both |expiration_month_| and | 58 // Either |expiration_date_| or both |expiration_month_| and |
| 58 // |expiration_year_| are required. | 59 // |expiration_year_| are required. |
| 59 const AutofillField* expiration_month_; | 60 AutofillField* expiration_month_; |
| 60 const AutofillField* expiration_year_; | 61 AutofillField* expiration_year_; |
| 61 const AutofillField* expiration_date_; | 62 AutofillField* expiration_date_; |
| 62 | 63 |
| 63 // For combined expiration field having year as 2-digits we store here | 64 // For combined expiration field having year as 2-digits we store here |
| 64 // |CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR|; otherwise we store | 65 // |CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR|; otherwise we store |
| 65 // |CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR|. | 66 // |CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR|. |
| 66 ServerFieldType exp_year_type_; | 67 ServerFieldType exp_year_type_; |
| 67 | 68 |
| 68 DISALLOW_COPY_AND_ASSIGN(CreditCardField); | 69 DISALLOW_COPY_AND_ASSIGN(CreditCardField); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 } // namespace autofill | 72 } // namespace autofill |
| 72 | 73 |
| 73 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ | 74 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_ |
| OLD | NEW |