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_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 20 matching lines...) Expand all Loading... |
31 class AutofillMetrics; | 31 class AutofillMetrics; |
32 | 32 |
33 namespace base { | 33 namespace base { |
34 class TimeTicks; | 34 class TimeTicks; |
35 } | 35 } |
36 | 36 |
37 namespace buzz { | 37 namespace buzz { |
38 class XmlElement; | 38 class XmlElement; |
39 } | 39 } |
40 | 40 |
41 namespace webkit_glue { | 41 namespace webkit { |
| 42 namespace forms { |
42 struct FormData; | 43 struct FormData; |
43 struct FormDataPredictions; | 44 struct FormDataPredictions; |
44 } | 45 } |
| 46 } |
45 | 47 |
46 // FormStructure stores a single HTML form together with the values entered | 48 // FormStructure stores a single HTML form together with the values entered |
47 // in the fields along with additional information needed by Autofill. | 49 // in the fields along with additional information needed by Autofill. |
48 class FormStructure { | 50 class FormStructure { |
49 public: | 51 public: |
50 explicit FormStructure(const webkit_glue::FormData& form); | 52 explicit FormStructure(const webkit::forms::FormData& form); |
51 virtual ~FormStructure(); | 53 virtual ~FormStructure(); |
52 | 54 |
53 // Runs several heuristics against the form fields to determine their possible | 55 // Runs several heuristics against the form fields to determine their possible |
54 // types. | 56 // types. |
55 void DetermineHeuristicTypes(); | 57 void DetermineHeuristicTypes(); |
56 | 58 |
57 // Encodes the XML upload request from this FormStructure. | 59 // Encodes the XML upload request from this FormStructure. |
58 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, | 60 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, |
59 bool form_was_autofilled, | 61 bool form_was_autofilled, |
60 std::string* encoded_xml) const; | 62 std::string* encoded_xml) const; |
(...skipping 10 matching lines...) Expand all Loading... |
71 // Parses the field types from the server query response. |forms| must be the | 73 // Parses the field types from the server query response. |forms| must be the |
72 // same as the one passed to EncodeQueryRequest when constructing the query. | 74 // same as the one passed to EncodeQueryRequest when constructing the query. |
73 static void ParseQueryResponse(const std::string& response_xml, | 75 static void ParseQueryResponse(const std::string& response_xml, |
74 const std::vector<FormStructure*>& forms, | 76 const std::vector<FormStructure*>& forms, |
75 const AutofillMetrics& metric_logger); | 77 const AutofillMetrics& metric_logger); |
76 | 78 |
77 // Fills |forms| with the details from the given |form_structures| and their | 79 // Fills |forms| with the details from the given |form_structures| and their |
78 // fields' predicted types. | 80 // fields' predicted types. |
79 static void GetFieldTypePredictions( | 81 static void GetFieldTypePredictions( |
80 const std::vector<FormStructure*>& form_structures, | 82 const std::vector<FormStructure*>& form_structures, |
81 std::vector<webkit_glue::FormDataPredictions>* forms); | 83 std::vector<webkit::forms::FormDataPredictions>* forms); |
82 | 84 |
83 // The unique signature for this form, composed of the target url domain, | 85 // The unique signature for this form, composed of the target url domain, |
84 // the form name, and the form field names in a 64-bit hash. | 86 // the form name, and the form field names in a 64-bit hash. |
85 std::string FormSignature() const; | 87 std::string FormSignature() const; |
86 | 88 |
87 // Runs a quick heuristic to rule out forms that are obviously not | 89 // Runs a quick heuristic to rule out forms that are obviously not |
88 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the | 90 // auto-fillable, like google/yahoo/msn search, etc. The requirement that the |
89 // form's method be POST is only applied if |require_method_post| is true. | 91 // form's method be POST is only applied if |require_method_post| is true. |
90 bool IsAutofillable(bool require_method_post) const; | 92 bool IsAutofillable(bool require_method_post) const; |
91 | 93 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 std::vector<AutofillField*>::const_iterator end() const { | 134 std::vector<AutofillField*>::const_iterator end() const { |
133 return fields_.end(); | 135 return fields_.end(); |
134 } | 136 } |
135 | 137 |
136 const GURL& source_url() const { return source_url_; } | 138 const GURL& source_url() const { return source_url_; } |
137 | 139 |
138 UploadRequired upload_required() const { return upload_required_; } | 140 UploadRequired upload_required() const { return upload_required_; } |
139 | 141 |
140 virtual std::string server_experiment_id() const; | 142 virtual std::string server_experiment_id() const; |
141 | 143 |
142 bool operator==(const webkit_glue::FormData& form) const; | 144 bool operator==(const webkit::forms::FormData& form) const; |
143 bool operator!=(const webkit_glue::FormData& form) const; | 145 bool operator!=(const webkit::forms::FormData& form) const; |
144 | 146 |
145 private: | 147 private: |
146 friend class FormStructureTest; | 148 friend class FormStructureTest; |
147 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); | 149 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); |
148 // 64-bit hash of the string - used in FormSignature and unit-tests. | 150 // 64-bit hash of the string - used in FormSignature and unit-tests. |
149 static std::string Hash64Bit(const std::string& str); | 151 static std::string Hash64Bit(const std::string& str); |
150 | 152 |
151 enum EncodeRequestType { | 153 enum EncodeRequestType { |
152 QUERY, | 154 QUERY, |
153 UPLOAD, | 155 UPLOAD, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 RequestMethod method_; | 209 RequestMethod method_; |
208 | 210 |
209 // Whether the form includes any field types explicitly specified by the site | 211 // Whether the form includes any field types explicitly specified by the site |
210 // author, via the |autocompletetype| attribute. | 212 // author, via the |autocompletetype| attribute. |
211 bool has_author_specified_types_; | 213 bool has_author_specified_types_; |
212 | 214 |
213 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 215 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
214 }; | 216 }; |
215 | 217 |
216 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 218 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
OLD | NEW |