@@ -284,6 +284,7 @@ class WebViewProvider {
284284 private CompletableFuture <ICoreWebView2 > webViewFuture = new CompletableFuture <>();
285285 private CompletableFuture <ICoreWebView2_2 > webView_2Future = new CompletableFuture <>();
286286 private CompletableFuture <ICoreWebView2_11 > webView_11Future = new CompletableFuture <>();
287+ private CompletableFuture <ICoreWebView2_12 > webView_12Future = new CompletableFuture <>();
287288
288289 private CompletableFuture <Void > lastWebViewTask = webViewFuture .thenRun (() -> {});
289290
@@ -293,6 +294,7 @@ ICoreWebView2 initializeWebView(ICoreWebView2Controller controller) {
293294 final ICoreWebView2 webView = new ICoreWebView2 (ppv [0 ]);
294295 initializeWebView_2 (webView );
295296 initializeWebView_11 (webView );
297+ initializeWebView_12 (webView );
296298 webViewFuture .complete (webView );
297299 return webView ;
298300 }
@@ -317,6 +319,16 @@ private void initializeWebView_11(ICoreWebView2 webView) {
317319 }
318320 }
319321
322+ private void initializeWebView_12 (ICoreWebView2 webView ) {
323+ long [] ppv = new long [1 ];
324+ int hr = webView .QueryInterface (COM .IID_ICoreWebView2_12 , ppv );
325+ if (hr == COM .S_OK ) {
326+ webView_12Future .complete (new ICoreWebView2_12 (ppv [0 ]));
327+ } else {
328+ webView_12Future .cancel (true );
329+ }
330+ }
331+
320332 ICoreWebView2 getWebView (boolean waitForPendingWebviewTasksToFinish ) {
321333 if (waitForPendingWebviewTasksToFinish ) {
322334 waitForFutureToFinish (lastWebViewTask );
@@ -348,6 +360,18 @@ boolean isWebView_11Available() {
348360 return !webView_11Future .isCancelled ();
349361 }
350362
363+ ICoreWebView2_12 getWebView_12 (boolean waitForPendingWebviewTasksToFinish ) {
364+ if (waitForPendingWebviewTasksToFinish ) {
365+ waitForFutureToFinish (lastWebViewTask );
366+ }
367+ return webView_12Future .join ();
368+ }
369+
370+ boolean isWebView_12Available () {
371+ waitForFutureToFinish (webView_12Future );
372+ return !webView_12Future .isCancelled ();
373+ }
374+
351375 /*
352376 * Schedule a given runnable in a queue to execute when the webView is free and
353377 * has finished all the pending tasks queued before it.
@@ -561,6 +585,11 @@ void setupBrowser(int hr, long pv) {
561585 webViewProvider .getWebView_11 (false ).add_ContextMenuRequested (handler , token );
562586 handler .Release ();
563587 }
588+ if (webViewProvider .isWebView_12Available ()) {
589+ handler = newCallback (this ::handleStatusBarTextChanged );
590+ webViewProvider .getWebView_12 (false ).add_StatusBarTextChanged (handler , token );
591+ handler .Release ();
592+ }
564593
565594 IUnknown hostDisp = newHostObject (this ::handleCallJava );
566595 long [] hostObj = { COM .VT_DISPATCH , hostDisp .getAddress (), 0 }; // VARIANT
@@ -587,6 +616,7 @@ void browserDispose(Event event) {
587616 if (settings != null ) settings .Release ();
588617 if (webViewProvider .isWebView_2Available ()) webViewProvider .getWebView_2 (false ).Release ();
589618 if (webViewProvider .isWebView_11Available ()) webViewProvider .getWebView_11 (false ).Release ();
619+ if (webViewProvider .isWebView_12Available ()) webViewProvider .getWebView_12 (false ).Release ();
590620 if (controller != null ) {
591621 // Bug in WebView2. Closing the controller from an event handler results
592622 // in a crash. The fix is to delay the closure with asyncExec.
@@ -866,6 +896,20 @@ int handleContextMenuRequested(long pView, long pArgs) {
866896 return COM .S_OK ;
867897}
868898
899+ int handleStatusBarTextChanged (long pView , long pArgs ) {
900+ long ppsz [] = new long [1 ];
901+ webViewProvider .getWebView_12 (true ).get_StatusBarText (ppsz );
902+ String text = wstrToString (ppsz [0 ], true );
903+ StatusTextEvent newEvent5 = new StatusTextEvent (browser );
904+ newEvent5 .display = browser .getDisplay ();
905+ newEvent5 .widget = browser ;
906+ newEvent5 .text = text ;
907+ for (StatusTextListener statusTextListener : statusTextListeners ) {
908+ statusTextListener .changed (newEvent5 );
909+ }
910+ return COM .S_OK ;
911+ }
912+
869913int handleNavigationCompleted (long pView , long pArgs ) {
870914 return handleNavigationCompleted (pView , pArgs , true );
871915}
0 commit comments