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_AUTOFILL_FIELD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "components/autofill/core/browser/field_types.h" | 12 #include "components/autofill/core/browser/field_types.h" |
13 #include "components/autofill/core/common/form_field_data.h" | 13 #include "components/autofill/core/common/form_field_data.h" |
14 | 14 |
15 namespace autofill { | 15 namespace autofill { |
16 | 16 |
17 class AutofillType; | 17 class AutofillType; |
18 | 18 |
19 class AutofillField : public FormFieldData { | 19 class AutofillField : public FormFieldData { |
20 public: | 20 public: |
21 enum PhonePart { | 21 enum PhonePart { |
22 IGNORED = 0, | 22 IGNORED = 0, |
23 PHONE_PREFIX = 1, | 23 PHONE_PREFIX = 1, |
24 PHONE_SUFFIX = 2, | 24 PHONE_SUFFIX = 2, |
25 }; | 25 }; |
26 | 26 |
27 // This structure holds the credit card number split information on the html | |
28 // form structure. | |
29 struct CreditCardNumberInfo { | |
30 int part_; | |
31 int start_index_; | |
Ilya Sherman
2014/08/07 20:57:25
Why do you need the part in addition to the index?
Pritam Nikam
2014/08/08 14:14:34
Done.
Removed this structure and instead book-keep
| |
32 }; | |
33 | |
27 AutofillField(); | 34 AutofillField(); |
28 AutofillField(const FormFieldData& field, const base::string16& unique_name); | 35 AutofillField(const FormFieldData& field, const base::string16& unique_name); |
29 virtual ~AutofillField(); | 36 virtual ~AutofillField(); |
30 | 37 |
31 const base::string16& unique_name() const { return unique_name_; } | 38 const base::string16& unique_name() const { return unique_name_; } |
32 | 39 |
33 const std::string& section() const { return section_; } | 40 const std::string& section() const { return section_; } |
34 ServerFieldType heuristic_type() const { return heuristic_type_; } | 41 ServerFieldType heuristic_type() const { return heuristic_type_; } |
35 ServerFieldType server_type() const { return server_type_; } | 42 ServerFieldType server_type() const { return server_type_; } |
36 HtmlFieldType html_type() const { return html_type_; } | 43 HtmlFieldType html_type() const { return html_type_; } |
(...skipping 21 matching lines...) Expand all Loading... | |
58 // input type in a 32-bit hash. | 65 // input type in a 32-bit hash. |
59 std::string FieldSignature() const; | 66 std::string FieldSignature() const; |
60 | 67 |
61 // Returns true if the field type has been determined (without the text in the | 68 // Returns true if the field type has been determined (without the text in the |
62 // field). | 69 // field). |
63 bool IsFieldFillable() const; | 70 bool IsFieldFillable() const; |
64 | 71 |
65 void set_default_value(const std::string& value) { default_value_ = value; } | 72 void set_default_value(const std::string& value) { default_value_ = value; } |
66 const std::string& default_value() const { return default_value_; } | 73 const std::string& default_value() const { return default_value_; } |
67 | 74 |
75 void set_credit_card_number_info(CreditCardNumberInfo* card_number_info) { | |
76 credit_card_number_info_ = card_number_info; | |
77 } | |
78 CreditCardNumberInfo* credit_card_number_info() const { | |
79 return credit_card_number_info_; | |
80 } | |
81 | |
68 // Set |field_data|'s value to |value|. Uses |field|, |address_language_code|, | 82 // Set |field_data|'s value to |value|. Uses |field|, |address_language_code|, |
69 // and |app_locale| as hints when filling exceptional cases like phone number | 83 // and |app_locale| as hints when filling exceptional cases like phone number |
70 // values and <select> fields. Returns |true| if the field has been filled, | 84 // values and <select> fields. Returns |true| if the field has been filled, |
71 // |false| otherwise. | 85 // |false| otherwise. |
72 static bool FillFormField(const AutofillField& field, | 86 static bool FillFormField(const AutofillField& field, |
73 const base::string16& value, | 87 const base::string16& value, |
74 const std::string& address_language_code, | 88 const std::string& address_language_code, |
75 const std::string& app_locale, | 89 const std::string& app_locale, |
76 FormFieldData* field_data); | 90 FormFieldData* field_data); |
77 | 91 |
(...skipping 17 matching lines...) Expand all Loading... | |
95 // The "mode" of the field, as specified by the site author in HTML. | 109 // The "mode" of the field, as specified by the site author in HTML. |
96 // Currently this is used to distinguish between billing and shipping fields. | 110 // Currently this is used to distinguish between billing and shipping fields. |
97 HtmlFieldMode html_mode_; | 111 HtmlFieldMode html_mode_; |
98 | 112 |
99 // The set of possible types for this field. | 113 // The set of possible types for this field. |
100 ServerFieldTypeSet possible_types_; | 114 ServerFieldTypeSet possible_types_; |
101 | 115 |
102 // Used to track whether this field is a phone prefix or suffix. | 116 // Used to track whether this field is a phone prefix or suffix. |
103 PhonePart phone_part_; | 117 PhonePart phone_part_; |
104 | 118 |
119 // Used to track whether this field is a credit card number along with split | |
120 // information. | |
121 CreditCardNumberInfo* credit_card_number_info_; | |
122 | |
105 // The default value returned by the Autofill server. | 123 // The default value returned by the Autofill server. |
106 std::string default_value_; | 124 std::string default_value_; |
107 | 125 |
108 DISALLOW_COPY_AND_ASSIGN(AutofillField); | 126 DISALLOW_COPY_AND_ASSIGN(AutofillField); |
109 }; | 127 }; |
110 | 128 |
111 } // namespace autofill | 129 } // namespace autofill |
112 | 130 |
113 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ | 131 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ |
OLD | NEW |