[Payments] Record navigations that close the Payment Request as aborts.
BUG=717757
Review-Url: https://codereview.chromium.org/2870153002
Cr-Commit-Position: refs/heads/master@{#472514}
diff --git a/components/payments/content/payment_request.cc b/components/payments/content/payment_request.cc
index 540059b..af2ca0d 100644
--- a/components/payments/content/payment_request.cc
+++ b/components/payments/content/payment_request.cc
@@ -152,8 +152,7 @@
// the renderer, which closes the Mojo message pipe, which triggers
// PaymentRequest::OnConnectionTerminated, which destroys this object.
// TODO(crbug.com/716546): Add a merchant abort metric,
- journey_logger_.RecordJourneyStatsHistograms(
- JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED);
+ RecordFirstCompletionStatus(JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED);
if (client_.is_bound())
client_->OnAbort(true /* aborted_successfully */);
}
@@ -226,8 +225,7 @@
if (!client_.is_bound())
return;
- journey_logger_.RecordJourneyStatsHistograms(
- JourneyLogger::COMPLETION_STATUS_USER_ABORTED);
+ RecordFirstCompletionStatus(JourneyLogger::COMPLETION_STATUS_USER_ABORTED);
// This sends an error to the renderer, which informs the API user.
client_->OnError(mojom::PaymentErrorReason::USER_CANCEL);
@@ -240,6 +238,12 @@
manager_->DestroyRequest(this);
}
+void PaymentRequest::DidStartNavigation(bool is_user_initiated) {
+ RecordFirstCompletionStatus(
+ is_user_initiated ? JourneyLogger::COMPLETION_STATUS_USER_ABORTED
+ : JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED);
+}
+
void PaymentRequest::OnConnectionTerminated() {
// We are here because of a browser-side error, or likely as a result of the
// connection_error_handler on |binding_|, which can mean that the renderer
@@ -258,4 +262,12 @@
state_->GeneratePaymentResponse();
}
+void PaymentRequest::RecordFirstCompletionStatus(
+ JourneyLogger::CompletionStatus completion_status) {
+ if (!has_recorded_abort_reason_) {
+ has_recorded_abort_reason_ = true;
+ journey_logger_.RecordJourneyStatsHistograms(completion_status);
+ }
+}
+
} // namespace payments