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 13 matching lines...) Expand all Loading... |
24 GET, | 24 GET, |
25 POST | 25 POST |
26 }; | 26 }; |
27 | 27 |
28 enum UploadRequired { | 28 enum UploadRequired { |
29 UPLOAD_NOT_REQUIRED, | 29 UPLOAD_NOT_REQUIRED, |
30 UPLOAD_REQUIRED, | 30 UPLOAD_REQUIRED, |
31 USE_UPLOAD_RATES | 31 USE_UPLOAD_RATES |
32 }; | 32 }; |
33 | 33 |
| 34 class AutoFillMetrics; |
| 35 |
34 // FormStructure stores a single HTML form together with the values entered | 36 // FormStructure stores a single HTML form together with the values entered |
35 // in the fields along with additional information needed by AutoFill. | 37 // in the fields along with additional information needed by AutoFill. |
36 class FormStructure { | 38 class FormStructure { |
37 public: | 39 public: |
38 explicit FormStructure(const webkit_glue::FormData& form); | 40 explicit FormStructure(const webkit_glue::FormData& form); |
39 ~FormStructure(); | 41 ~FormStructure(); |
40 | 42 |
41 // Encodes the XML upload request from this FormStructure. | 43 // Encodes the XML upload request from this FormStructure. |
42 bool EncodeUploadRequest(bool auto_fill_used, | 44 bool EncodeUploadRequest(bool auto_fill_used, |
43 std::string* encoded_xml) const; | 45 std::string* encoded_xml) const; |
44 | 46 |
45 // Encodes the XML query request for the set of forms. | 47 // Encodes the XML query request for the set of forms. |
46 // All fields are returned in one XML. For example, there are three forms, | 48 // All fields are returned in one XML. For example, there are three forms, |
47 // with 2, 4, and 3 fields. The returned XML would have type info for 9 | 49 // with 2, 4, and 3 fields. The returned XML would have type info for 9 |
48 // fields, first two of which would be for the first form, next 4 for the | 50 // fields, first two of which would be for the first form, next 4 for the |
49 // second, and the rest is for the third. | 51 // second, and the rest is for the third. |
50 static bool EncodeQueryRequest(const ScopedVector<FormStructure>& forms, | 52 static bool EncodeQueryRequest(const ScopedVector<FormStructure>& forms, |
51 std::vector<std::string>* encoded_signatures, | 53 std::vector<std::string>* encoded_signatures, |
52 std::string* encoded_xml); | 54 std::string* encoded_xml); |
53 | 55 |
54 // Parses the field types from the server query response. |forms| must be the | 56 // 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. | 57 // same as the one passed to EncodeQueryRequest when constructing the query. |
56 static void ParseQueryResponse(const std::string& response_xml, | 58 static void ParseQueryResponse(const std::string& response_xml, |
57 const std::vector<FormStructure*>& forms, | 59 const std::vector<FormStructure*>& forms, |
58 UploadRequired* upload_required); | 60 UploadRequired* upload_required, |
| 61 const AutoFillMetrics& metric_logger); |
59 | 62 |
60 // The unique signature for this form, composed of the target url domain, | 63 // 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. | 64 // the form name, and the form field names in a 64-bit hash. |
62 std::string FormSignature() const; | 65 std::string FormSignature() const; |
63 | 66 |
64 // Runs a quick heuristic to rule out forms that are obviously not | 67 // Runs a quick heuristic to rule out forms that are obviously not |
65 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the | 68 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the |
66 // form's method be POST is only applied if |require_method_post| is true. | 69 // form's method be POST is only applied if |require_method_post| is true. |
67 bool IsAutoFillable(bool require_method_post) const; | 70 bool IsAutoFillable(bool require_method_post) const; |
68 | 71 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" | 149 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" |
147 std::string form_signature_field_names_; | 150 std::string form_signature_field_names_; |
148 | 151 |
149 // GET or POST. | 152 // GET or POST. |
150 RequestMethod method_; | 153 RequestMethod method_; |
151 | 154 |
152 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 155 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
153 }; | 156 }; |
154 | 157 |
155 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 158 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
OLD | NEW |