Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: chrome/browser/autofill/form_structure.h

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Mostly cosmetic fixup Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 content {
41 namespace forms {
42 struct FormData; 41 struct FormData;
43 struct FormDataPredictions; 42 struct FormDataPredictions;
44 } 43 }
45 }
46 44
47 // FormStructure stores a single HTML form together with the values entered 45 // FormStructure stores a single HTML form together with the values entered
48 // in the fields along with additional information needed by Autofill. 46 // in the fields along with additional information needed by Autofill.
49 class FormStructure { 47 class FormStructure {
50 public: 48 public:
51 explicit FormStructure(const webkit::forms::FormData& form); 49 explicit FormStructure(const content::FormData& form);
52 virtual ~FormStructure(); 50 virtual ~FormStructure();
53 51
54 // Runs several heuristics against the form fields to determine their possible 52 // Runs several heuristics against the form fields to determine their possible
55 // types. 53 // types.
56 void DetermineHeuristicTypes(); 54 void DetermineHeuristicTypes();
57 55
58 // Encodes the XML upload request from this FormStructure. 56 // Encodes the XML upload request from this FormStructure.
59 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, 57 bool EncodeUploadRequest(const FieldTypeSet& available_field_types,
60 bool form_was_autofilled, 58 bool form_was_autofilled,
61 std::string* encoded_xml) const; 59 std::string* encoded_xml) const;
(...skipping 10 matching lines...) Expand all
72 // Parses the field types from the server query response. |forms| must be the 70 // 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. 71 // same as the one passed to EncodeQueryRequest when constructing the query.
74 static void ParseQueryResponse(const std::string& response_xml, 72 static void ParseQueryResponse(const std::string& response_xml,
75 const std::vector<FormStructure*>& forms, 73 const std::vector<FormStructure*>& forms,
76 const AutofillMetrics& metric_logger); 74 const AutofillMetrics& metric_logger);
77 75
78 // Fills |forms| with the details from the given |form_structures| and their 76 // Fills |forms| with the details from the given |form_structures| and their
79 // fields' predicted types. 77 // fields' predicted types.
80 static void GetFieldTypePredictions( 78 static void GetFieldTypePredictions(
81 const std::vector<FormStructure*>& form_structures, 79 const std::vector<FormStructure*>& form_structures,
82 std::vector<webkit::forms::FormDataPredictions>* forms); 80 std::vector<content::FormDataPredictions>* forms);
83 81
84 // The unique signature for this form, composed of the target url domain, 82 // 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. 83 // the form name, and the form field names in a 64-bit hash.
86 std::string FormSignature() const; 84 std::string FormSignature() const;
87 85
88 // Runs a quick heuristic to rule out forms that are obviously not 86 // 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 87 // 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. 88 // form's method be POST is only applied if |require_method_post| is true.
91 bool IsAutofillable(bool require_method_post) const; 89 bool IsAutofillable(bool require_method_post) const;
92 90
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 std::vector<AutofillField*>::const_iterator end() const { 131 std::vector<AutofillField*>::const_iterator end() const {
134 return fields_.end(); 132 return fields_.end();
135 } 133 }
136 134
137 const GURL& source_url() const { return source_url_; } 135 const GURL& source_url() const { return source_url_; }
138 136
139 UploadRequired upload_required() const { return upload_required_; } 137 UploadRequired upload_required() const { return upload_required_; }
140 138
141 virtual std::string server_experiment_id() const; 139 virtual std::string server_experiment_id() const;
142 140
143 bool operator==(const webkit::forms::FormData& form) const; 141 bool operator==(const content::FormData& form) const;
144 bool operator!=(const webkit::forms::FormData& form) const; 142 bool operator!=(const content::FormData& form) const;
145 143
146 private: 144 private:
147 friend class FormStructureTest; 145 friend class FormStructureTest;
148 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 146 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
149 // 64-bit hash of the string - used in FormSignature and unit-tests. 147 // 64-bit hash of the string - used in FormSignature and unit-tests.
150 static std::string Hash64Bit(const std::string& str); 148 static std::string Hash64Bit(const std::string& str);
151 149
152 enum EncodeRequestType { 150 enum EncodeRequestType {
153 QUERY, 151 QUERY,
154 UPLOAD, 152 UPLOAD,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RequestMethod method_; 206 RequestMethod method_;
209 207
210 // Whether the form includes any field types explicitly specified by the site 208 // Whether the form includes any field types explicitly specified by the site
211 // author, via the |autocompletetype| attribute. 209 // author, via the |autocompletetype| attribute.
212 bool has_author_specified_types_; 210 bool has_author_specified_types_;
213 211
214 DISALLOW_COPY_AND_ASSIGN(FormStructure); 212 DISALLOW_COPY_AND_ASSIGN(FormStructure);
215 }; 213 };
216 214
217 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ 215 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698