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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 } | 38 } |
39 | 39 |
40 namespace buzz { | 40 namespace buzz { |
41 class XmlElement; | 41 class XmlElement; |
42 } | 42 } |
43 | 43 |
44 // FormStructure stores a single HTML form together with the values entered | 44 // FormStructure stores a single HTML form together with the values entered |
45 // in the fields along with additional information needed by Autofill. | 45 // in the fields along with additional information needed by Autofill. |
46 class FormStructure { | 46 class FormStructure { |
47 public: | 47 public: |
48 explicit FormStructure(const FormData& form); | 48 FormStructure(const FormData& form, bool autocheckout_enabled); |
Ilya Sherman
2013/01/28 23:21:39
nit: Rather than passing in a boolean, which is ha
benquan
2013/01/29 03:28:30
It will not be consistent with other methods in th
Ilya Sherman
2013/01/29 05:56:35
That's ok. It's worthwhile to move code in that d
benquan
2013/01/30 00:48:42
Is it a new coding style guide requires to replace
Ilya Sherman
2013/01/30 00:52:48
Specifically, booleans as parameters to functions,
benquan
2013/01/30 18:39:00
Bascially we have the same issue with all constant
Ilya Sherman
2013/01/30 21:05:31
I do insist that if you keep this as a parameter t
benquan
2013/01/31 03:21:23
Replaced autochout_enabled with autocheckout_url_p
| |
49 virtual ~FormStructure(); | 49 virtual ~FormStructure(); |
50 | 50 |
51 // Runs several heuristics against the form fields to determine their possible | 51 // Runs several heuristics against the form fields to determine their possible |
52 // types. | 52 // types. |
53 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger); | 53 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger); |
54 | 54 |
55 // Encodes the XML upload request from this FormStructure. | 55 // Encodes the XML upload request from this FormStructure. |
56 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, | 56 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, |
57 bool form_was_autofilled, | 57 bool form_was_autofilled, |
58 std::string* encoded_xml) const; | 58 std::string* encoded_xml) const; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // Returns a FormData containing the data this form structure knows about. | 165 // Returns a FormData containing the data this form structure knows about. |
166 // |user_submitted| is currently always false. | 166 // |user_submitted| is currently always false. |
167 FormData ToFormData() const; | 167 FormData ToFormData() const; |
168 | 168 |
169 bool operator==(const FormData& form) const; | 169 bool operator==(const FormData& form) const; |
170 bool operator!=(const FormData& form) const; | 170 bool operator!=(const FormData& form) const; |
171 | 171 |
172 private: | 172 private: |
173 friend class FormStructureTest; | 173 friend class FormStructureTest; |
174 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); | 174 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); |
175 | |
175 // 64-bit hash of the string - used in FormSignature and unit-tests. | 176 // 64-bit hash of the string - used in FormSignature and unit-tests. |
176 static std::string Hash64Bit(const std::string& str); | 177 static std::string Hash64Bit(const std::string& str); |
177 | 178 |
178 enum EncodeRequestType { | 179 enum EncodeRequestType { |
179 QUERY, | 180 QUERY, |
180 UPLOAD, | 181 UPLOAD, |
181 }; | 182 }; |
182 | 183 |
183 // Adds form info to |encompassing_xml_element|. |request_type| indicates if | 184 // Adds form info to |encompassing_xml_element|. |request_type| indicates if |
184 // it is a query or upload. | 185 // it is a query or upload. |
185 bool EncodeFormRequest(EncodeRequestType request_type, | 186 bool EncodeFormRequest(EncodeRequestType request_type, |
186 buzz::XmlElement* encompassing_xml_element) const; | 187 buzz::XmlElement* encompassing_xml_element) const; |
187 | 188 |
188 // Classifies each field in |fields_| into a logical section. | 189 // Classifies each field in |fields_| into a logical section. |
189 // Sections are identified by the heuristic that a logical section should not | 190 // Sections are identified by the heuristic that a logical section should not |
190 // include multiple fields of the same autofill type (with some exceptions, as | 191 // include multiple fields of the same autofill type (with some exceptions, as |
191 // described in the implementation). Sections are furthermore distinguished | 192 // described in the implementation). Sections are furthermore distinguished |
192 // as either credit card or non-credit card sections. | 193 // as either credit card or non-credit card sections. |
193 // If |has_author_specified_sections| is true, only the second pass -- | 194 // If |has_author_specified_sections| is true, only the second pass -- |
194 // distinguishing credit card sections from non-credit card ones -- is made. | 195 // distinguishing credit card sections from non-credit card ones -- is made. |
195 void IdentifySections(bool has_author_specified_sections); | 196 void IdentifySections(bool has_author_specified_sections); |
196 | 197 |
198 // Returns the minimal number of fillable fields required to start autofill. | |
199 size_t RequiredFillableFields() const; | |
200 | |
197 // The name of the form. | 201 // The name of the form. |
198 string16 form_name_; | 202 string16 form_name_; |
199 | 203 |
200 // The source URL. | 204 // The source URL. |
201 GURL source_url_; | 205 GURL source_url_; |
202 | 206 |
203 // The target URL. | 207 // The target URL. |
204 GURL target_url_; | 208 GURL target_url_; |
205 | 209 |
206 // The number of fields able to be auto-filled. | 210 // The number of fields able to be auto-filled. |
(...skipping 29 matching lines...) Expand all Loading... | |
236 // to any autofill flow, it is set to -1. | 240 // to any autofill flow, it is set to -1. |
237 int total_pages_; | 241 int total_pages_; |
238 | 242 |
239 // Proceed element for multipage Autofill flow. | 243 // Proceed element for multipage Autofill flow. |
240 scoped_ptr<autofill::WebElementDescriptor> proceed_element_descriptor_; | 244 scoped_ptr<autofill::WebElementDescriptor> proceed_element_descriptor_; |
241 | 245 |
242 // Whether the form includes any field types explicitly specified by the site | 246 // Whether the form includes any field types explicitly specified by the site |
243 // author, via the |autocompletetype| attribute. | 247 // author, via the |autocompletetype| attribute. |
244 bool has_author_specified_types_; | 248 bool has_author_specified_types_; |
245 | 249 |
246 // State of the kEnableExperimentalFormFilling flag. | 250 // Whether the autocheckout feature is enabled for the site which contains |
247 bool experimental_form_filling_enabled_; | 251 // this form. |
252 bool autocheckout_enabled_; | |
248 | 253 |
249 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 254 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
250 }; | 255 }; |
251 | 256 |
252 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 257 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
OLD | NEW |