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

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: Response to review 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
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/autofill/autofill_field.h" 13 #include "chrome/browser/autofill/autofill_field.h"
14 #include "chrome/browser/autofill/autofill_type.h" 14 #include "chrome/browser/autofill/autofill_type.h"
15 #include "chrome/browser/autofill/field_types.h" 15 #include "chrome/browser/autofill/field_types.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 struct FormData;
19 struct FormDataPredictions;
18 20
19 enum RequestMethod { 21 enum RequestMethod {
20 GET, 22 GET,
21 POST 23 POST
22 }; 24 };
23 25
24 enum UploadRequired { 26 enum UploadRequired {
25 UPLOAD_NOT_REQUIRED, 27 UPLOAD_NOT_REQUIRED,
26 UPLOAD_REQUIRED, 28 UPLOAD_REQUIRED,
27 USE_UPLOAD_RATES 29 USE_UPLOAD_RATES
28 }; 30 };
29 31
30 class AutofillMetrics; 32 class AutofillMetrics;
31 33
32 namespace base { 34 namespace base {
33 class TimeTicks; 35 class TimeTicks;
34 } 36 }
35 37
36 namespace buzz { 38 namespace buzz {
37 class XmlElement; 39 class XmlElement;
38 } 40 }
39 41
40 namespace webkit {
41 namespace forms {
42 struct FormData;
43 struct FormDataPredictions;
44 }
45 }
46
47 // FormStructure stores a single HTML form together with the values entered 42 // FormStructure stores a single HTML form together with the values entered
48 // in the fields along with additional information needed by Autofill. 43 // in the fields along with additional information needed by Autofill.
49 class FormStructure { 44 class FormStructure {
50 public: 45 public:
51 explicit FormStructure(const webkit::forms::FormData& form); 46 explicit FormStructure(const FormData& form);
52 virtual ~FormStructure(); 47 virtual ~FormStructure();
53 48
54 // Runs several heuristics against the form fields to determine their possible 49 // Runs several heuristics against the form fields to determine their possible
55 // types. 50 // types.
56 void DetermineHeuristicTypes(); 51 void DetermineHeuristicTypes();
57 52
58 // Encodes the XML upload request from this FormStructure. 53 // Encodes the XML upload request from this FormStructure.
59 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, 54 bool EncodeUploadRequest(const FieldTypeSet& available_field_types,
60 bool form_was_autofilled, 55 bool form_was_autofilled,
61 std::string* encoded_xml) const; 56 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 67 // 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. 68 // same as the one passed to EncodeQueryRequest when constructing the query.
74 static void ParseQueryResponse(const std::string& response_xml, 69 static void ParseQueryResponse(const std::string& response_xml,
75 const std::vector<FormStructure*>& forms, 70 const std::vector<FormStructure*>& forms,
76 const AutofillMetrics& metric_logger); 71 const AutofillMetrics& metric_logger);
77 72
78 // Fills |forms| with the details from the given |form_structures| and their 73 // Fills |forms| with the details from the given |form_structures| and their
79 // fields' predicted types. 74 // fields' predicted types.
80 static void GetFieldTypePredictions( 75 static void GetFieldTypePredictions(
81 const std::vector<FormStructure*>& form_structures, 76 const std::vector<FormStructure*>& form_structures,
82 std::vector<webkit::forms::FormDataPredictions>* forms); 77 std::vector<FormDataPredictions>* forms);
83 78
84 // The unique signature for this form, composed of the target url domain, 79 // 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. 80 // the form name, and the form field names in a 64-bit hash.
86 std::string FormSignature() const; 81 std::string FormSignature() const;
87 82
88 // Runs a quick heuristic to rule out forms that are obviously not 83 // 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 84 // 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. 85 // form's method be POST is only applied if |require_method_post| is true.
91 bool IsAutofillable(bool require_method_post) const; 86 bool IsAutofillable(bool require_method_post) const;
92 87
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 std::vector<AutofillField*>::const_iterator end() const { 128 std::vector<AutofillField*>::const_iterator end() const {
134 return fields_.end(); 129 return fields_.end();
135 } 130 }
136 131
137 const GURL& source_url() const { return source_url_; } 132 const GURL& source_url() const { return source_url_; }
138 133
139 UploadRequired upload_required() const { return upload_required_; } 134 UploadRequired upload_required() const { return upload_required_; }
140 135
141 virtual std::string server_experiment_id() const; 136 virtual std::string server_experiment_id() const;
142 137
143 bool operator==(const webkit::forms::FormData& form) const; 138 bool operator==(const FormData& form) const;
144 bool operator!=(const webkit::forms::FormData& form) const; 139 bool operator!=(const FormData& form) const;
145 140
146 private: 141 private:
147 friend class FormStructureTest; 142 friend class FormStructureTest;
148 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 143 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
149 // 64-bit hash of the string - used in FormSignature and unit-tests. 144 // 64-bit hash of the string - used in FormSignature and unit-tests.
150 static std::string Hash64Bit(const std::string& str); 145 static std::string Hash64Bit(const std::string& str);
151 146
152 enum EncodeRequestType { 147 enum EncodeRequestType {
153 QUERY, 148 QUERY,
154 UPLOAD, 149 UPLOAD,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RequestMethod method_; 203 RequestMethod method_;
209 204
210 // Whether the form includes any field types explicitly specified by the site 205 // Whether the form includes any field types explicitly specified by the site
211 // author, via the |autocompletetype| attribute. 206 // author, via the |autocompletetype| attribute.
212 bool has_author_specified_types_; 207 bool has_author_specified_types_;
213 208
214 DISALLOW_COPY_AND_ASSIGN(FormStructure); 209 DISALLOW_COPY_AND_ASSIGN(FormStructure);
215 }; 210 };
216 211
217 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ 212 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/credit_card_field_unittest.cc ('k') | chrome/browser/autofill/form_structure.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698