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

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

Issue 11867025: Download autocheckout whitelist and enable autocheckout for whitelisted sites only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass autocheckout url prefix to FormStructure's constructor. Created 7 years, 10 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 | Annotate | Revision Log
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 27 matching lines...) Expand all
38 } 38 }
39 39
40 namespace buzz { 40 namespace buzz {
41 class XmlElement; 41 class XmlElement;
42 } 42 }
43 43
44 // FormStructure stores a single HTML form together with the values entered 44 // FormStructure stores a single HTML form together with the values entered
45 // in the fields along with additional information needed by Autofill. 45 // in the fields along with additional information needed by Autofill.
46 class FormStructure { 46 class FormStructure {
47 public: 47 public:
48 explicit FormStructure(const FormData& form); 48 FormStructure(const FormData& form, std::string autocheckout_url_prefix);
49 virtual ~FormStructure(); 49 virtual ~FormStructure();
50 50
51 // Runs several heuristics against the form fields to determine their possible 51 // Runs several heuristics against the form fields to determine their possible
52 // types. 52 // types.
53 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger); 53 void DetermineHeuristicTypes(const AutofillMetrics& metric_logger);
54 54
55 // Encodes the XML upload request from this FormStructure. 55 // Encodes the XML upload request from this FormStructure.
56 bool EncodeUploadRequest(const FieldTypeSet& available_field_types, 56 bool EncodeUploadRequest(const FieldTypeSet& available_field_types,
57 bool form_was_autofilled, 57 bool form_was_autofilled,
58 std::string* encoded_xml) const; 58 std::string* encoded_xml) const;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Returns a FormData containing the data this form structure knows about. 165 // Returns a FormData containing the data this form structure knows about.
166 // |user_submitted| is currently always false. 166 // |user_submitted| is currently always false.
167 FormData ToFormData() const; 167 FormData ToFormData() const;
168 168
169 bool operator==(const FormData& form) const; 169 bool operator==(const FormData& form) const;
170 bool operator!=(const FormData& form) const; 170 bool operator!=(const FormData& form) const;
171 171
172 private: 172 private:
173 friend class FormStructureTest; 173 friend class FormStructureTest;
174 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 174 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
175
175 // 64-bit hash of the string - used in FormSignature and unit-tests. 176 // 64-bit hash of the string - used in FormSignature and unit-tests.
176 static std::string Hash64Bit(const std::string& str); 177 static std::string Hash64Bit(const std::string& str);
177 178
178 enum EncodeRequestType { 179 enum EncodeRequestType {
179 QUERY, 180 QUERY,
180 UPLOAD, 181 UPLOAD,
181 }; 182 };
182 183
183 // Adds form info to |encompassing_xml_element|. |request_type| indicates if 184 // Adds form info to |encompassing_xml_element|. |request_type| indicates if
184 // it is a query or upload. 185 // it is a query or upload.
185 bool EncodeFormRequest(EncodeRequestType request_type, 186 bool EncodeFormRequest(EncodeRequestType request_type,
186 buzz::XmlElement* encompassing_xml_element) const; 187 buzz::XmlElement* encompassing_xml_element) const;
187 188
188 // Classifies each field in |fields_| into a logical section. 189 // Classifies each field in |fields_| into a logical section.
189 // Sections are identified by the heuristic that a logical section should not 190 // Sections are identified by the heuristic that a logical section should not
190 // include multiple fields of the same autofill type (with some exceptions, as 191 // include multiple fields of the same autofill type (with some exceptions, as
191 // described in the implementation). Sections are furthermore distinguished 192 // described in the implementation). Sections are furthermore distinguished
192 // as either credit card or non-credit card sections. 193 // as either credit card or non-credit card sections.
193 // If |has_author_specified_sections| is true, only the second pass -- 194 // If |has_author_specified_sections| is true, only the second pass --
194 // distinguishing credit card sections from non-credit card ones -- is made. 195 // distinguishing credit card sections from non-credit card ones -- is made.
195 void IdentifySections(bool has_author_specified_sections); 196 void IdentifySections(bool has_author_specified_sections);
196 197
198 bool IsAutocheckoutEnabled() const;
199
200 // Returns the minimal number of fillable fields required to start autofill.
201 size_t RequiredFillableFields() const;
202
197 // The name of the form. 203 // The name of the form.
198 string16 form_name_; 204 string16 form_name_;
199 205
200 // The source URL. 206 // The source URL.
201 GURL source_url_; 207 GURL source_url_;
202 208
203 // The target URL. 209 // The target URL.
204 GURL target_url_; 210 GURL target_url_;
205 211
206 // The number of fields able to be auto-filled. 212 // The number of fields able to be auto-filled.
(...skipping 29 matching lines...) Expand all
236 // to any autofill flow, it is set to -1. 242 // to any autofill flow, it is set to -1.
237 int total_pages_; 243 int total_pages_;
238 244
239 // Proceed element for multipage Autofill flow. 245 // Proceed element for multipage Autofill flow.
240 scoped_ptr<autofill::WebElementDescriptor> proceed_element_descriptor_; 246 scoped_ptr<autofill::WebElementDescriptor> proceed_element_descriptor_;
241 247
242 // Whether the form includes any field types explicitly specified by the site 248 // Whether the form includes any field types explicitly specified by the site
243 // author, via the |autocompletetype| attribute. 249 // author, via the |autocompletetype| attribute.
244 bool has_author_specified_types_; 250 bool has_author_specified_types_;
245 251
246 // State of the kEnableExperimentalFormFilling flag. 252 // The URL prefix matched in autocheckout whitelist. An empty string implies
247 bool experimental_form_filling_enabled_; 253 // autocheckout is not enabled for this form.
254 std::string autocheckout_url_prefix_;
248 255
249 DISALLOW_COPY_AND_ASSIGN(FormStructure); 256 DISALLOW_COPY_AND_ASSIGN(FormStructure);
250 }; 257 };
251 258
252 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_ 259 #endif // CHROME_BROWSER_AUTOFILL_FORM_STRUCTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698