diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java index 01c12371aea..6a7b817f909 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java @@ -284,6 +284,7 @@ class WebViewProvider { private CompletableFuture webViewFuture = new CompletableFuture<>(); private CompletableFuture webView_2Future = new CompletableFuture<>(); private CompletableFuture webView_11Future = new CompletableFuture<>(); + private CompletableFuture webView_12Future = new CompletableFuture<>(); private CompletableFuture lastWebViewTask = webViewFuture.thenRun(() -> {}); @@ -293,6 +294,7 @@ ICoreWebView2 initializeWebView(ICoreWebView2Controller controller) { final ICoreWebView2 webView = new ICoreWebView2(ppv[0]); initializeWebView_2(webView); initializeWebView_11(webView); + initializeWebView_12(webView); webViewFuture.complete(webView); return webView; } @@ -317,6 +319,16 @@ private void initializeWebView_11(ICoreWebView2 webView) { } } + private void initializeWebView_12(ICoreWebView2 webView) { + long[] ppv = new long[1]; + int hr = webView.QueryInterface(COM.IID_ICoreWebView2_12, ppv); + if (hr == COM.S_OK) { + webView_12Future.complete(new ICoreWebView2_12(ppv[0])); + } else { + webView_12Future.cancel(true); + } + } + ICoreWebView2 getWebView(boolean waitForPendingWebviewTasksToFinish) { if(waitForPendingWebviewTasksToFinish) { waitForFutureToFinish(lastWebViewTask); @@ -348,6 +360,18 @@ boolean isWebView_11Available() { return !webView_11Future.isCancelled(); } + ICoreWebView2_12 getWebView_12(boolean waitForPendingWebviewTasksToFinish) { + if(waitForPendingWebviewTasksToFinish) { + waitForFutureToFinish(lastWebViewTask); + } + return webView_12Future.join(); + } + + boolean isWebView_12Available() { + waitForFutureToFinish(webView_12Future); + return !webView_12Future.isCancelled(); + } + /* * Schedule a given runnable in a queue to execute when the webView is free and * has finished all the pending tasks queued before it. @@ -561,6 +585,11 @@ void setupBrowser(int hr, long pv) { webViewProvider.getWebView_11(false).add_ContextMenuRequested(handler, token); handler.Release(); } + if (webViewProvider.isWebView_12Available()) { + handler = newCallback(this::handleStatusBarTextChanged); + webViewProvider.getWebView_12(false).add_StatusBarTextChanged(handler, token); + handler.Release(); + } IUnknown hostDisp = newHostObject(this::handleCallJava); long[] hostObj = { COM.VT_DISPATCH, hostDisp.getAddress(), 0 }; // VARIANT @@ -587,6 +616,7 @@ void browserDispose(Event event) { if (settings != null) settings.Release(); if (webViewProvider.isWebView_2Available()) webViewProvider.getWebView_2(false).Release(); if (webViewProvider.isWebView_11Available()) webViewProvider.getWebView_11(false).Release(); + if (webViewProvider.isWebView_12Available()) webViewProvider.getWebView_12(false).Release(); if(controller != null) { // Bug in WebView2. Closing the controller from an event handler results // in a crash. The fix is to delay the closure with asyncExec. @@ -866,6 +896,20 @@ int handleContextMenuRequested(long pView, long pArgs) { return COM.S_OK; } +int handleStatusBarTextChanged(long pView, long pArgs) { + long ppsz[] = new long[1]; + webViewProvider.getWebView_12(true).get_StatusBarText(ppsz); + String text = wstrToString(ppsz[0], true); + StatusTextEvent newEvent5 = new StatusTextEvent(browser); + newEvent5.display = browser.getDisplay(); + newEvent5.widget = browser; + newEvent5.text = text; + for (StatusTextListener statusTextListener : statusTextListeners) { + statusTextListener.changed(newEvent5); + } + return COM.S_OK; +} + int handleNavigationCompleted(long pView, long pArgs) { return handleNavigationCompleted(pView, pArgs, true); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java index 6416ab2a38a..f0d45d548e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java @@ -87,6 +87,7 @@ public class COM extends OS { public static final GUID IID_ICoreWebView2Environment2 = IIDFromString("{41F3632B-5EF4-404F-AD82-2D606C5A9A21}"); //$NON-NLS-1$ public static final GUID IID_ICoreWebView2_2 = IIDFromString("{9E8F0CF8-E670-4B5E-B2BC-73E061E3184C}"); //$NON-NLS-1$ public static final GUID IID_ICoreWebView2_11 = IIDFromString("{0BE78E56-C193-4051-B943-23B460C08BDB}"); //$NON-NLS-1$ + public static final GUID IID_ICoreWebView2_12 = IIDFromString("{35D69927-BCFA-4566-9349-6B3E0D154CAC}"); //$NON-NLS-1$ // IA2 related GUIDS public static final GUID IIDIAccessible2 = IIDFromString("{E89F726E-C4F4-4c19-BB19-B647D7FA8478}"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ICoreWebView2_12.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ICoreWebView2_12.java new file mode 100644 index 00000000000..4b05a897070 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ICoreWebView2_12.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2024 SAP SE and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * SAP SE - initial implementation + *******************************************************************************/ +package org.eclipse.swt.internal.ole.win32; + +public class ICoreWebView2_12 extends ICoreWebView2_11 { + +public ICoreWebView2_12(long address) { + super(address); +} + +public int add_StatusBarTextChanged(IUnknown eventHandler, long[] token) { + return COM.VtblCall(102, address, eventHandler.getAddress(), token); +} + +public int remove_StatusBarTextChanged(long[] token) { + return COM.VtblCall(103, address, token); +} + +public int get_StatusBarText(long[] value) { + return COM.VtblCall(104, address, value); +} + +}