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