| 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 19 matching lines...) Expand all Loading... |
| 30 class AutofillMetrics; | 30 class AutofillMetrics; |
| 31 | 31 |
| 32 namespace base { | 32 namespace base { |
| 33 class TimeTicks; | 33 class TimeTicks; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace buzz { | 36 namespace buzz { |
| 37 class XmlElement; | 37 class XmlElement; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace webkit { | 40 namespace chrome { |
| 41 namespace forms { | |
| 42 struct FormData; | |
| 43 struct FormDataPredictions; | 41 struct FormDataPredictions; |
| 44 } | 42 } |
| 43 |
| 44 namespace content { |
| 45 struct FormData; |
| 45 } | 46 } |
| 46 | 47 |
| 47 // FormStructure stores a single HTML form together with the values entered | 48 // FormStructure stores a single HTML form together with the values entered |
| 48 // in the fields along with additional information needed by Autofill. | 49 // in the fields along with additional information needed by Autofill. |
| 49 class FormStructure { | 50 class FormStructure { |
| 50 public: | 51 public: |
| 51 explicit FormStructure(const webkit::forms::FormData& form); | 52 explicit FormStructure(const content::FormData& form); |
| 52 virtual ~FormStructure(); | 53 virtual ~FormStructure(); |
| 53 | 54 |
| 54 // Runs several heuristics against the form fields to determine their possible | 55 // Runs several heuristics against the form fields to determine their possible |
| 55 // types. | 56 // types. |
| 56 void DetermineHeuristicTypes(); | 57 void DetermineHeuristicTypes(); |
| 57 | 58 |
| 58 // Encodes the XML upload request from this FormStructure. | 59 // Encodes the XML upload request from this FormStructure. |
| 59 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, | 60 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, |
| 60 bool form_was_autofilled, | 61 bool form_was_autofilled, |
| 61 std::string* encoded_xml) const; | 62 std::string* encoded_xml) const; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 72 // 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 |
| 73 // same as the one passed to EncodeQueryRequest when constructing the query. | 74 // same as the one passed to EncodeQueryRequest when constructing the query. |
| 74 static void ParseQueryResponse(const std::string& response_xml, | 75 static void ParseQueryResponse(const std::string& response_xml, |
| 75 const std::vector<FormStructure*>& forms, | 76 const std::vector<FormStructure*>& forms, |
| 76 const AutofillMetrics& metric_logger); | 77 const AutofillMetrics& metric_logger); |
| 77 | 78 |
| 78 // 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 |
| 79 // fields' predicted types. | 80 // fields' predicted types. |
| 80 static void GetFieldTypePredictions( | 81 static void GetFieldTypePredictions( |
| 81 const std::vector<FormStructure*>& form_structures, | 82 const std::vector<FormStructure*>& form_structures, |
| 82 std::vector<webkit::forms::FormDataPredictions>* forms); | 83 std::vector<chrome::FormDataPredictions>* forms); |
| 83 | 84 |
| 84 // 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, |
| 85 // 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. |
| 86 std::string FormSignature() const; | 87 std::string FormSignature() const; |
| 87 | 88 |
| 88 // 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 |
| 89 // 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 |
| 90 // 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. |
| 91 bool IsAutofillable(bool require_method_post) const; | 92 bool IsAutofillable(bool require_method_post) const; |
| 92 | 93 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 std::vector<AutofillField*>::const_iterator end() const { | 134 std::vector<AutofillField*>::const_iterator end() const { |
| 134 return fields_.end(); | 135 return fields_.end(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 const GURL& source_url() const { return source_url_; } | 138 const GURL& source_url() const { return source_url_; } |
| 138 | 139 |
| 139 UploadRequired upload_required() const { return upload_required_; } | 140 UploadRequired upload_required() const { return upload_required_; } |
| 140 | 141 |
| 141 virtual std::string server_experiment_id() const; | 142 virtual std::string server_experiment_id() const; |
| 142 | 143 |
| 143 bool operator==(const webkit::forms::FormData& form) const; | 144 bool operator==(const content::FormData& form) const; |
| 144 bool operator!=(const webkit::forms::FormData& form) const; | 145 bool operator!=(const content::FormData& form) const; |
| 145 | 146 |
| 146 private: | 147 private: |
| 147 friend class FormStructureTest; | 148 friend class FormStructureTest; |
| 148 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); | 149 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); |
| 149 // 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. |
| 150 static std::string Hash64Bit(const std::string& str); | 151 static std::string Hash64Bit(const std::string& str); |
| 151 | 152 |
| 152 enum EncodeRequestType { | 153 enum EncodeRequestType { |
| 153 QUERY, | 154 QUERY, |
| 154 UPLOAD, | 155 UPLOAD, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 RequestMethod method_; | 209 RequestMethod method_; |
| 209 | 210 |
| 210 // 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 |
| 211 // author, via the |autocompletetype| attribute. | 212 // author, via the |autocompletetype| attribute. |
| 212 bool has_author_specified_types_; | 213 bool has_author_specified_types_; |
| 213 | 214 |
| 214 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 215 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
| 215 }; | 216 }; |
| 216 | 217 |
| 217 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ | 218 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ |
| OLD | NEW |