20
20
21
21
import org .chromium .content_public .browser .LoadUrlParams ;
22
22
import org .chromium .content_public .browser .WebContents ;
23
+ import org .chromium .ui .base .ActivityWindowAndroid ;
24
+ import org .chromium .ui .base .IntentRequestTracker ;
23
25
import org .chromium .ui .base .ViewAndroidDelegate ;
24
26
import org .chromium .ui .base .WindowAndroid ;
25
27
import org .chromium .url .GURL ;
@@ -56,6 +58,7 @@ public class WolvicPaymentUiService {
56
58
private List <PaymentApp > mPaymentApps ;
57
59
58
60
private static final String TAG = "WolvicPaymentUiService" ;
61
+ private Runnable mHider ;
59
62
60
63
/** The delegate of this class. */
61
64
// TODO(jfernandez): Define the a complete delegate
@@ -246,11 +249,14 @@ public void initialize(PaymentDetails details) {
246
249
* successful; null if failed.
247
250
*/
248
251
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 ();
252
255
if (activity == null ) return null ;
253
256
257
+ ActivityWindowAndroid windowAndroid = new ActivityWindowAndroid (activity , false ,
258
+ IntentRequestTracker .createFromActivity (activity ));
259
+
254
260
WebContents paymentHandlerWebContents = createWebContents (mIsOffTheRecord );
255
261
if (paymentHandlerWebContents == null )
256
262
return null ;
@@ -270,6 +276,9 @@ public void initialize(PaymentDetails details) {
270
276
271
277
mWebContents .notifyOnCreateNewPaymentHandler (paymentHandlerWebContents );
272
278
279
+ mHider = () -> {
280
+ paymentHandlerWebContents .destroy ();
281
+ };
273
282
return paymentHandlerWebContents ;
274
283
}
275
284
@@ -328,7 +337,8 @@ public void close() {
328
337
assert !mHasClosed ;
329
338
mHasClosed = true ;
330
339
331
- // TODO(jfernandez): Implement properly the "close" logic.
332
-
340
+ if (mHider == null ) return ;
341
+ mHider .run ();
342
+ mHider = null ;
333
343
}
334
344
}
0 commit comments