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; |
| 18 |
17 class AutofillField : public FormFieldData { | 19 class AutofillField : public FormFieldData { |
18 public: | 20 public: |
19 enum PhonePart { | 21 enum PhonePart { |
20 IGNORED = 0, | 22 IGNORED = 0, |
21 PHONE_PREFIX = 1, | 23 PHONE_PREFIX = 1, |
22 PHONE_SUFFIX = 2, | 24 PHONE_SUFFIX = 2, |
23 }; | 25 }; |
24 | 26 |
25 AutofillField(); | 27 AutofillField(); |
26 AutofillField(const FormFieldData& field, const base::string16& unique_name); | 28 AutofillField(const FormFieldData& field, const base::string16& unique_name); |
27 virtual ~AutofillField(); | 29 virtual ~AutofillField(); |
28 | 30 |
29 const base::string16& unique_name() const { return unique_name_; } | 31 const base::string16& unique_name() const { return unique_name_; } |
30 | 32 |
31 const std::string& section() const { return section_; } | 33 const std::string& section() const { return section_; } |
32 AutofillFieldType heuristic_type() const { return heuristic_type_; } | 34 ServerFieldType heuristic_type() const { return heuristic_type_; } |
33 AutofillFieldType server_type() const { return server_type_; } | 35 ServerFieldType server_type() const { return server_type_; } |
34 const FieldTypeSet& possible_types() const { return possible_types_; } | 36 const ServerFieldTypeSet& possible_types() const { return possible_types_; } |
35 PhonePart phone_part() const { return phone_part_; } | 37 PhonePart phone_part() const { return phone_part_; } |
36 | 38 |
37 // Sets the heuristic type of this field, validating the input. | 39 // Sets the heuristic type of this field, validating the input. |
38 void set_section(const std::string& section) { section_ = section; } | 40 void set_section(const std::string& section) { section_ = section; } |
39 void set_heuristic_type(AutofillFieldType type); | 41 void set_heuristic_type(ServerFieldType type); |
40 void set_server_type(AutofillFieldType type); | 42 void set_server_type(ServerFieldType type); |
41 void set_possible_types(const FieldTypeSet& possible_types) { | 43 void set_possible_types(const ServerFieldTypeSet& possible_types) { |
42 possible_types_ = possible_types; | 44 possible_types_ = possible_types; |
43 } | 45 } |
44 void set_phone_part(PhonePart part) { phone_part_ = part; } | 46 void set_phone_part(PhonePart part) { phone_part_ = part; } |
45 | 47 |
46 // This function automatically chooses between server and heuristic autofill | 48 // This function automatically chooses between server and heuristic autofill |
47 // type, depending on the data available. | 49 // type, depending on the data available. |
48 AutofillFieldType type() const; | 50 AutofillType Type() const; |
49 | 51 |
50 // Returns true if the value of this field is empty. | 52 // Returns true if the value of this field is empty. |
51 bool IsEmpty() const; | 53 bool IsEmpty() const; |
52 | 54 |
53 // The unique signature of this field, composed of the field name and the html | 55 // The unique signature of this field, composed of the field name and the html |
54 // input type in a 32-bit hash. | 56 // input type in a 32-bit hash. |
55 std::string FieldSignature() const; | 57 std::string FieldSignature() const; |
56 | 58 |
57 // Returns true if the field type has been determined (without the text in the | 59 // Returns true if the field type has been determined (without the text in the |
58 // field). | 60 // field). |
59 bool IsFieldFillable() const; | 61 bool IsFieldFillable() const; |
60 | 62 |
61 void set_default_value(const std::string& value) { default_value_ = value; } | 63 void set_default_value(const std::string& value) { default_value_ = value; } |
62 const std::string& default_value() const { return default_value_; } | 64 const std::string& default_value() const { return default_value_; } |
63 | 65 |
64 private: | 66 private: |
65 // The unique name of this field, generated by Autofill. | 67 // The unique name of this field, generated by Autofill. |
66 base::string16 unique_name_; | 68 base::string16 unique_name_; |
67 | 69 |
68 // The unique identifier for the section (e.g. billing vs. shipping address) | 70 // The unique identifier for the section (e.g. billing vs. shipping address) |
69 // that this field belongs to. | 71 // that this field belongs to. |
70 std::string section_; | 72 std::string section_; |
71 | 73 |
72 // The type of the field, as determined by the Autofill server. | 74 // The type of the field, as determined by the Autofill server. |
73 AutofillFieldType server_type_; | 75 ServerFieldType server_type_; |
74 | 76 |
75 // The type of the field, as determined by the local heuristics. | 77 // The type of the field, as determined by the local heuristics. |
76 AutofillFieldType heuristic_type_; | 78 ServerFieldType heuristic_type_; |
77 | 79 |
78 // The set of possible types for this field. | 80 // The set of possible types for this field. |
79 FieldTypeSet possible_types_; | 81 ServerFieldTypeSet possible_types_; |
80 | 82 |
81 // Used to track whether this field is a phone prefix or suffix. | 83 // Used to track whether this field is a phone prefix or suffix. |
82 PhonePart phone_part_; | 84 PhonePart phone_part_; |
83 | 85 |
84 // The default value returned by the Autofill server. | 86 // The default value returned by the Autofill server. |
85 std::string default_value_; | 87 std::string default_value_; |
86 | 88 |
87 DISALLOW_COPY_AND_ASSIGN(AutofillField); | 89 DISALLOW_COPY_AND_ASSIGN(AutofillField); |
88 }; | 90 }; |
89 | 91 |
90 } // namespace autofill | 92 } // namespace autofill |
91 | 93 |
92 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ | 94 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_FIELD_H_ |
OLD | NEW |