Skip to content

Commit 31e4858

Browse files
MyidShinjavifernandez
authored andcommitted
fix DCHECK error & implement close()
1 parent fbd6bcd commit 31e4858

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: wolvic/java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import org.chromium.content_public.browser.LoadUrlParams;
2222
import org.chromium.content_public.browser.WebContents;
23+
import org.chromium.ui.base.ActivityWindowAndroid;
24+
import org.chromium.ui.base.IntentRequestTracker;
2325
import org.chromium.ui.base.ViewAndroidDelegate;
2426
import org.chromium.ui.base.WindowAndroid;
2527
import org.chromium.url.GURL;
@@ -56,6 +58,7 @@ public class WolvicPaymentUiService {
5658
private List<PaymentApp> mPaymentApps;
5759

5860
private static final String TAG = "WolvicPaymentUiService";
61+
private Runnable mHider;
5962

6063
/** The delegate of this class. */
6164
// TODO(jfernandez): Define the a complete delegate
@@ -246,11 +249,14 @@ public void initialize(PaymentDetails details) {
246249
* successful; null if failed.
247250
*/
248251
public @Nullable WebContents showPaymentHandlerUI(GURL url) {
249-
WindowAndroid windowAndroid = mWebContents.getTopLevelNativeWindow();
250-
if (windowAndroid == null) return null;
251-
Activity activity = windowAndroid.getActivity().get();
252+
if (mWebContents.getTopLevelNativeWindow() == null) return null;
253+
254+
Activity activity = mWebContents.getTopLevelNativeWindow().getActivity().get();
252255
if (activity == null) return null;
253256

257+
ActivityWindowAndroid windowAndroid = new ActivityWindowAndroid(activity, false,
258+
IntentRequestTracker.createFromActivity(activity));
259+
254260
WebContents paymentHandlerWebContents = createWebContents(mIsOffTheRecord);
255261
if (paymentHandlerWebContents == null)
256262
return null;
@@ -270,6 +276,9 @@ public void initialize(PaymentDetails details) {
270276

271277
mWebContents.notifyOnCreateNewPaymentHandler(paymentHandlerWebContents);
272278

279+
mHider = () -> {
280+
paymentHandlerWebContents.destroy();
281+
};
273282
return paymentHandlerWebContents;
274283
}
275284

@@ -328,7 +337,8 @@ public void close() {
328337
assert !mHasClosed;
329338
mHasClosed = true;
330339

331-
// TODO(jfernandez): Implement properly the "close" logic.
332-
340+
if (mHider == null) return;
341+
mHider.run();
342+
mHider = null;
333343
}
334344
}

0 commit comments

Comments
 (0)