| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 } | 689 } |
| 690 | 690 |
| 691 void FormStructure::LogQualityMetrics( | 691 void FormStructure::LogQualityMetrics( |
| 692 const base::TimeTicks& load_time, | 692 const base::TimeTicks& load_time, |
| 693 const base::TimeTicks& interaction_time, | 693 const base::TimeTicks& interaction_time, |
| 694 const base::TimeTicks& submission_time, | 694 const base::TimeTicks& submission_time, |
| 695 rappor::RapporServiceImpl* rappor_service, | 695 rappor::RapporServiceImpl* rappor_service, |
| 696 AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger, | 696 AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger, |
| 697 bool did_show_suggestions, | 697 bool did_show_suggestions, |
| 698 bool observed_submission) const { | 698 bool observed_submission) const { |
| 699 // Use the same timestamp on UKM Metrics generated within this method's scope. |
| 700 AutofillMetrics::UkmTimestampPin timestamp_pin(form_interactions_ukm_logger); |
| 701 |
| 699 size_t num_detected_field_types = 0; | 702 size_t num_detected_field_types = 0; |
| 700 size_t num_edited_autofilled_fields = 0; | 703 size_t num_edited_autofilled_fields = 0; |
| 701 bool did_autofill_all_possible_fields = true; | 704 bool did_autofill_all_possible_fields = true; |
| 702 bool did_autofill_some_possible_fields = false; | 705 bool did_autofill_some_possible_fields = false; |
| 703 | 706 |
| 704 // Determine the correct suffix for the metric, depending on whether or | 707 // Determine the correct suffix for the metric, depending on whether or |
| 705 // not a submission was observed. | 708 // not a submission was observed. |
| 706 const AutofillMetrics::QualityMetricType metric_type = | 709 const AutofillMetrics::QualityMetricType metric_type = |
| 707 observed_submission ? AutofillMetrics::TYPE_SUBMISSION | 710 observed_submission ? AutofillMetrics::TYPE_SUBMISSION |
| 708 : AutofillMetrics::TYPE_NO_SUBMISSION; | 711 : AutofillMetrics::TYPE_NO_SUBMISSION; |
| 709 | 712 |
| 710 for (size_t i = 0; i < field_count(); ++i) { | 713 for (size_t i = 0; i < field_count(); ++i) { |
| 711 auto* const field = this->field(i); | 714 auto* const field = this->field(i); |
| 712 | 715 |
| 713 // No further logging for password fields. Those are primarily related to a | |
| 714 // different feature code path, and so make more sense to track outside of | |
| 715 // this metric. | |
| 716 if (field->form_control_type == "password") | |
| 717 continue; | |
| 718 | |
| 719 if (IsUPIVirtualPaymentAddress(field->value)) { | 716 if (IsUPIVirtualPaymentAddress(field->value)) { |
| 720 AutofillMetrics::LogUserHappinessMetric( | 717 AutofillMetrics::LogUserHappinessMetric( |
| 721 AutofillMetrics::USER_DID_ENTER_UPI_VPA); | 718 AutofillMetrics::USER_DID_ENTER_UPI_VPA); |
| 722 } | 719 } |
| 720 |
| 721 form_interactions_ukm_logger->LogFieldFillStatus(*this, *field, |
| 722 metric_type); |
| 723 |
| 724 AutofillMetrics::LogHeuristicPredictionQualityMetrics( |
| 725 form_interactions_ukm_logger, *this, *field, metric_type); |
| 726 AutofillMetrics::LogServerPredictionQualityMetrics( |
| 727 form_interactions_ukm_logger, *this, *field, metric_type); |
| 728 AutofillMetrics::LogOverallPredictionQualityMetrics( |
| 729 form_interactions_ukm_logger, *this, *field, metric_type); |
| 723 // We count fields that were autofilled but later modified, regardless of | 730 // We count fields that were autofilled but later modified, regardless of |
| 724 // whether the data now in the field is recognized. | 731 // whether the data now in the field is recognized. |
| 725 if (field->previously_autofilled()) | 732 if (field->previously_autofilled()) |
| 726 num_edited_autofilled_fields++; | 733 num_edited_autofilled_fields++; |
| 727 | 734 |
| 728 // Aliases for the field types predicted by heuristics, server and overall. | |
| 729 ServerFieldType heuristic_type = | |
| 730 AutofillType(field->heuristic_type()).GetStorableType(); | |
| 731 ServerFieldType server_type = | |
| 732 AutofillType(field->server_type()).GetStorableType(); | |
| 733 ServerFieldType predicted_type = field->Type().GetStorableType(); | |
| 734 | |
| 735 const ServerFieldTypeSet& field_types = field->possible_types(); | 735 const ServerFieldTypeSet& field_types = field->possible_types(); |
| 736 DCHECK(!field_types.empty()); | 736 DCHECK(!field_types.empty()); |
| 737 | 737 if (field_types.count(EMPTY_TYPE) || field_types.count(UNKNOWN_TYPE)) { |
| 738 AutofillMetrics::LogHeuristicPredictionQualityMetrics( | 738 DCHECK_EQ(field_types.size(), 1u); |
| 739 field_types, heuristic_type, metric_type); | |
| 740 AutofillMetrics::LogServerPredictionQualityMetrics(field_types, server_type, | |
| 741 metric_type); | |
| 742 AutofillMetrics::LogOverallPredictionQualityMetrics( | |
| 743 field_types, predicted_type, metric_type); | |
| 744 | |
| 745 if (field_types.count(EMPTY_TYPE) || field_types.count(UNKNOWN_TYPE)) | |
| 746 continue; | 739 continue; |
| 740 } |
| 747 | 741 |
| 748 ++num_detected_field_types; | 742 ++num_detected_field_types; |
| 749 if (field->is_autofilled) | 743 if (field->is_autofilled) |
| 750 did_autofill_some_possible_fields = true; | 744 did_autofill_some_possible_fields = true; |
| 751 else | 745 else |
| 752 did_autofill_all_possible_fields = false; | 746 did_autofill_all_possible_fields = false; |
| 753 } | 747 } |
| 754 | 748 |
| 755 AutofillMetrics::LogNumberOfEditedAutofilledFields( | 749 AutofillMetrics::LogNumberOfEditedAutofilledFields( |
| 756 num_edited_autofilled_fields, observed_submission); | 750 num_edited_autofilled_fields, observed_submission); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 800 } |
| 807 } | 801 } |
| 808 } | 802 } |
| 809 if (form_interactions_ukm_logger->url() != source_url()) | 803 if (form_interactions_ukm_logger->url() != source_url()) |
| 810 form_interactions_ukm_logger->UpdateSourceURL(source_url()); | 804 form_interactions_ukm_logger->UpdateSourceURL(source_url()); |
| 811 AutofillMetrics::LogAutofillFormSubmittedState( | 805 AutofillMetrics::LogAutofillFormSubmittedState( |
| 812 state, form_interactions_ukm_logger); | 806 state, form_interactions_ukm_logger); |
| 813 } | 807 } |
| 814 } | 808 } |
| 815 | 809 |
| 816 void FormStructure::LogQualityMetricsBasedOnAutocomplete() const { | 810 void FormStructure::LogQualityMetricsBasedOnAutocomplete( |
| 811 AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger) |
| 812 const { |
| 817 const AutofillMetrics::QualityMetricType metric_type = | 813 const AutofillMetrics::QualityMetricType metric_type = |
| 818 AutofillMetrics::TYPE_AUTOCOMPLETE_BASED; | 814 AutofillMetrics::TYPE_AUTOCOMPLETE_BASED; |
| 819 for (const auto& field : fields_) { | 815 for (const auto& field : fields_) { |
| 820 if (field->html_type() != HTML_TYPE_UNSPECIFIED && | 816 if (field->html_type() != HTML_TYPE_UNSPECIFIED && |
| 821 field->html_type() != HTML_TYPE_UNRECOGNIZED) { | 817 field->html_type() != HTML_TYPE_UNRECOGNIZED) { |
| 822 // The type inferred by the autocomplete attribute. | |
| 823 ServerFieldTypeSet actual_field_type_set{ | |
| 824 AutofillType(field->html_type(), field->html_mode()) | |
| 825 .GetStorableType()}; | |
| 826 | |
| 827 AutofillMetrics::LogHeuristicPredictionQualityMetrics( | 818 AutofillMetrics::LogHeuristicPredictionQualityMetrics( |
| 828 actual_field_type_set, field->heuristic_type(), metric_type); | 819 form_interactions_ukm_logger, *this, *field, metric_type); |
| 829 AutofillMetrics::LogServerPredictionQualityMetrics( | 820 AutofillMetrics::LogServerPredictionQualityMetrics( |
| 830 actual_field_type_set, field->server_type(), metric_type); | 821 form_interactions_ukm_logger, *this, *field, metric_type); |
| 831 } | 822 } |
| 832 } | 823 } |
| 833 } | 824 } |
| 834 | 825 |
| 835 void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { | 826 void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { |
| 836 const std::string kDefaultSection = "-default"; | 827 const std::string kDefaultSection = "-default"; |
| 837 | 828 |
| 838 has_author_specified_types_ = false; | 829 has_author_specified_types_ = false; |
| 839 has_author_specified_sections_ = false; | 830 has_author_specified_sections_ = false; |
| 840 has_author_specified_upi_vpa_hint_ = false; | 831 has_author_specified_upi_vpa_hint_ = false; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 filtered_strings[0].at(prefix_len)) { | 1269 filtered_strings[0].at(prefix_len)) { |
| 1279 // Mismatch found. | 1270 // Mismatch found. |
| 1280 return filtered_strings[i].substr(0, prefix_len); | 1271 return filtered_strings[i].substr(0, prefix_len); |
| 1281 } | 1272 } |
| 1282 } | 1273 } |
| 1283 } | 1274 } |
| 1284 return filtered_strings[0]; | 1275 return filtered_strings[0]; |
| 1285 } | 1276 } |
| 1286 | 1277 |
| 1287 } // namespace autofill | 1278 } // namespace autofill |
| OLD | NEW |