Skip to content

Commit

Permalink
Add WebContentDelegate to the web-payments WebContent instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
javifernandez committed Dec 2, 2024
1 parent 3420ca0 commit e66d0f5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.igalia.wolvic.browser.api.impl;

import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewGroup;

Expand All @@ -16,11 +17,19 @@ public PanZoomControllerImpl(SessionImpl session) {

@Override
public void onTouchEvent(@NonNull MotionEvent event) {
if (getContentView() == null) {
Log.w("PanZoomControllerImpl", "called onTouchEvent() but getContentView() is null");
return;
}
getContentView().dispatchTouchEvent(event);
}

@Override
public void onMotionEvent(@NonNull MotionEvent event) {
if (getContentView() == null) {
Log.w("PanZoomControllerImpl", "called onMotionEvent() but getContentView() is null");
return;
}
getContentView().dispatchGenericMotionEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void purgeHistory() {
public void setPaymentWebContents(WebContents webContents, ContentView contentView, TabCompositorView compositorView) {
Log.e("MYSH", "set PaymentWebContents webContents=" + webContents + " contentView="+ contentView + " compositorView="+ compositorView);

//setWebContentsDelegate(webContents, mTabWebContentsDelegate);

mPaymentHandlerWebContents = webContents;
mPaymentHandlerContentView = contentView;
mPaymentHandlerCompositorView = compositorView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,13 @@ public void onCreateNewWindow(WebContents webContents) {

@Override
public void closeContents() {
Log.w(LOGTAG, "closeContents");
WSession.ContentDelegate delegate = mSession.getContentDelegate();
assert delegate != null;
//assert delegate != null;
if (delegate == null) {
Log.w(LOGTAG, "Trying to close contents when delegate is null");
return;
}

PostTask.postDelayedTask(TaskTraits.UI_DEFAULT, () -> {
delegate.onCloseRequest(mSession);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void onCreateNewPaymentHandler(final WebContents newWebContents) {
assert viewDelegate.getContainerView() instanceof ContentView
: "WebContents should not set container views other than ContentView.";

mTab.setWebContentsDelegate(newWebContents, new TabWebContentsDelegate(mSession, newWebContents));
mTab.setPaymentWebContents(newWebContents, (ContentView) viewDelegate.getContainerView(), compositorView);

WDisplay display = mSession.acquireOverlayDisplay(compositorView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ public void onFullScreen(@NonNull WSession session, boolean aFullScreen) {

@Override
public void onCloseRequest(@NonNull WSession aSession) {
Log.w(LOGTAG, "onCloseRequest");
Session session = SessionStore.get().getSession(aSession);
mWidgetManager.getWindows().onTabsClose(Collections.singletonList(session));
}
Expand Down

0 comments on commit e66d0f5

Please sign in to comment.