| 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 forms that are obviously not | 64 // Runs a quick heuristic to rule out pages but obviously not auto-fillable, |
| 65 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the | 65 // like google/yahoo/msn search, etc. |
| 66 // form's method be POST is only applied if |require_method_post| is true. | 66 bool IsAutoFillable() const; |
| 67 bool IsAutoFillable(bool require_method_post) const; | |
| 68 | 67 |
| 69 // Returns true if at least one of the form fields relevant for AutoFill | 68 // Returns true if at least one of the form fields relevant for AutoFill |
| 70 // is not empty. | 69 // is not empty. |
| 71 bool HasAutoFillableValues() const; | 70 bool HasAutoFillableValues() const; |
| 72 | 71 |
| 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 |
| 73 // Resets |autofill_count_| and counts the number of auto-fillable fields. | 80 // Resets |autofill_count_| and counts the number of auto-fillable fields. |
| 74 // This is used when we receive server data for form fields. At that time, | 81 // This is used when we receive server data for form fields. At that time, |
| 75 // we may have more known fields than just the number of fields we matched | 82 // we may have more known fields than just the number of fields we matched |
| 76 // heuristically. | 83 // heuristically. |
| 77 void UpdateAutoFillCount(); | 84 void UpdateAutoFillCount(); |
| 78 | 85 |
| 79 // Returns true if this form matches the structural requirements for AutoFill. | 86 // Returns true if this form matches the structural requirements for AutoFill. |
| 80 // The requirement that the form's method be POST is only applied if | 87 bool ShouldBeParsed() const; |
| 81 // |require_method_post| is true. | |
| 82 bool ShouldBeParsed(bool require_method_post) const; | |
| 83 | 88 |
| 84 // Sets the possible types for the field at |index|. | 89 // Sets the possible types for the field at |index|. |
| 85 void set_possible_types(int index, const FieldTypeSet& types); | 90 void set_possible_types(int index, const FieldTypeSet& types); |
| 86 | 91 |
| 87 const AutoFillField* field(int index) const; | 92 const AutoFillField* field(int index) const; |
| 88 size_t field_count() const; | 93 size_t field_count() const; |
| 89 | 94 |
| 90 // Returns the number of fields that are able to be autofilled. | 95 // Returns the number of fields that are able to be autofilled. |
| 91 size_t autofill_count() const { return autofill_count_; } | 96 size_t autofill_count() const { return autofill_count_; } |
| 92 | 97 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" | 151 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" |
| 147 std::string form_signature_field_names_; | 152 std::string form_signature_field_names_; |
| 148 | 153 |
| 149 // GET or POST. | 154 // GET or POST. |
| 150 RequestMethod method_; | 155 RequestMethod method_; |
| 151 | 156 |
| 152 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 157 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
| 153 }; | 158 }; |
| 154 | 159 |
| 155 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 160 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
| OLD | NEW |