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/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
12 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/autofill/core/browser/autofill_experiments.h" | |
14 #include "components/autofill/core/browser/autofill_type.h" | 15 #include "components/autofill/core/browser/autofill_type.h" |
15 #include "components/autofill/core/browser/form_structure.h" | 16 #include "components/autofill/core/browser/form_structure.h" |
16 #include "components/autofill/core/common/form_data.h" | 17 #include "components/autofill/core/common/form_data.h" |
18 #include "components/ukm/ukm_entry_builder.h" | |
19 | |
20 namespace internal { | |
21 const char kUKMCardUploadDecisionEntryName[] = "Autofill.CardUploadDecision"; | |
22 const char kUKMCardUploadDecisionMetricName[] = "UploadDecision"; | |
23 } // namespace internal | |
17 | 24 |
18 namespace autofill { | 25 namespace autofill { |
19 | 26 |
20 namespace { | 27 namespace { |
21 | 28 |
22 // Note: if adding an enum value here, update the corresponding description for | 29 // Note: if adding an enum value here, update the corresponding description for |
23 // AutofillTypeQualityByFieldType in histograms.xml. | 30 // AutofillTypeQualityByFieldType in histograms.xml. |
24 enum FieldTypeGroupForMetrics { | 31 enum FieldTypeGroupForMetrics { |
25 GROUP_AMBIGUOUS = 0, | 32 GROUP_AMBIGUOUS = 0, |
26 GROUP_NAME, | 33 GROUP_NAME, |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, | 689 UMA_HISTOGRAM_ENUMERATION("Autofill.WalletAddressConversionType", type, |
683 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); | 690 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES); |
684 } | 691 } |
685 | 692 |
686 // static | 693 // static |
687 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { | 694 void AutofillMetrics::LogShowedHttpNotSecureExplanation() { |
688 base::RecordAction( | 695 base::RecordAction( |
689 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); | 696 base::UserMetricsAction("Autofill_ShowedHttpNotSecureExplanation")); |
690 } | 697 } |
691 | 698 |
699 // static | |
700 bool AutofillMetrics::LogCardUploadDecisionMetricUkm( | |
701 ukm::UkmService* ukm_service, | |
702 const GURL& url, | |
703 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
704 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) | |
705 return false; | |
706 | |
707 std::map<std::string, int> metrics = { | |
708 {internal::kUKMCardUploadDecisionMetricName, | |
709 static_cast<int>(upload_decision)}}; | |
710 return LogUkm(ukm_service, url, internal::kUKMCardUploadDecisionEntryName, | |
711 metrics); | |
712 } | |
713 | |
714 // static | |
715 bool AutofillMetrics::LogUkm(ukm::UkmService* ukm_service, | |
Mathieu
2017/03/10 15:30:22
We can keep the return value for unit testing, I g
sebsg
2017/03/10 16:45:28
Acknowledged.
| |
716 const GURL& url, | |
717 const std::string& ukm, | |
718 const std::map<std::string, int>& metrics) { | |
719 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || | |
720 metrics.empty()) { | |
721 return false; | |
722 } | |
723 | |
724 int32_t source_id = ukm_service->GetNewSourceID(); | |
725 ukm_service->UpdateSourceURL(source_id, url); | |
726 std::unique_ptr<ukm::UkmEntryBuilder> builder = | |
727 ukm_service->GetEntryBuilder(source_id, ukm.c_str()); | |
728 | |
729 for (auto it = metrics.begin(); it != metrics.end(); ++it) { | |
730 builder->AddMetric(it->first.c_str(), it->second); | |
731 } | |
732 | |
733 return true; | |
734 } | |
735 | |
692 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) | 736 AutofillMetrics::FormEventLogger::FormEventLogger(bool is_for_credit_card) |
693 : is_for_credit_card_(is_for_credit_card), | 737 : is_for_credit_card_(is_for_credit_card), |
694 is_server_data_available_(false), | 738 is_server_data_available_(false), |
695 is_local_data_available_(false), | 739 is_local_data_available_(false), |
696 is_context_secure_(false), | 740 is_context_secure_(false), |
697 has_logged_interacted_(false), | 741 has_logged_interacted_(false), |
698 has_logged_suggestions_shown_(false), | 742 has_logged_suggestions_shown_(false), |
699 has_logged_masked_server_card_suggestion_selected_(false), | 743 has_logged_masked_server_card_suggestion_selected_(false), |
700 has_logged_suggestion_filled_(false), | 744 has_logged_suggestion_filled_(false), |
701 has_logged_will_submit_(false), | 745 has_logged_will_submit_(false), |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 else if (is_server_data_available_ && !is_local_data_available_) | 930 else if (is_server_data_available_ && !is_local_data_available_) |
887 name += ".WithOnlyServerData"; | 931 name += ".WithOnlyServerData"; |
888 else if (!is_server_data_available_ && is_local_data_available_) | 932 else if (!is_server_data_available_ && is_local_data_available_) |
889 name += ".WithOnlyLocalData"; | 933 name += ".WithOnlyLocalData"; |
890 else | 934 else |
891 name += ".WithBothServerAndLocalData"; | 935 name += ".WithBothServerAndLocalData"; |
892 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); | 936 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); |
893 } | 937 } |
894 | 938 |
895 } // namespace autofill | 939 } // namespace autofill |
OLD | NEW |