Commit d341822b authored by Sahel Sharify's avatar Sahel Sharify Committed by Commit Bot

[Payments] Fix DCHECK triggered by cluster-fuzz test case.

The DCHECK happens when PaymentRequestState::OnDoneCreatingPaymentApps()
gets called after the merchant has called Abort(), and no supported
method exists. This is because the supported method callback which gets
called inside OnDoneCreatingPaymentApps() tries to set a NotShownReason
after the Abort() call which has already set the AbortReason.

In this cl the state_ gets notified about Abort() calls, and clears
the pending (if any) supported method call back on abort.

A test will be added in a follow up cl to test abort() call before
OnDoneCreatingPaymentApps() once cross platform payment app factory is
ready (crbug.com/1054115)

Bug: 1040194
Change-Id: I8985fd805df05e656b271e4dac4bb4d20a7fb045
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065049Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Sahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742807}
parent 3e33b99b
......@@ -424,6 +424,9 @@ void PaymentRequest::Abort() {
if (observer_for_testing_)
observer_for_testing_->OnAbortCalled();
if (accepting_abort)
state_->OnAbort();
}
void PaymentRequest::Complete(mojom::PaymentComplete result) {
......
......@@ -263,6 +263,13 @@ void PaymentRequestState::AreRequestedMethodsSupported(
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void PaymentRequestState::OnAbort() {
// Reset supported method callback when the merchant calls abort before
// OnDoneCreatingPaymentApps().
if (are_requested_methods_supported_callback_)
are_requested_methods_supported_callback_.Reset();
}
void PaymentRequestState::CheckRequestedMethodsSupported(
MethodsSupportedCallback callback) {
DCHECK(get_all_apps_finished_);
......
......@@ -163,6 +163,9 @@ class PaymentRequestState : public PaymentAppFactory::Delegate,
// "basic-card", but false for "https://bobpay.com".
void AreRequestedMethodsSupported(MethodsSupportedCallback callback);
// Resets pending MethodsSupportedCallback after abort.
void OnAbort();
// Returns authenticated user email, or empty string.
std::string GetAuthenticatedEmail() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment