OLD | NEW |
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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 bool FormStructure::ShouldBeCrowdsourced() const { | 621 bool FormStructure::ShouldBeCrowdsourced() const { |
622 return (has_password_field_ || | 622 return (has_password_field_ || |
623 active_field_count() >= kRequiredFieldsForPredictionRoutines) && | 623 active_field_count() >= kRequiredFieldsForPredictionRoutines) && |
624 ShouldBeParsed(); | 624 ShouldBeParsed(); |
625 } | 625 } |
626 | 626 |
627 void FormStructure::UpdateFromCache(const FormStructure& cached_form) { | 627 void FormStructure::UpdateFromCache(const FormStructure& cached_form) { |
628 // Map from field signatures to cached fields. | 628 // Map from field signatures to cached fields. |
629 std::map<std::string, const AutofillField*> cached_fields; | 629 std::map<std::string, const AutofillField*> cached_fields; |
630 for (size_t i = 0; i < cached_form.field_count(); ++i) { | 630 for (size_t i = 0; i < cached_form.field_count(); ++i) { |
631 const auto& field = cached_form.field(i); | 631 auto* const field = cached_form.field(i); |
632 cached_fields[field->FieldSignatureAsStr()] = field; | 632 cached_fields[field->FieldSignatureAsStr()] = field; |
633 } | 633 } |
634 | 634 |
635 for (auto& field : *this) { | 635 for (auto& field : *this) { |
636 std::map<std::string, const AutofillField*>::const_iterator cached_field = | 636 std::map<std::string, const AutofillField*>::const_iterator cached_field = |
637 cached_fields.find(field->FieldSignatureAsStr()); | 637 cached_fields.find(field->FieldSignatureAsStr()); |
638 if (cached_field != cached_fields.end()) { | 638 if (cached_field != cached_fields.end()) { |
639 if (field->form_control_type != "select-one" && | 639 if (field->form_control_type != "select-one" && |
640 field->value == cached_field->second->value) { | 640 field->value == cached_field->second->value) { |
641 // From the perspective of learning user data, text fields containing | 641 // From the perspective of learning user data, text fields containing |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 rappor::RapporServiceImpl* rappor_service, | 674 rappor::RapporServiceImpl* rappor_service, |
675 bool did_show_suggestions, | 675 bool did_show_suggestions, |
676 bool observed_submission) const { | 676 bool observed_submission) const { |
677 size_t num_detected_field_types = 0; | 677 size_t num_detected_field_types = 0; |
678 size_t num_server_mismatches = 0; | 678 size_t num_server_mismatches = 0; |
679 size_t num_heuristic_mismatches = 0; | 679 size_t num_heuristic_mismatches = 0; |
680 size_t num_edited_autofilled_fields = 0; | 680 size_t num_edited_autofilled_fields = 0; |
681 bool did_autofill_all_possible_fields = true; | 681 bool did_autofill_all_possible_fields = true; |
682 bool did_autofill_some_possible_fields = false; | 682 bool did_autofill_some_possible_fields = false; |
683 for (size_t i = 0; i < field_count(); ++i) { | 683 for (size_t i = 0; i < field_count(); ++i) { |
684 const auto& field = this->field(i); | 684 auto* const field = this->field(i); |
685 | 685 |
686 // No further logging for password fields. Those are primarily related to a | 686 // No further logging for password fields. Those are primarily related to a |
687 // different feature code path, and so make more sense to track outside of | 687 // different feature code path, and so make more sense to track outside of |
688 // this metric. | 688 // this metric. |
689 if (field->form_control_type == "password") | 689 if (field->form_control_type == "password") |
690 continue; | 690 continue; |
691 | 691 |
692 // We count fields that were autofilled but later modified, regardless of | 692 // We count fields that were autofilled but later modified, regardless of |
693 // whether the data now in the field is recognized. | 693 // whether the data now in the field is recognized. |
694 if (field->previously_autofilled()) | 694 if (field->previously_autofilled()) |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 filtered_strings[0].at(prefix_len)) { | 1320 filtered_strings[0].at(prefix_len)) { |
1321 // Mismatch found. | 1321 // Mismatch found. |
1322 return filtered_strings[i].substr(0, prefix_len); | 1322 return filtered_strings[i].substr(0, prefix_len); |
1323 } | 1323 } |
1324 } | 1324 } |
1325 } | 1325 } |
1326 return filtered_strings[0]; | 1326 return filtered_strings[0]; |
1327 } | 1327 } |
1328 | 1328 |
1329 } // namespace autofill | 1329 } // namespace autofill |
OLD | NEW |