Commit 8d9b777c authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Chromium LUCI CQ

[WebLayer] Encapsulate Minimal UI in PaymentUiService

MinimalUi is the implementation details of PaymentUiService and so
should not be exposed to the payment request service. This CL
encapsulate the MinimalUI logic in PaymentUiService so that
PaymentUiService no longer provides the MinimalUICoordinator instance.

Bug: 1155582
Change-Id: Ica49ae9190248d400f29ef8102c9a4394356ad85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575342
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834023}
parent 5ec320bd
...@@ -10,7 +10,6 @@ import androidx.annotation.Nullable; ...@@ -10,7 +10,6 @@ import androidx.annotation.Nullable;
import androidx.collection.ArrayMap; import androidx.collection.ArrayMap;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.ChromeActivity; import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager; import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator; import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator;
...@@ -671,10 +670,9 @@ public class ChromePaymentRequestService ...@@ -671,10 +670,9 @@ public class ChromePaymentRequestService
// Implements BrowserPaymentRequest: // Implements BrowserPaymentRequest:
@Override @Override
public void onInstrumentDetailsError(String errorMessage) { public void onInstrumentDetailsError(String errorMessage) {
if (mPaymentUiService.getMinimalUI() != null) { if (mPaymentUiService.isShowingMinimalUi()) {
mJourneyLogger.setAborted(AbortReason.ABORTED_BY_USER); mJourneyLogger.setAborted(AbortReason.ABORTED_BY_USER);
mPaymentUiService.getMinimalUI().showErrorAndClose( mPaymentUiService.closeMinimalUiOnError(this::close);
/*observer=*/this::close, R.string.payments_error_message);
return; return;
} }
......
...@@ -443,9 +443,20 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs ...@@ -443,9 +443,20 @@ public class PaymentUiService implements SettingsAutofillAndPaymentsObserver.Obs
return mHaveRequestedAutofillData; return mHaveRequestedAutofillData;
} }
/** @return The minimal UI coordinator. */ /**
public MinimalUICoordinator getMinimalUI() { * Closes the minimal UI and shows an error message, called only when isShowingMinimalUi()
return mMinimalUi; * returns true.
* @param onClosed Called when the minimal UI is closed.
*/
public void closeMinimalUiOnError(Runnable onClosed) {
assert mMinimalUi != null;
mMinimalUi.showErrorAndClose(
/*observer=*/onClosed::run, R.string.payments_error_message);
}
/** @return Whether the minimal UI is showing. */
public boolean isShowingMinimalUi() {
return mMinimalUi != null;
} }
// Implements PaymentUiServiceTestInterface: // Implements PaymentUiServiceTestInterface:
......
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