Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/autofill/form_structure.h" | 5 #include "chrome/browser/autofill/form_structure.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/sha1.h" | 11 #include "base/sha1.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/time.h" | |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/autofill/autofill_metrics.h" | 17 #include "chrome/browser/autofill/autofill_metrics.h" |
| 17 #include "chrome/browser/autofill/autofill_type.h" | 18 #include "chrome/browser/autofill/autofill_type.h" |
| 18 #include "chrome/browser/autofill/autofill_xml_parser.h" | 19 #include "chrome/browser/autofill/autofill_xml_parser.h" |
| 19 #include "chrome/browser/autofill/field_types.h" | 20 #include "chrome/browser/autofill/field_types.h" |
| 20 #include "chrome/browser/autofill/form_field.h" | 21 #include "chrome/browser/autofill/form_field.h" |
| 21 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 22 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 22 #include "webkit/glue/form_data.h" | 23 #include "webkit/glue/form_data.h" |
| 23 #include "webkit/glue/form_data_predictions.h" | 24 #include "webkit/glue/form_data_predictions.h" |
| 24 #include "webkit/glue/form_field.h" | 25 #include "webkit/glue/form_field.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 // rearranged via JavaScript between page load and form submission, so we | 640 // rearranged via JavaScript between page load and form submission, so we |
| 640 // copy over the |form_signature_field_names_| corresponding to the query | 641 // copy over the |form_signature_field_names_| corresponding to the query |
| 641 // request. | 642 // request. |
| 642 DCHECK_EQ(cached_form.form_name_, form_name_); | 643 DCHECK_EQ(cached_form.form_name_, form_name_); |
| 643 DCHECK_EQ(cached_form.source_url_, source_url_); | 644 DCHECK_EQ(cached_form.source_url_, source_url_); |
| 644 DCHECK_EQ(cached_form.target_url_, target_url_); | 645 DCHECK_EQ(cached_form.target_url_, target_url_); |
| 645 form_signature_field_names_ = cached_form.form_signature_field_names_; | 646 form_signature_field_names_ = cached_form.form_signature_field_names_; |
| 646 } | 647 } |
| 647 | 648 |
| 648 void FormStructure::LogQualityMetrics( | 649 void FormStructure::LogQualityMetrics( |
| 649 const AutofillMetrics& metric_logger) const { | 650 const AutofillMetrics& metric_logger, |
| 651 const base::TimeTicks& interaction_time, | |
| 652 const base::TimeTicks& submission_time) const { | |
| 650 std::string experiment_id = server_experiment_id(); | 653 std::string experiment_id = server_experiment_id(); |
| 651 metric_logger.LogServerExperimentIdForUpload(experiment_id); | 654 metric_logger.LogServerExperimentIdForUpload(experiment_id); |
| 652 | 655 |
| 653 size_t num_detected_field_types = 0; | 656 size_t num_detected_field_types = 0; |
| 654 bool did_autofill_all_possible_fields = true; | 657 bool did_autofill_all_possible_fields = true; |
| 655 bool did_autofill_some_possible_fields = false; | 658 bool did_autofill_some_possible_fields = false; |
| 656 for (size_t i = 0; i < field_count(); ++i) { | 659 for (size_t i = 0; i < field_count(); ++i) { |
| 657 const AutofillField* field = this->field(i); | 660 const AutofillField* field = this->field(i); |
| 658 metric_logger.LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED, | 661 metric_logger.LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED, |
| 659 experiment_id); | 662 experiment_id); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 metric_logger.LogQualityMetric( | 774 metric_logger.LogQualityMetric( |
| 772 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH, | 775 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH, |
| 773 experiment_id); | 776 experiment_id); |
| 774 } | 777 } |
| 775 } | 778 } |
| 776 } | 779 } |
| 777 | 780 |
| 778 if (num_detected_field_types < kRequiredFillableFields) { | 781 if (num_detected_field_types < kRequiredFillableFields) { |
| 779 metric_logger.LogUserHappinessMetric( | 782 metric_logger.LogUserHappinessMetric( |
| 780 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM); | 783 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM); |
| 781 } else if (did_autofill_all_possible_fields) { | |
| 782 metric_logger.LogUserHappinessMetric( | |
| 783 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL); | |
| 784 } else if (did_autofill_some_possible_fields) { | |
| 785 metric_logger.LogUserHappinessMetric( | |
| 786 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME); | |
| 787 } else { | 784 } else { |
| 788 metric_logger.LogUserHappinessMetric( | 785 if (did_autofill_all_possible_fields) { |
| 789 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE); | 786 metric_logger.LogUserHappinessMetric( |
| 787 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL); | |
| 788 } else if (did_autofill_some_possible_fields) { | |
| 789 metric_logger.LogUserHappinessMetric( | |
| 790 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME); | |
| 791 } else { | |
| 792 metric_logger.LogUserHappinessMetric( | |
| 793 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE); | |
| 794 } | |
| 795 | |
| 796 // Only log timing metrics if both timestamps are set and seem plausible. | |
| 797 if (!interaction_time.is_null() && !submission_time.is_null() && | |
|
dhollowa
2011/08/31 22:40:52
Could you explain why this is needed. It seems li
Ilya Sherman
2011/08/31 23:21:32
Done.
dhollowa
2011/08/31 23:42:20
Sorry, my thinking was to let the bad data propaga
| |
| 798 submission_time > interaction_time) { | |
| 799 base::TimeDelta time_delta = submission_time - interaction_time; | |
| 800 if (did_autofill_some_possible_fields) | |
| 801 metric_logger.LogAutofilledFormSubmittedAfterDuration(time_delta); | |
| 802 else | |
| 803 metric_logger.LogNonAutofilledFormSubmittedAfterDuration(time_delta); | |
| 804 } | |
| 790 } | 805 } |
| 791 } | 806 } |
| 792 | 807 |
| 793 const AutofillField* FormStructure::field(size_t index) const { | 808 const AutofillField* FormStructure::field(size_t index) const { |
| 794 if (index >= fields_.size()) { | 809 if (index >= fields_.size()) { |
| 795 NOTREACHED(); | 810 NOTREACHED(); |
| 796 return NULL; | 811 return NULL; |
| 797 } | 812 } |
| 798 | 813 |
| 799 return fields_[index]; | 814 return fields_[index]; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 if (current_type != UNKNOWN_TYPE && already_saw_current_type) { | 975 if (current_type != UNKNOWN_TYPE && already_saw_current_type) { |
| 961 // We reached the end of a section, so start a new section. | 976 // We reached the end of a section, so start a new section. |
| 962 seen_types.clear(); | 977 seen_types.clear(); |
| 963 current_section = (*field)->unique_name(); | 978 current_section = (*field)->unique_name(); |
| 964 } | 979 } |
| 965 | 980 |
| 966 seen_types.insert(current_type); | 981 seen_types.insert(current_type); |
| 967 (*field)->set_section(current_section); | 982 (*field)->set_section(current_section); |
| 968 } | 983 } |
| 969 } | 984 } |
| OLD | NEW |