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

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: std::move 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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/strings/string_piece.h"
20 #include "components/autofill/core/browser/autofill_field.h" 21 #include "components/autofill/core/browser/autofill_field.h"
21 #include "components/autofill/core/browser/autofill_type.h" 22 #include "components/autofill/core/browser/autofill_type.h"
22 #include "components/autofill/core/browser/field_types.h" 23 #include "components/autofill/core/browser/field_types.h"
23 #include "components/autofill/core/browser/proto/server.pb.h" 24 #include "components/autofill/core/browser/proto/server.pb.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 class XmlWriter; 27 class XmlWriter;
27 28
28 enum UploadRequired { 29 enum UploadRequired {
29 UPLOAD_NOT_REQUIRED, 30 UPLOAD_NOT_REQUIRED,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 // Returns a FormData containing the data this form structure knows about. 210 // Returns a FormData containing the data this form structure knows about.
210 FormData ToFormData() const; 211 FormData ToFormData() const;
211 212
212 bool operator==(const FormData& form) const; 213 bool operator==(const FormData& form) const;
213 bool operator!=(const FormData& form) const; 214 bool operator!=(const FormData& form) const;
214 215
215 private: 216 private:
216 friend class FormStructureTest; 217 friend class FormStructureTest;
217 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); 218 FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
219 FRIEND_TEST_ALL_PREFIXES(FormStructureTest, FindLongestCommonPrefix);
218 220
219 // Encodes information about this form and its fields into |query_form|. 221 // Encodes information about this form and its fields into |query_form|.
220 void EncodeFormForQuery( 222 void EncodeFormForQuery(
221 autofill::AutofillQueryContents::Form* query_form) const; 223 autofill::AutofillQueryContents::Form* query_form) const;
222 224
223 // Encodes information about this form and its fields into |upload|. 225 // Encodes information about this form and its fields into |upload|.
224 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const; 226 void EncodeFormForUpload(autofill::AutofillUploadContents* upload) const;
225 227
226 // 64-bit hash of the string - used in FormSignature and unit-tests. 228 // 64-bit hash of the string - used in FormSignature and unit-tests.
227 static uint64_t Hash64Bit(const std::string& str); 229 static uint64_t Hash64Bit(const std::string& str);
228 230
229 uint64_t FormSignature64Bit() const; 231 uint64_t FormSignature64Bit() const;
230 232
231 // Returns true if the form has no fields, or too many. 233 // Returns true if the form has no fields, or too many.
232 bool IsMalformed() const; 234 bool IsMalformed() const;
233 235
234 // Classifies each field in |fields_| into a logical section. 236 // Classifies each field in |fields_| into a logical section.
235 // Sections are identified by the heuristic that a logical section should not 237 // 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 238 // include multiple fields of the same autofill type (with some exceptions, as
237 // described in the implementation). Sections are furthermore distinguished 239 // described in the implementation). Sections are furthermore distinguished
238 // as either credit card or non-credit card sections. 240 // as either credit card or non-credit card sections.
239 // If |has_author_specified_sections| is true, only the second pass -- 241 // If |has_author_specified_sections| is true, only the second pass --
240 // distinguishing credit card sections from non-credit card ones -- is made. 242 // distinguishing credit card sections from non-credit card ones -- is made.
241 void IdentifySections(bool has_author_specified_sections); 243 void IdentifySections(bool has_author_specified_sections);
242 244
243 // Returns true if field should be skipped when talking to Autofill server. 245 // Returns true if field should be skipped when talking to Autofill server.
244 bool ShouldSkipField(const FormFieldData& field) const; 246 bool ShouldSkipField(const FormFieldData& field) const;
245 247
248 // Further processes the extracted |fields_|.
249 void ProcessExtractedFields();
250
251 // Returns the longest common prefix found within |strings|. IMPORTANT: the
252 // returned StringPiece16 is a view into |strings| and the latter must remain
253 // valid while the StringPiece16 is used.
254 static base::StringPiece16 FindLongestCommonPrefix(
255 const std::vector<base::string16>& strings);
256
246 // The name of the form. 257 // The name of the form.
247 base::string16 form_name_; 258 base::string16 form_name_;
248 259
249 // The source URL. 260 // The source URL.
250 GURL source_url_; 261 GURL source_url_;
251 262
252 // The target URL. 263 // The target URL.
253 GURL target_url_; 264 GURL target_url_;
254 265
255 // The number of fields able to be auto-filled. 266 // The number of fields able to be auto-filled.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 300
290 // True if the form is a <form>. 301 // True if the form is a <form>.
291 bool is_form_tag_; 302 bool is_form_tag_;
292 303
293 DISALLOW_COPY_AND_ASSIGN(FormStructure); 304 DISALLOW_COPY_AND_ASSIGN(FormStructure);
294 }; 305 };
295 306
296 } // namespace autofill 307 } // namespace autofill
297 308
298 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ 309 #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