Index: components/autofill/core/browser/autofill_manager.cc |
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc |
index 1e7a2cacfe19b19dcc46d3220b4294f6bb6eb162..7c59a533aaf9b9733727150419d5922e2430ba12 100644 |
--- a/components/autofill/core/browser/autofill_manager.cc |
+++ b/components/autofill/core/browser/autofill_manager.cc |
@@ -42,6 +42,7 @@ |
#include "components/autofill/core/browser/autofill_metrics.h" |
#include "components/autofill/core/browser/autofill_profile.h" |
#include "components/autofill/core/browser/autofill_type.h" |
+#include "components/autofill/core/browser/autofill_ukm.h" |
#include "components/autofill/core/browser/country_names.h" |
#include "components/autofill/core/browser/credit_card.h" |
#include "components/autofill/core/browser/field_types.h" |
@@ -206,6 +207,22 @@ Suggestion CreateHttpWarningMessageSuggestionItem(const GURL& source_url) { |
return cc_field_http_warning_suggestion; |
} |
+// Logs the card upload decision ukm based on the specified |url| and |
+// |upload_decision|. Returns whether the metric was logged sucessfully. |
+bool LogCardUploadDecisionMetricUkm( |
+ ukm::UkmService* ukm_service, |
+ const GURL& url, |
+ AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
+ if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) |
Mathieu
2017/03/09 18:40:49
DCHECK(ukm_service);
sebsg
2017/03/09 19:57:04
As discussed offline, will not add this.
|
+ return false; |
+ |
+ std::map<std::string, int> metrics; |
Mathieu
2017/03/09 18:40:49
is there a fancy initialization like:
const std::
sebsg
2017/03/09 19:57:04
Done.
|
+ metrics.insert( |
+ std::make_pair("UploadDecision", static_cast<int>(upload_decision))); |
+ return AutofillUkm::LogUkm(ukm_service, url, "Autofill.CardUploadDecision", |
+ metrics); |
+} |
+ |
} // namespace |
AutofillManager::AutofillManager( |
@@ -1039,6 +1056,9 @@ void AutofillManager::OnDidGetUploadDetails( |
weak_ptr_factory_.GetWeakPtr())); |
AutofillMetrics::LogCardUploadDecisionMetric( |
AutofillMetrics::UPLOAD_OFFERED); |
+ LogCardUploadDecisionMetricUkm(client_->GetUkmService(), |
+ pending_upload_request_url_, |
+ AutofillMetrics::UPLOAD_OFFERED); |
} else { |
// If the upload details request failed, fall back to a local save. The |
// reasoning here is as follows: |
@@ -1058,7 +1078,11 @@ void AutofillManager::OnDidGetUploadDetails( |
base::Unretained(personal_data_), upload_request_.card)); |
AutofillMetrics::LogCardUploadDecisionMetric( |
AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
+ LogCardUploadDecisionMetricUkm( |
+ client_->GetUkmService(), pending_upload_request_url_, |
+ AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
} |
+ pending_upload_request_url_ = GURL(); |
} |
void AutofillManager::OnDidUploadCard( |
@@ -1218,11 +1242,17 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
&get_profiles_decision_metric, |
&rappor_metric_name); |
+ pending_upload_request_url_ = GURL(submitted_form.source_url()); |
+ |
// Both the CVC and address checks are done. Conform to the legacy order of |
// reporting on CVC then address. |
if (upload_request_.cvc.empty()) { |
AutofillMetrics::LogCardUploadDecisionMetric( |
AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
+ LogCardUploadDecisionMetricUkm( |
+ client_->GetUkmService(), pending_upload_request_url_, |
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
+ pending_upload_request_url_ = GURL(); |
CollectRapportSample(submitted_form.source_url(), |
"Autofill.CardUploadNotOfferedNoCvc"); |
return; |
@@ -1231,6 +1261,10 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); |
AutofillMetrics::LogCardUploadDecisionMetric( |
get_profiles_decision_metric); |
+ LogCardUploadDecisionMetricUkm(client_->GetUkmService(), |
+ pending_upload_request_url_, |
+ get_profiles_decision_metric); |
+ pending_upload_request_url_ = GURL(); |
if (!rappor_metric_name.empty()) { |
CollectRapportSample(submitted_form.source_url(), rappor_metric_name); |
} |