From 31e48589a98e00207e338e50ee5e178318a598c3 Mon Sep 17 00:00:00 2001 From: Miyoung Shin Date: Tue, 3 Dec 2024 15:34:10 +0900 Subject: [PATCH] fix DCHECK error & implement close() --- .../payments/ui/WolvicPaymentUiService.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/wolvic/java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java b/wolvic/java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java index 8602ab2e70d373..17a6e9f2d95e8e 100644 --- a/wolvic/java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java +++ b/wolvic/java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java @@ -20,6 +20,8 @@ import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.WebContents; +import org.chromium.ui.base.ActivityWindowAndroid; +import org.chromium.ui.base.IntentRequestTracker; import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.WindowAndroid; import org.chromium.url.GURL; @@ -56,6 +58,7 @@ public class WolvicPaymentUiService { private List mPaymentApps; private static final String TAG = "WolvicPaymentUiService"; + private Runnable mHider; /** The delegate of this class. */ // TODO(jfernandez): Define the a complete delegate @@ -246,11 +249,14 @@ public void initialize(PaymentDetails details) { * successful; null if failed. */ public @Nullable WebContents showPaymentHandlerUI(GURL url) { - WindowAndroid windowAndroid = mWebContents.getTopLevelNativeWindow(); - if (windowAndroid == null) return null; - Activity activity = windowAndroid.getActivity().get(); + if (mWebContents.getTopLevelNativeWindow() == null) return null; + + Activity activity = mWebContents.getTopLevelNativeWindow().getActivity().get(); if (activity == null) return null; + ActivityWindowAndroid windowAndroid = new ActivityWindowAndroid(activity, false, + IntentRequestTracker.createFromActivity(activity)); + WebContents paymentHandlerWebContents = createWebContents(mIsOffTheRecord); if (paymentHandlerWebContents == null) return null; @@ -270,6 +276,9 @@ public void initialize(PaymentDetails details) { mWebContents.notifyOnCreateNewPaymentHandler(paymentHandlerWebContents); + mHider = () -> { + paymentHandlerWebContents.destroy(); + }; return paymentHandlerWebContents; } @@ -328,7 +337,8 @@ public void close() { assert !mHasClosed; mHasClosed = true; - // TODO(jfernandez): Implement properly the "close" logic. - + if (mHider == null) return; + mHider.run(); + mHider = null; } }