Skip to content

Commit 11df912

Browse files
committed
[WebPayments] A new PaymentRequestUI class, derived from Tab
This new class can be used to create instance of Tabs that can handle PaymentHandler work-flow. The Client interface provides an API to control the window's life-cycle.
1 parent dae31d1 commit 11df912

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

Diff for: wolvic/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ android_library("wolvic_java") {
355355
"java/org/chromium/wolvic/payments/WolvicPaymentRequestService.java",
356356
"java/org/chromium/wolvic/payments/WolvicPaymentResponseHelper.java",
357357
"java/org/chromium/wolvic/payments/ui/WolvicPaymentUiService.java",
358+
"java/org/chromium/wolvic/payments/ui/PaymentRequestUI.java",
358359
]
359360
srcjar_deps = [ ":jni_headers" ]
360361
deps = [

Diff for: wolvic/java/org/chromium/wolvic/Tab.java

-16
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,6 @@ public Tab(@NonNull Context context, boolean is_off_the_record, WebContents webC
8686
mWebContents.onShow();
8787
}
8888

89-
public static TabCompositorView createNewTab(@NonNull Context context, @NonNull WebContents webContents) {
90-
// TODO(jfernandez): This code block is duplicated in Tabconstructor, so we may want to refactor it.
91-
ActivityWindowAndroid windowAndroid = new ActivityWindowAndroid(context, false,
92-
IntentRequestTracker.createFromActivity(ContextUtils.activityFromContext(context)));
93-
TabCompositorView compositorView = new TabCompositorView(context);
94-
compositorView.onNativeLibraryLoaded(windowAndroid);
95-
windowAndroid.setAnimationPlaceholderView(compositorView);
96-
ContentView webContentView =
97-
ContentView.createContentView(
98-
context, /* eventOffsetHandler= */ null, webContents);
99-
webContents.initialize("", ViewAndroidDelegate.createBasicDelegate(webContentView),
100-
webContentView, windowAndroid, WebContents.createDefaultInternalsHolder());
101-
102-
return compositorView;
103-
}
104-
10589
public void destroy() {
10690
mWindowAndroid = null;
10791
mContentView = null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.chromium.wolvic.payments.ui;
2+
3+
import android.content.Context;
4+
5+
import androidx.annotation.Nullable;
6+
import androidx.annotation.NonNull;
7+
8+
import org.chromium.content_public.browser.WebContents;
9+
10+
import org.chromium.wolvic.Tab;
11+
12+
/** The PaymentRequest UI. */
13+
public class PaymentRequestUI extends Tab {
14+
15+
/** The interface to be implemented by the consumer of the PaymentRequest UI. */
16+
public interface Client {
17+
18+
/**
19+
* Called when the user dismisses the UI via clicking outsude the modal dialog.
20+
*/
21+
void onDismiss();
22+
}
23+
24+
private Client mClient;
25+
26+
public PaymentRequestUI(
27+
@NonNull Context context,
28+
@Nullable WebContents webContents,
29+
@Nullable Client client) {
30+
super(context, false, webContents);
31+
mClient = client;
32+
}
33+
34+
@Override
35+
public void destroy() {
36+
super.destroy();
37+
if (mClient != null)
38+
mClient.onDismiss();
39+
}
40+
}

0 commit comments

Comments
 (0)