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

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

Issue 1622073002: [Autofill] Remove longest common prefix from field names when running heuristics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 11 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 // Returns a FormData containing the data this form structure knows about. 209 // Returns a FormData containing the data this form structure knows about.
210 FormData ToFormData() const; 210 FormData ToFormData() const;
211 211
212 bool operator==(const FormData& form) const; 212 bool operator==(const FormData& form) const;
213 bool operator!=(const FormData& form) const; 213 bool operator!=(const FormData& form) const;
214 214
215 private: 215 private:
216 friend class FormStructureTest; 216 friend class FormStructureTest;
217 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 217 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
218 FRIEND_TEST_ALL_PREFIXES(FormStructureTest, FindLongestCommonPrefix);
218 219
219 // Encodes information about this form and its fields into |query_form|. 220 // Encodes information about this form and its fields into |query_form|.
220 void EncodeFormForQuery( 221 void EncodeFormForQuery(
221 autofill::AutofillQueryContents::Form* query_form) const; 222 autofill::AutofillQueryContents::Form* query_form) const;
222 223
223 // Encodes information about this form and its fields into |upload|. 224 // Encodes information about this form and its fields into |upload|.
224 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const; 225 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const;
225 226
226 // 64-bit hash of the string - used in FormSignature and unit-tests. 227 // 64-bit hash of the string - used in FormSignature and unit-tests.
227 static uint64_t Hash64Bit(const std::string& str); 228 static uint64_t Hash64Bit(const std::string& str);
228 229
229 uint64_t FormSignature64Bit() const; 230 uint64_t FormSignature64Bit() const;
230 231
231 // Returns true if the form has no fields, or too many. 232 // Returns true if the form has no fields, or too many.
232 bool IsMalformed() const; 233 bool IsMalformed() const;
233 234
234 // Classifies each field in |fields_| into a logical section. 235 // Classifies each field in |fields_| into a logical section.
235 // Sections are identified by the heuristic that a logical section should not 236 // Sections are identified by the heuristic that a logical section should not
236 // include multiple fields of the same autofill type (with some exceptions, as 237 // include multiple fields of the same autofill type (with some exceptions, as
237 // described in the implementation). Sections are furthermore distinguished 238 // described in the implementation). Sections are furthermore distinguished
238 // as either credit card or non-credit card sections. 239 // as either credit card or non-credit card sections.
239 // If |has_author_specified_sections| is true, only the second pass -- 240 // If |has_author_specified_sections| is true, only the second pass --
240 // distinguishing credit card sections from non-credit card ones -- is made. 241 // distinguishing credit card sections from non-credit card ones -- is made.
241 void IdentifySections(bool has_author_specified_sections); 242 void IdentifySections(bool has_author_specified_sections);
242 243
243 // Returns true if field should be skipped when talking to Autofill server. 244 // Returns true if field should be skipped when talking to Autofill server.
244 bool ShouldSkipField(const FormFieldData& field) const; 245 bool ShouldSkipField(const FormFieldData& field) const;
245 246
247 // Further processes the extracted |fields_|.
248 void ProcessExtractedFields();
249
250 // Returns the longest common prefix found within |strings|.
251 static base::string16 FindLongestCommonPrefix(
vabr (Chromium) 2016/01/25 10:10:26 optional: This could return a StringPiece, saving
Mathieu 2016/01/25 15:52:53 Done.
252 const std::vector<base::string16>& strings);
253
246 // The name of the form. 254 // The name of the form.
247 base::string16 form_name_; 255 base::string16 form_name_;
248 256
249 // The source URL. 257 // The source URL.
250 GURL source_url_; 258 GURL source_url_;
251 259
252 // The target URL. 260 // The target URL.
253 GURL target_url_; 261 GURL target_url_;
254 262
255 // The number of fields able to be auto-filled. 263 // The number of fields able to be auto-filled.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 297
290 // True if the form is a <form>. 298 // True if the form is a <form>.
291 bool is_form_tag_; 299 bool is_form_tag_;
292 300
293 DISALLOW_COPY_AND_ASSIGN(FormStructure); 301 DISALLOW_COPY_AND_ASSIGN(FormStructure);
294 }; 302 };
295 303
296 } // namespace autofill 304 } // namespace autofill
297 305
298 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ 306 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698