public class WindowsWebViewJNI extends Object
newMessageLoop() from the message loop thread.runMessageLoop(long) from the message loop
thread. This enters a blocking loop in native code. It will not return until releaseMessageLoop(long) is
called by another thread.
long webViewMessageLoop = 0;
// Create a new thread to run the WebView message loop.
webViewUI = new Thread("WebView UI")
{
public void run()
{
// Create a message loop in native code. This call must return
// before any messages are sent to the WebView.
webViewMessageLoop = WindowsWebViewJNI.newMessageLoop();
// Notify the outer thread that the message loop is ready.
synchronized (webViewUILock)
{
webViewUILock.notify();
}
// Process messages in native code until the message loop
// is terminated.
WindowsWebViewJNI.runMessageLoop(webViewMessageloop);
}
};
webViewUI.start();
// Wait for the newly started thread to create the message loop. We cannot
// safely use the WebView until the message loop has been initialized.
while (webViewMessageLoop == 0)
{
try
{
webViewUILock.wait();
}
catch (InterruptedException ignored)
{
}
}
| Constructor and Description |
|---|
WindowsWebViewJNI() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addWindowUpdateObserver(long webViewWindowPtr,
long observerPtr)
Add an observer that will be notified when the rendered contents of the WebView change (due to animation, user
input, etc)
|
static Dimension |
getContentSize(long webViewWindowPtr)
Get the size of the scrollable WebView content.
|
static String |
getContentURL(long webViewWindowPtr)
Get the URL of the page currently loaded in the WebView.
|
static AVList[] |
getLinks(long webViewWindowPtr) |
static Dimension |
getMinContentSize(long webViewWindowPtr)
Get minimum size of the WebView content.
|
static long |
getUpdateTime(long webViewWindowPtr)
Get the time at which the WebView rendered contents last changed.
|
static void |
goBack(long webViewWindowPtr)
Navigate a WebView window to the previous page in the navigation history.
|
static void |
goForward(long webViewWindowPtr)
Navigate a WebView window to the next page in the navigation history.
|
protected static void |
initialize()
Initialize the native library.
|
static void |
loadDisplayInGLTexture(long webViewWindowPtr,
int target)
Load the captured WebView image into an OpenGL texture.
|
static long |
newMessageLoop()
Create a new native message loop.
|
static long |
newNotificationAdapter(PropertyChangeListener listener)
Create a new notification adapter to bridge changes in the native WebView to PropertyChangeEvents.
|
static long |
newWebViewWindow(long messageLoop)
Create a new WebView window.
|
static void |
releaseComObject(long unknownPtr)
Release a COM object.
|
static void |
releaseMessageLoop(long messageLoop)
Release a previously allocated message loop.
|
static void |
releaseWebView(long webViewWindowPtr)
Release a WebView window.
|
static void |
removeWindowUpdateObserver(long webViewWindowPtr,
long observerPtr)
Remove an update observer from a WebView.
|
static void |
runMessageLoop(long messageLoop)
Run a native message loop.
|
static void |
sendEvent(long webViewWindowPtr,
InputEvent event)
Send an input event to a WebView window.
|
static void |
setActive(long webViewWindowPtr,
boolean active)
Set a WebViewWindow to be active or inactive.
|
static void |
setBackgroundColor(long webViewWindowPtr,
String colorString)
Set the background color the WebView.
|
static void |
setFrameSize(long webViewWindowPtr,
int width,
int height)
Set the size of a WebView window.
|
static void |
setHTMLString(long webViewWindowPtr,
String htmlString,
String baseUrlString)
Set the HTML content of a WebView, with a base URL.
|
static void |
setHTMLStringWithResourceResolver(long webViewWindowPtr,
String htmlString,
WebResourceResolver resolver)
Set the HTML content of a WebView, with a
WebResourceResolver to resolve local references. |
static void |
setMinContentSize(long webViewWindowPtr,
int width,
int height)
Specifies the minimum size of the WebView content.
|
public static void addWindowUpdateObserver(long webViewWindowPtr,
long observerPtr)
webViewWindowPtr - pointer to native WebView to observeobserverPtr - notification adapter allocated by newNotificationAdapter(java.beans.PropertyChangeListener)public static Dimension getContentSize(long webViewWindowPtr)
webViewWindowPtr - pointer to native WebView.public static String getContentURL(long webViewWindowPtr)
webViewWindowPtr - pointer to native WebView.public static AVList[] getLinks(long webViewWindowPtr)
public static Dimension getMinContentSize(long webViewWindowPtr)
webViewWindowPtr - pointer to native WebView.public static long getUpdateTime(long webViewWindowPtr)
webViewWindowPtr - pointer to native WebViewpublic static void goBack(long webViewWindowPtr)
webViewWindowPtr - pointer to native WebView.public static void goForward(long webViewWindowPtr)
webViewWindowPtr - WebView window to navigate.protected static void initialize()
public static void loadDisplayInGLTexture(long webViewWindowPtr,
int target)
webViewWindowPtr - pointer to native WebView to load into texturetarget - GL texture identifierpublic static long newMessageLoop()
public static long newNotificationAdapter(PropertyChangeListener listener)
listener - listener that will receive PropertyChangeEvents caused by changes in the native WebViewreleaseComObject.releaseComObject(long)public static long newWebViewWindow(long messageLoop)
messageLoop - message loop that will handle events for the window.public static void releaseComObject(long unknownPtr)
unknownPtr - pointer to object to releasepublic static void releaseMessageLoop(long messageLoop)
messageLoop - identifier of the message loop to release.newMessageLoop()public static void releaseWebView(long webViewWindowPtr)
webViewWindowPtr - pointer to the window to release.public static void removeWindowUpdateObserver(long webViewWindowPtr,
long observerPtr)
webViewWindowPtr - pointer to native WebView from which to remove observerobserverPtr - observer to removepublic static void runMessageLoop(long messageLoop)
messageLoop - Identifier for the message loop. This value is returned by newMessageLoop().public static void sendEvent(long webViewWindowPtr,
InputEvent event)
webViewWindowPtr - window to send input to.event - input event to send.public static void setActive(long webViewWindowPtr,
boolean active)
webViewWindowPtr - window to set active or inactive.active - true if the window is being activated. false if the window is being
deactivated.public static void setBackgroundColor(long webViewWindowPtr,
String colorString)
webViewWindowPtr - WebView window to set color ofcolorString - Color expressed as a string. Color strings must follow the format defined by the HTML
specification.public static void setFrameSize(long webViewWindowPtr,
int width,
int height)
webViewWindowPtr - window to set size ofwidth - new widthheight - new heightpublic static void setHTMLString(long webViewWindowPtr,
String htmlString,
String baseUrlString)
webViewWindowPtr - WebView window to set content ofhtmlString - new HTML contentbaseUrlString - base URL against which to resolve relative linkspublic static void setHTMLStringWithResourceResolver(long webViewWindowPtr,
String htmlString,
WebResourceResolver resolver)
WebResourceResolver to resolve local references.webViewWindowPtr - WebView window to set content ofhtmlString - new HTML contentresolver - WebResourceResolver that will resolve local references in the HTML content.public static void setMinContentSize(long webViewWindowPtr,
int width,
int height)
webViewWindowPtr - pointer to native WebView.width - minimum width, in pixels.height - minimum height, in pixels.