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

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

Issue 2796873002: Sending autofill types for username fields in sign-in forms for improving username detection. (Closed)
Patch Set: Fix compilation error Created 3 years, 8 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 #include "components/autofill/core/browser/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 autofill_count_(0), 302 autofill_count_(0),
303 active_field_count_(0), 303 active_field_count_(0),
304 upload_required_(USE_UPLOAD_RATES), 304 upload_required_(USE_UPLOAD_RATES),
305 has_author_specified_types_(false), 305 has_author_specified_types_(false),
306 has_author_specified_sections_(false), 306 has_author_specified_sections_(false),
307 has_author_specified_upi_vpa_hint_(false), 307 has_author_specified_upi_vpa_hint_(false),
308 was_parsed_for_autocomplete_attributes_(false), 308 was_parsed_for_autocomplete_attributes_(false),
309 has_password_field_(false), 309 has_password_field_(false),
310 is_form_tag_(form.is_form_tag), 310 is_form_tag_(form.is_form_tag),
311 is_formless_checkout_(form.is_formless_checkout), 311 is_formless_checkout_(form.is_formless_checkout),
312 all_fields_are_passwords_(true) { 312 all_fields_are_passwords_(true),
313 is_signin_upload_(false) {
313 // Copy the form fields. 314 // Copy the form fields.
314 std::map<base::string16, size_t> unique_names; 315 std::map<base::string16, size_t> unique_names;
315 for (const FormFieldData& field : form.fields) { 316 for (const FormFieldData& field : form.fields) {
316 if (!ShouldSkipField(field)) 317 if (!ShouldSkipField(field))
317 ++active_field_count_; 318 ++active_field_count_;
318 319
319 if (field.form_control_type == "password") 320 if (field.form_control_type == "password")
320 has_password_field_ = true; 321 has_password_field_ = true;
321 else 322 else
322 all_fields_are_passwords_ = false; 323 all_fields_are_passwords_ = false;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 for (const auto& field : *this) { 607 for (const auto& field : *this) {
607 if (field && field->IsFieldFillable()) 608 if (field && field->IsFieldFillable())
608 ++autofill_count_; 609 ++autofill_count_;
609 } 610 }
610 } 611 }
611 612
612 bool FormStructure::ShouldBeParsed() const { 613 bool FormStructure::ShouldBeParsed() const {
613 if (active_field_count() < kRequiredFieldsForPredictionRoutines && 614 if (active_field_count() < kRequiredFieldsForPredictionRoutines &&
614 (!all_fields_are_passwords() || 615 (!all_fields_are_passwords() ||
615 active_field_count() < kRequiredFieldsForFormsWithOnlyPasswordFields) && 616 active_field_count() < kRequiredFieldsForFormsWithOnlyPasswordFields) &&
616 !has_author_specified_types_) { 617 !is_signin_upload_ && !has_author_specified_types_) {
617 return false; 618 return false;
618 } 619 }
619 620
620 // Rule out http(s)://*/search?... 621 // Rule out http(s)://*/search?...
621 // e.g. http://www.google.com/search?q=... 622 // e.g. http://www.google.com/search?q=...
622 // http://search.yahoo.com/search?p=... 623 // http://search.yahoo.com/search?p=...
623 if (target_url_.path_piece() == "/search") 624 if (target_url_.path_piece() == "/search")
624 return false; 625 return false;
625 626
626 bool has_text_field = false; 627 bool has_text_field = false;
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 filtered_strings[0].at(prefix_len)) { 1339 filtered_strings[0].at(prefix_len)) {
1339 // Mismatch found. 1340 // Mismatch found.
1340 return filtered_strings[i].substr(0, prefix_len); 1341 return filtered_strings[i].substr(0, prefix_len);
1341 } 1342 }
1342 } 1343 }
1343 } 1344 }
1344 return filtered_strings[0]; 1345 return filtered_strings[0];
1345 } 1346 }
1346 1347
1347 } // namespace autofill 1348 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698