OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_FORM_STRUCTURE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
6 #define CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Parses the field types from the server query response. |forms| must be the | 54 // Parses the field types from the server query response. |forms| must be the |
55 // same as the one passed to EncodeQueryRequest when constructing the query. | 55 // same as the one passed to EncodeQueryRequest when constructing the query. |
56 static void ParseQueryResponse(const std::string& response_xml, | 56 static void ParseQueryResponse(const std::string& response_xml, |
57 const std::vector<FormStructure*>& forms, | 57 const std::vector<FormStructure*>& forms, |
58 UploadRequired* upload_required); | 58 UploadRequired* upload_required); |
59 | 59 |
60 // The unique signature for this form, composed of the target url domain, | 60 // The unique signature for this form, composed of the target url domain, |
61 // the form name, and the form field names in a 64-bit hash. | 61 // the form name, and the form field names in a 64-bit hash. |
62 std::string FormSignature() const; | 62 std::string FormSignature() const; |
63 | 63 |
64 // Runs a quick heuristic to rule out pages but obviously not auto-fillable, | 64 // Runs a quick heuristic to rule out forms that are obviously not |
65 // like google/yahoo/msn search, etc. | 65 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the |
66 bool IsAutoFillable() const; | 66 // form's method be POST is only applied if |require_method_post| is true. |
| 67 bool IsAutoFillable(bool require_method_post) const; |
67 | 68 |
68 // Returns true if at least one of the form fields relevant for AutoFill | 69 // Returns true if at least one of the form fields relevant for AutoFill |
69 // is not empty. | 70 // is not empty. |
70 bool HasAutoFillableValues() const; | 71 bool HasAutoFillableValues() const; |
71 | 72 |
72 // Returns true if at least one of the form fields is a billing field, which | |
73 // includes billing address fields and credit card fields. | |
74 bool HasBillingFields() const; | |
75 | |
76 // Returns true if at least one of the form fields is a non-billing field, | |
77 // which includes billing address fields and credit card fields. | |
78 bool HasNonBillingFields() const; | |
79 | |
80 // Resets |autofill_count_| and counts the number of auto-fillable fields. | 73 // Resets |autofill_count_| and counts the number of auto-fillable fields. |
81 // This is used when we receive server data for form fields. At that time, | 74 // This is used when we receive server data for form fields. At that time, |
82 // we may have more known fields than just the number of fields we matched | 75 // we may have more known fields than just the number of fields we matched |
83 // heuristically. | 76 // heuristically. |
84 void UpdateAutoFillCount(); | 77 void UpdateAutoFillCount(); |
85 | 78 |
86 // Returns true if this form matches the structural requirements for AutoFill. | 79 // Returns true if this form matches the structural requirements for AutoFill. |
87 bool ShouldBeParsed() const; | 80 // The requirement that the form's method be POST is only applied if |
| 81 // |require_method_post| is true. |
| 82 bool ShouldBeParsed(bool require_method_post) const; |
88 | 83 |
89 // Sets the possible types for the field at |index|. | 84 // Sets the possible types for the field at |index|. |
90 void set_possible_types(int index, const FieldTypeSet& types); | 85 void set_possible_types(int index, const FieldTypeSet& types); |
91 | 86 |
92 const AutoFillField* field(int index) const; | 87 const AutoFillField* field(int index) const; |
93 size_t field_count() const; | 88 size_t field_count() const; |
94 | 89 |
95 // Returns the number of fields that are able to be autofilled. | 90 // Returns the number of fields that are able to be autofilled. |
96 size_t autofill_count() const { return autofill_count_; } | 91 size_t autofill_count() const { return autofill_count_; } |
97 | 92 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" | 146 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" |
152 std::string form_signature_field_names_; | 147 std::string form_signature_field_names_; |
153 | 148 |
154 // GET or POST. | 149 // GET or POST. |
155 RequestMethod method_; | 150 RequestMethod method_; |
156 | 151 |
157 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 152 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
158 }; | 153 }; |
159 | 154 |
160 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 155 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
OLD | NEW |