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

Side by Side Diff: components/autofill/core/browser/form_structure.h

Issue 2318533002: [Password Generation] Use signatures for form matching (Closed)
Patch Set: Rebase Created 4 years, 3 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 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 rappor::RapporService* rappor_service); 84 rappor::RapporService* rappor_service);
85 85
86 // Returns predictions using the details from the given |form_structures| and 86 // Returns predictions using the details from the given |form_structures| and
87 // their fields' predicted types. 87 // their fields' predicted types.
88 static std::vector<FormDataPredictions> GetFieldTypePredictions( 88 static std::vector<FormDataPredictions> GetFieldTypePredictions(
89 const std::vector<FormStructure*>& form_structures); 89 const std::vector<FormStructure*>& form_structures);
90 90
91 // Returns whether sending autofill field metadata to the server is enabled. 91 // Returns whether sending autofill field metadata to the server is enabled.
92 static bool IsAutofillFieldMetadataEnabled(); 92 static bool IsAutofillFieldMetadataEnabled();
93 93
94 // The unique signature for this form, composed of the target url domain, 94 // Return the form signature as string.
95 // the form name, and the form field names in a 64-bit hash. 95 std::string FormSignatureAsStr() const;
96 std::string FormSignature() const;
97 96
98 // Runs a quick heuristic to rule out forms that are obviously not 97 // Runs a quick heuristic to rule out forms that are obviously not
99 // auto-fillable, like google/yahoo/msn search, etc. 98 // auto-fillable, like google/yahoo/msn search, etc.
100 bool IsAutofillable() const; 99 bool IsAutofillable() const;
101 100
102 // Returns whether |this| form represents a complete Credit Card form, which 101 // Returns whether |this| form represents a complete Credit Card form, which
103 // consists in having at least a credit card number field and an expiration 102 // consists in having at least a credit card number field and an expiration
104 // field. 103 // field.
105 bool IsCompleteCreditCardForm() const; 104 bool IsCompleteCreditCardForm() const;
106 105
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return has_author_specified_sections_; 213 return has_author_specified_sections_;
215 } 214 }
216 215
217 void set_upload_required(UploadRequired required) { 216 void set_upload_required(UploadRequired required) {
218 upload_required_ = required; 217 upload_required_ = required;
219 } 218 }
220 UploadRequired upload_required() const { return upload_required_; } 219 UploadRequired upload_required() const { return upload_required_; }
221 220
222 bool all_fields_are_passwords() const { return all_fields_are_passwords_; } 221 bool all_fields_are_passwords() const { return all_fields_are_passwords_; }
223 222
223 FormSignature form_signature() const { return form_signature_; }
224
224 // Returns a FormData containing the data this form structure knows about. 225 // Returns a FormData containing the data this form structure knows about.
225 FormData ToFormData() const; 226 FormData ToFormData() const;
226 227
227 bool operator==(const FormData& form) const; 228 bool operator==(const FormData& form) const;
228 bool operator!=(const FormData& form) const; 229 bool operator!=(const FormData& form) const;
229 230
230 private: 231 private:
231 friend class AutofillMergeTest; 232 friend class AutofillMergeTest;
232 friend class FormStructureTest; 233 friend class FormStructureTest;
233 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 234 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
234 FRIEND_TEST_ALL_PREFIXES(FormStructureTest, FindLongestCommonPrefix); 235 FRIEND_TEST_ALL_PREFIXES(FormStructureTest, FindLongestCommonPrefix);
235 236
236 // Encodes information about this form and its fields into |query_form|. 237 // Encodes information about this form and its fields into |query_form|.
237 void EncodeFormForQuery( 238 void EncodeFormForQuery(
238 autofill::AutofillQueryContents::Form* query_form) const; 239 autofill::AutofillQueryContents::Form* query_form) const;
239 240
240 // Encodes information about this form and its fields into |upload|. 241 // Encodes information about this form and its fields into |upload|.
241 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const; 242 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const;
242 243
243 // 64-bit hash of the string - used in FormSignature and unit-tests.
244 static uint64_t Hash64Bit(const std::string& str);
245
246 uint64_t FormSignature64Bit() const;
247
248 // Returns true if the form has no fields, or too many. 244 // Returns true if the form has no fields, or too many.
249 bool IsMalformed() const; 245 bool IsMalformed() const;
250 246
251 // Classifies each field in |fields_| into a logical section. 247 // Classifies each field in |fields_| into a logical section.
252 // Sections are identified by the heuristic that a logical section should not 248 // Sections are identified by the heuristic that a logical section should not
253 // include multiple fields of the same autofill type (with some exceptions, as 249 // include multiple fields of the same autofill type (with some exceptions, as
254 // described in the implementation). Sections are furthermore distinguished 250 // described in the implementation). Sections are furthermore distinguished
255 // as either credit card or non-credit card sections. 251 // as either credit card or non-credit card sections.
256 // If |has_author_specified_sections| is true, only the second pass -- 252 // If |has_author_specified_sections| is true, only the second pass --
257 // distinguishing credit card sections from non-credit card ones -- is made. 253 // distinguishing credit card sections from non-credit card ones -- is made.
(...skipping 25 matching lines...) Expand all
283 // The number of fields able to be auto-filled. 279 // The number of fields able to be auto-filled.
284 size_t autofill_count_; 280 size_t autofill_count_;
285 281
286 // A vector of all the input fields in the form. 282 // A vector of all the input fields in the form.
287 ScopedVector<AutofillField> fields_; 283 ScopedVector<AutofillField> fields_;
288 284
289 // The number of fields that are part of the form signature and that are 285 // The number of fields that are part of the form signature and that are
290 // included in queries to the Autofill server. 286 // included in queries to the Autofill server.
291 size_t active_field_count_; 287 size_t active_field_count_;
292 288
293 // The names of the form input elements, that are part of the form signature.
294 // The string starts with "&" and the names are also separated by the "&"
295 // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name"
296 std::string form_signature_field_names_;
297
298 // Whether the server expects us to always upload, never upload, or default 289 // Whether the server expects us to always upload, never upload, or default
299 // to the stored upload rates. 290 // to the stored upload rates.
300 UploadRequired upload_required_; 291 UploadRequired upload_required_;
301 292
302 // Whether the form includes any field types explicitly specified by the site 293 // Whether the form includes any field types explicitly specified by the site
303 // author, via the |autocompletetype| attribute. 294 // author, via the |autocompletetype| attribute.
304 bool has_author_specified_types_; 295 bool has_author_specified_types_;
305 296
306 // Whether the form includes any sections explicitly specified by the site 297 // Whether the form includes any sections explicitly specified by the site
307 // author, via the autocomplete attribute. 298 // author, via the autocomplete attribute.
308 bool has_author_specified_sections_; 299 bool has_author_specified_sections_;
309 300
310 // Whether the form was parsed for autocomplete attribute, thus assigning 301 // Whether the form was parsed for autocomplete attribute, thus assigning
311 // the real values of |has_author_specified_types_| and 302 // the real values of |has_author_specified_types_| and
312 // |has_author_specified_sections_|. 303 // |has_author_specified_sections_|.
313 bool was_parsed_for_autocomplete_attributes_; 304 bool was_parsed_for_autocomplete_attributes_;
314 305
315 // True if the form contains at least one password field. 306 // True if the form contains at least one password field.
316 bool has_password_field_; 307 bool has_password_field_;
317 308
318 // True if the form is a <form>. 309 // True if the form is a <form>.
319 bool is_form_tag_; 310 bool is_form_tag_;
320 311
321 // True if the form is made of unowned fields in a non checkout flow. 312 // True if the form is made of unowned fields in a non checkout flow.
322 bool is_formless_checkout_; 313 bool is_formless_checkout_;
323 314
324 // True if all form fields are password fields. 315 // True if all form fields are password fields.
325 bool all_fields_are_passwords_; 316 bool all_fields_are_passwords_;
326 317
318 // The unique signature for this form, composed of the target url domain,
319 // the form name, and the form field names in a 64-bit hash.
320 FormSignature form_signature_;
321
327 DISALLOW_COPY_AND_ASSIGN(FormStructure); 322 DISALLOW_COPY_AND_ASSIGN(FormStructure);
328 }; 323 };
329 324
330 } // namespace autofill 325 } // namespace autofill
331 326
332 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ 327 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_field.cc ('k') | components/autofill/core/browser/form_structure.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698