| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace buzz { | 44 namespace buzz { |
| 45 class XmlElement; | 45 class XmlElement; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // FormStructure stores a single HTML form together with the values entered | 48 // FormStructure stores a single HTML form together with the values entered |
| 49 // in the fields along with additional information needed by Autofill. | 49 // in the fields along with additional information needed by Autofill. |
| 50 class FormStructure { | 50 class FormStructure { |
| 51 public: | 51 public: |
| 52 explicit FormStructure(const FormData& form); | 52 FormStructure(const FormData& form, std::string autocheckout_url_prefix); |
| 53 virtual ~FormStructure(); | 53 virtual ~FormStructure(); |
| 54 | 54 |
| 55 // Runs several heuristics against the form fields to determine their possible | 55 // Runs several heuristics against the form fields to determine their possible |
| 56 // types. | 56 // types. |
| 57 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger); | 57 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger); |
| 58 | 58 |
| 59 // Encodes the XML upload request from this FormStructure. | 59 // Encodes the XML upload request from this FormStructure. |
| 60 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, | 60 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, |
| 61 bool form_was_autofilled, | 61 bool form_was_autofilled, |
| 62 std::string* encoded_xml) const; | 62 std::string* encoded_xml) const; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Returns a FormData containing the data this form structure knows about. | 157 // Returns a FormData containing the data this form structure knows about. |
| 158 // |user_submitted| is currently always false. | 158 // |user_submitted| is currently always false. |
| 159 FormData ToFormData() const; | 159 FormData ToFormData() const; |
| 160 | 160 |
| 161 bool operator==(const FormData& form) const; | 161 bool operator==(const FormData& form) const; |
| 162 bool operator!=(const FormData& form) const; | 162 bool operator!=(const FormData& form) const; |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 friend class FormStructureTest; | 165 friend class FormStructureTest; |
| 166 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); | 166 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); |
| 167 |
| 167 // 64-bit hash of the string - used in FormSignature and unit-tests. | 168 // 64-bit hash of the string - used in FormSignature and unit-tests. |
| 168 static std::string Hash64Bit(const std::string& str); | 169 static std::string Hash64Bit(const std::string& str); |
| 169 | 170 |
| 170 enum EncodeRequestType { | 171 enum EncodeRequestType { |
| 171 QUERY, | 172 QUERY, |
| 172 UPLOAD, | 173 UPLOAD, |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 // Adds form info to |encompassing_xml_element|. |request_type| indicates if | 176 // Adds form info to |encompassing_xml_element|. |request_type| indicates if |
| 176 // it is a query or upload. | 177 // it is a query or upload. |
| 177 bool EncodeFormRequest(EncodeRequestType request_type, | 178 bool EncodeFormRequest(EncodeRequestType request_type, |
| 178 buzz::XmlElement* encompassing_xml_element) const; | 179 buzz::XmlElement* encompassing_xml_element) const; |
| 179 | 180 |
| 180 // Classifies each field in |fields_| into a logical section. | 181 // Classifies each field in |fields_| into a logical section. |
| 181 // Sections are identified by the heuristic that a logical section should not | 182 // Sections are identified by the heuristic that a logical section should not |
| 182 // include multiple fields of the same autofill type (with some exceptions, as | 183 // include multiple fields of the same autofill type (with some exceptions, as |
| 183 // described in the implementation). Sections are furthermore distinguished | 184 // described in the implementation). Sections are furthermore distinguished |
| 184 // as either credit card or non-credit card sections. | 185 // as either credit card or non-credit card sections. |
| 185 // If |has_author_specified_sections| is true, only the second pass -- | 186 // If |has_author_specified_sections| is true, only the second pass -- |
| 186 // distinguishing credit card sections from non-credit card ones -- is made. | 187 // distinguishing credit card sections from non-credit card ones -- is made. |
| 187 void IdentifySections(bool has_author_specified_sections); | 188 void IdentifySections(bool has_author_specified_sections); |
| 188 | 189 |
| 190 bool IsAutocheckoutEnabled() const; |
| 191 |
| 192 // Returns the minimal number of fillable fields required to start autofill. |
| 193 size_t RequiredFillableFields() const; |
| 194 |
| 189 // The name of the form. | 195 // The name of the form. |
| 190 string16 form_name_; | 196 string16 form_name_; |
| 191 | 197 |
| 192 // The source URL. | 198 // The source URL. |
| 193 GURL source_url_; | 199 GURL source_url_; |
| 194 | 200 |
| 195 // The target URL. | 201 // The target URL. |
| 196 GURL target_url_; | 202 GURL target_url_; |
| 197 | 203 |
| 198 // The number of fields able to be auto-filled. | 204 // The number of fields able to be auto-filled. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 217 // form. | 223 // form. |
| 218 std::string server_experiment_id_; | 224 std::string server_experiment_id_; |
| 219 | 225 |
| 220 // GET or POST. | 226 // GET or POST. |
| 221 RequestMethod method_; | 227 RequestMethod method_; |
| 222 | 228 |
| 223 // Whether the form includes any field types explicitly specified by the site | 229 // Whether the form includes any field types explicitly specified by the site |
| 224 // author, via the |autocompletetype| attribute. | 230 // author, via the |autocompletetype| attribute. |
| 225 bool has_author_specified_types_; | 231 bool has_author_specified_types_; |
| 226 | 232 |
| 227 // State of the kEnableExperimentalFormFilling flag. | 233 // The URL prefix matched in autocheckout whitelist. An empty string implies |
| 228 bool experimental_form_filling_enabled_; | 234 // autocheckout is not enabled for this form. |
| 235 std::string autocheckout_url_prefix_; |
| 229 | 236 |
| 230 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 237 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
| 231 }; | 238 }; |
| 232 | 239 |
| 233 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 240 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
| OLD | NEW |