Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / credit_card_field.h
blob922f2fc2b2eca17285c893a8bbea2b709585bed9
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/autofill/core/browser/autofill_type.h"
15 #include "components/autofill/core/browser/form_field.h"
17 namespace autofill {
19 class AutofillField;
20 class AutofillScanner;
22 class CreditCardField : public FormField {
23 public:
24 ~CreditCardField() override;
25 static scoped_ptr<FormField> Parse(AutofillScanner* scanner);
27 protected:
28 // FormField:
29 bool ClassifyField(ServerFieldTypeMap* map) const override;
31 private:
32 friend class CreditCardFieldTest;
34 // Returns true if |scanner| points to a field that looks like a month
35 // <select>.
36 static bool LikelyCardMonthSelectField(AutofillScanner* scanner);
38 // Returns true if |scanner| points to a field that looks like a year
39 // <select> for a credit card. i.e. it contains the current year and
40 // the next few years.
41 static bool LikelyCardYearSelectField(AutofillScanner* scanner);
43 // Returns true if |scanner| points to a <select> field that contains credit
44 // card type options.
45 static bool LikelyCardTypeSelectField(AutofillScanner* scanner);
47 // Returns true if |scanner| points to a field that is for a gift card number.
48 // |scanner| advances if this returns true.
49 // Prepaid debit cards do not count as gift cards, since they can be used like
50 // a credit card.
51 static bool IsGiftCardField(AutofillScanner* scanner);
53 CreditCardField();
55 // Parses the expiration month/year/date fields. Returns true if it finds
56 // something new.
57 bool ParseExpirationDate(AutofillScanner* scanner);
59 // For the combined expiration field we return |exp_year_type_|; otherwise if
60 // |expiration_year_| is having year with |max_length| of 2-digits we return
61 // |CREDIT_CARD_EXP_2_DIGIT_YEAR|; otherwise |CREDIT_CARD_EXP_4_DIGIT_YEAR|.
62 ServerFieldType GetExpirationYearType() const;
64 AutofillField* cardholder_; // Optional.
66 // Occasionally pages have separate fields for the cardholder's first and
67 // last names; for such pages |cardholder_| holds the first name field and
68 // we store the last name field here.
69 // (We could store an embedded |NameField| object here, but we don't do so
70 // because the text patterns for matching a cardholder name are different
71 // than for ordinary names, and because cardholder names never have titles,
72 // middle names or suffixes.)
73 AutofillField* cardholder_last_;
75 AutofillField* type_; // Optional.
76 std::vector<AutofillField*> numbers_; // Required.
78 // The 3-digit card verification number; we don't currently fill this.
79 AutofillField* verification_;
81 // Either |expiration_date_| or both |expiration_month_| and
82 // |expiration_year_| are required.
83 AutofillField* expiration_month_;
84 AutofillField* expiration_year_;
85 AutofillField* expiration_date_;
87 // For combined expiration field having year as 2-digits we store here
88 // |CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR|; otherwise we store
89 // |CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR|.
90 ServerFieldType exp_year_type_;
92 DISALLOW_COPY_AND_ASSIGN(CreditCardField);
95 } // namespace autofill
97 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_FIELD_H_