OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace autofill { | 37 namespace autofill { |
38 | 38 |
39 struct FormData; | 39 struct FormData; |
40 struct FormDataPredictions; | 40 struct FormDataPredictions; |
41 | 41 |
42 // FormStructure stores a single HTML form together with the values entered | 42 // FormStructure stores a single HTML form together with the values entered |
43 // in the fields along with additional information needed by Autofill. | 43 // in the fields along with additional information needed by Autofill. |
44 class FormStructure { | 44 class FormStructure { |
45 public: | 45 public: |
46 FormStructure(const FormData& form); | 46 explicit FormStructure(const FormData& form); |
47 virtual ~FormStructure(); | 47 virtual ~FormStructure(); |
48 | 48 |
49 // Runs several heuristics against the form fields to determine their possible | 49 // Runs several heuristics against the form fields to determine their possible |
50 // types. | 50 // types. |
51 void DetermineHeuristicTypes(); | 51 void DetermineHeuristicTypes(); |
52 | 52 |
53 // Encodes the XML upload request from this FormStructure. | 53 // Encodes the XML upload request from this FormStructure. |
54 bool EncodeUploadRequest(const ServerFieldTypeSet& available_field_types, | 54 bool EncodeUploadRequest(const ServerFieldTypeSet& available_field_types, |
55 bool form_was_autofilled, | 55 bool form_was_autofilled, |
56 std::string* encoded_xml) const; | 56 std::string* encoded_xml) const; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 UploadRequired upload_required() const { return upload_required_; } | 181 UploadRequired upload_required() const { return upload_required_; } |
182 | 182 |
183 // Returns a FormData containing the data this form structure knows about. | 183 // Returns a FormData containing the data this form structure knows about. |
184 // |user_submitted| is currently always false. | 184 // |user_submitted| is currently always false. |
185 FormData ToFormData() const; | 185 FormData ToFormData() const; |
186 | 186 |
187 bool operator==(const FormData& form) const; | 187 bool operator==(const FormData& form) const; |
188 bool operator!=(const FormData& form) const; | 188 bool operator!=(const FormData& form) const; |
189 | 189 |
| 190 void set_is_unowned() { is_unowned_ = true; } |
| 191 |
190 private: | 192 private: |
191 friend class FormStructureTest; | 193 friend class FormStructureTest; |
192 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); | 194 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); |
193 | 195 |
194 // 64-bit hash of the string - used in FormSignature and unit-tests. | 196 // 64-bit hash of the string - used in FormSignature and unit-tests. |
195 static std::string Hash64Bit(const std::string& str); | 197 static std::string Hash64Bit(const std::string& str); |
196 | 198 |
197 enum EncodeRequestType { | 199 enum EncodeRequestType { |
198 QUERY, | 200 QUERY, |
199 UPLOAD, | 201 UPLOAD, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // to the stored upload rates. | 249 // to the stored upload rates. |
248 UploadRequired upload_required_; | 250 UploadRequired upload_required_; |
249 | 251 |
250 // Whether the form includes any field types explicitly specified by the site | 252 // Whether the form includes any field types explicitly specified by the site |
251 // author, via the |autocompletetype| attribute. | 253 // author, via the |autocompletetype| attribute. |
252 bool has_author_specified_types_; | 254 bool has_author_specified_types_; |
253 | 255 |
254 // True if the form contains at least one password field. | 256 // True if the form contains at least one password field. |
255 bool has_password_field_; | 257 bool has_password_field_; |
256 | 258 |
| 259 // True if the form is unowned, i.e. not for a <form>. |
| 260 bool is_unowned_; |
| 261 |
257 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 262 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
258 }; | 263 }; |
259 | 264 |
260 } // namespace autofill | 265 } // namespace autofill |
261 | 266 |
262 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 267 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |
OLD | NEW |