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

Side by Side Diff: chrome/browser/autofill/form_structure.cc

Issue 7747009: Add metrics to track Autofill "user happiness" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 DCHECK_EQ(cached_form.source_url_, source_url_); 628 DCHECK_EQ(cached_form.source_url_, source_url_);
629 DCHECK_EQ(cached_form.target_url_, target_url_); 629 DCHECK_EQ(cached_form.target_url_, target_url_);
630 form_signature_field_names_ = cached_form.form_signature_field_names_; 630 form_signature_field_names_ = cached_form.form_signature_field_names_;
631 } 631 }
632 632
633 void FormStructure::LogQualityMetrics( 633 void FormStructure::LogQualityMetrics(
634 const AutofillMetrics& metric_logger) const { 634 const AutofillMetrics& metric_logger) const {
635 std::string experiment_id = server_experiment_id(); 635 std::string experiment_id = server_experiment_id();
636 metric_logger.LogServerExperimentIdForUpload(experiment_id); 636 metric_logger.LogServerExperimentIdForUpload(experiment_id);
637 637
638 size_t num_detected_field_types = 0;
638 for (size_t i = 0; i < field_count(); ++i) { 639 for (size_t i = 0; i < field_count(); ++i) {
639 const AutofillField* field = this->field(i); 640 const AutofillField* field = this->field(i);
640 metric_logger.LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED, 641 metric_logger.LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
641 experiment_id); 642 experiment_id);
642 643
643 // No further logging for empty fields nor for fields where the entered data 644 // No further logging for empty fields nor for fields where the entered data
644 // does not appear to already exist in the user's stored Autofill data. 645 // does not appear to already exist in the user's stored Autofill data.
645 const FieldTypeSet& field_types = field->possible_types(); 646 const FieldTypeSet& field_types = field->possible_types();
646 DCHECK(!field_types.empty()); 647 DCHECK(!field_types.empty());
647 if (field_types.count(EMPTY_TYPE) || field_types.count(UNKNOWN_TYPE)) 648 if (field_types.count(EMPTY_TYPE) || field_types.count(UNKNOWN_TYPE))
648 continue; 649 continue;
649 650
651 ++num_detected_field_types;
652
650 // Collapse field types that Chrome treats as identical, e.g. home and 653 // Collapse field types that Chrome treats as identical, e.g. home and
651 // billing address fields. 654 // billing address fields.
652 FieldTypeSet collapsed_field_types; 655 FieldTypeSet collapsed_field_types;
653 for (FieldTypeSet::const_iterator it = field_types.begin(); 656 for (FieldTypeSet::const_iterator it = field_types.begin();
654 it != field_types.end(); 657 it != field_types.end();
655 ++it) { 658 ++it) {
656 // Since we currently only support US phone numbers, the (city code + main 659 // Since we currently only support US phone numbers, the (city code + main
657 // digits) number is almost always identical to the whole phone number. 660 // digits) number is almost always identical to the whole phone number.
658 // TODO(isherman): Improve this logic once we add support for 661 // TODO(isherman): Improve this logic once we add support for
659 // international numbers. 662 // international numbers.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 metric_logger.LogQualityMetric( 746 metric_logger.LogQualityMetric(
744 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH, 747 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
745 experiment_id); 748 experiment_id);
746 } else { 749 } else {
747 metric_logger.LogQualityMetric( 750 metric_logger.LogQualityMetric(
748 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH, 751 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
749 experiment_id); 752 experiment_id);
750 } 753 }
751 } 754 }
752 } 755 }
753 }
754 756
755 void FormStructure::set_possible_types(size_t index, 757 if (num_detected_field_types >= kRequiredFillableFields) {
756 const FieldTypeSet& types) { 758 metric_logger.LogUserHappinessMetric(
757 if (index >= fields_.size()) { 759 AutofillMetrics::SUBMITTED_FORM_COULD_HAVE_BEEN_AUTOFILLED);
758 NOTREACHED();
759 return;
760 } 760 }
761
762 fields_[index]->set_possible_types(types);
763 } 761 }
764 762
765 const AutofillField* FormStructure::field(size_t index) const { 763 const AutofillField* FormStructure::field(size_t index) const {
766 if (index >= fields_.size()) { 764 if (index >= fields_.size()) {
767 NOTREACHED(); 765 NOTREACHED();
768 return NULL; 766 return NULL;
769 } 767 }
770 768
771 return fields_[index]; 769 return fields_[index];
772 } 770 }
773 771
772 AutofillField* FormStructure::field(size_t index) {
773 return const_cast<AutofillField*>(
774 static_cast<const FormStructure*>(this)->field(index));
775 }
776
774 size_t FormStructure::field_count() const { 777 size_t FormStructure::field_count() const {
775 return fields_.size(); 778 return fields_.size();
776 } 779 }
777 780
778 std::string FormStructure::server_experiment_id() const { 781 std::string FormStructure::server_experiment_id() const {
779 return server_experiment_id_; 782 return server_experiment_id_;
780 } 783 }
781 784
782 bool FormStructure::operator==(const FormData& form) const { 785 bool FormStructure::operator==(const FormData& form) const {
783 // TODO(jhawkins): Is this enough to differentiate a form? 786 // TODO(jhawkins): Is this enough to differentiate a form?
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (current_type != UNKNOWN_TYPE && already_saw_current_type) { 933 if (current_type != UNKNOWN_TYPE && already_saw_current_type) {
931 // We reached the end of a section, so start a new section. 934 // We reached the end of a section, so start a new section.
932 seen_types.clear(); 935 seen_types.clear();
933 current_section = (*field)->unique_name(); 936 current_section = (*field)->unique_name();
934 } 937 }
935 938
936 seen_types.insert(current_type); 939 seen_types.insert(current_type);
937 (*field)->set_section(current_section); 940 (*field)->set_section(current_section);
938 } 941 }
939 } 942 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698