| Index: components/autofill/core/browser/autofill_metrics.cc
|
| diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc
|
| index 21ca9f840d9ecad5624ba2474946b25d9dea0de2..b935208272d1ac95cd64b89eceb00d59981f8144 100644
|
| --- a/components/autofill/core/browser/autofill_metrics.cc
|
| +++ b/components/autofill/core/browser/autofill_metrics.cc
|
| @@ -465,4 +465,52 @@ void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) {
|
| UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions);
|
| }
|
|
|
| +AutofillMetrics::FormEventLogger::FormEventLogger(bool is_credit_card)
|
| + : is_credit_card_(is_credit_card),
|
| + is_server_data_available_(false),
|
| + is_local_data_available_(false),
|
| + has_logged_interacted_(false) {};
|
| +
|
| +void AutofillMetrics::FormEventLogger::set_is_server_data_available(
|
| + bool is_server_data_available) {
|
| + is_server_data_available_ = is_server_data_available;
|
| +}
|
| +
|
| +void AutofillMetrics::FormEventLogger::set_is_local_data_available(
|
| + bool is_local_data_available) {
|
| + is_local_data_available_ = is_local_data_available;
|
| +}
|
| +
|
| +void AutofillMetrics::FormEventLogger::OnDidInteractWithAutofillableForm() {
|
| + if (!has_logged_interacted_) {
|
| + has_logged_interacted_ = true;
|
| + Log(AutofillMetrics::INTERACTED_ONCE_FORM_EVENT);
|
| + }
|
| +}
|
| +
|
| +void AutofillMetrics::FormEventLogger::Log(AutofillFormEvent event) const {
|
| + DCHECK_LT(event, NUM_AUTOFILL_FORM_EVENTS);
|
| + std::string name("Autofill.FormEvents.");
|
| + if (is_credit_card_) {
|
| + name += "CreditCard";
|
| + } else {
|
| + name += "Address";
|
| + }
|
| + LogUMAHistogramEnumeration(name, event, NUM_AUTOFILL_FORM_EVENTS);
|
| +
|
| + // Logging again in a different histogram for segmentation purposes.
|
| + // TODO(waltercacau): Re-evaluate if we still need such fine grained
|
| + // segmentation. http://crbug.com/454018
|
| + if (!is_server_data_available_ && !is_local_data_available_) {
|
| + name += ".WithNoData";
|
| + } else if (is_server_data_available_ && !is_local_data_available_) {
|
| + name += ".WithOnlyServerData";
|
| + } else if (!is_server_data_available_ && is_local_data_available_) {
|
| + name += ".WithOnlyLocalData";
|
| + } else {
|
| + name += ".WithBothServerAndLocalData";
|
| + }
|
| + LogUMAHistogramEnumeration(name, event, NUM_AUTOFILL_FORM_EVENTS);
|
| +}
|
| +
|
| } // namespace autofill
|
|
|