Class WebView
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
WebKitWebView
is the central class of the WPE WebKit and WebKitGTK
APIs. It is responsible for managing the drawing of the content and
forwarding of events. You can load any URI into the WebKitWebView
or
a data string. With WebKitSettings
you can control various aspects
of the rendering and loading of the content.
Note that in WebKitGTK, WebKitWebView
is scrollable by itself, so
you don't need to embed it in a GtkScrolledWindow
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theAuthenticateCallback
callback.static class
WebView.Builder<B extends WebView.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCloseCallback
callback.static interface
Functional interface declaration of theContextMenuCallback
callback.static interface
Functional interface declaration of theContextMenuDismissedCallback
callback.static interface
Functional interface declaration of theCreateCallback
callback.static interface
Functional interface declaration of theDecidePolicyCallback
callback.static interface
Functional interface declaration of theEnterFullscreenCallback
callback.static interface
Deprecated.static interface
Functional interface declaration of theLeaveFullscreenCallback
callback.static interface
Functional interface declaration of theLoadChangedCallback
callback.static interface
Functional interface declaration of theLoadFailedCallback
callback.static interface
Functional interface declaration of theLoadFailedWithTlsErrorsCallback
callback.static interface
Functional interface declaration of theMouseTargetChangedCallback
callback.static interface
Functional interface declaration of thePermissionRequestCallback
callback.static interface
Functional interface declaration of thePrintCallback
callback.static interface
Functional interface declaration of theQueryPermissionStateCallback
callback.static interface
Functional interface declaration of theReadyToShowCallback
callback.static interface
Functional interface declaration of theResourceLoadStartedCallback
callback.static interface
Functional interface declaration of theRunAsModalCallback
callback.static interface
Functional interface declaration of theRunColorChooserCallback
callback.static interface
Functional interface declaration of theRunFileChooserCallback
callback.static interface
Functional interface declaration of theScriptDialogCallback
callback.static interface
Functional interface declaration of theShowNotificationCallback
callback.static interface
Functional interface declaration of theShowOptionMenuCallback
callback.static interface
Functional interface declaration of theSubmitFormCallback
callback.static interface
Functional interface declaration of theUserMessageReceivedCallback
callback.static interface
Functional interface declaration of theWebProcessTerminatedCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.webkit.WebViewBase
WebViewBase.WebViewBaseClass
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
-
Constructor Summary
ConstructorDescriptionWebView()
Creates a newWebKitWebView
with the defaultWebKitWebContext
.WebView
(MemorySegment address) Create a WebView proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected WebView
asParent()
Returns this instance as if it were its parent type.protected boolean
authenticate
(AuthenticationRequest request) static WebView.Builder
<? extends WebView.Builder> builder()
AWebView.Builder
object constructs aWebView
with the specified properties.void
callAsyncJavascriptFunction
(String body, long length, @Nullable Variant arguments, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously callbody
witharguments
in the script world with nameworldName
of the main frame current context in this WebView.Finish an asynchronous operation started with webkit_web_view_call_async_javascript_function().void
canExecuteEditingCommand
(String command, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously check if it is possible to execute the given editing command.boolean
Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command().boolean
Determines whether this WebView has a previous history item.boolean
Determines whether this WebView has a next history item.boolean
canShowMimeType
(String mimeType) Whether or not a MIME type can be displayed in this WebView.protected void
close()
protected boolean
contextMenu
(ContextMenu contextMenu, HitTestResult hitTestResult) protected void
protected Widget
create
(NavigationAction navigationAction) protected boolean
decidePolicy
(PolicyDecision decision, PolicyDecisionType type) downloadUri
(String uri) Requests downloading of the specified URI string for this WebView.boolean
emitAuthenticate
(AuthenticationRequest request) Emits the "authenticate" signal.void
Emits the "close" signal.boolean
emitContextMenu
(ContextMenu contextMenu, HitTestResult hitTestResult) Emits the "context-menu" signal.void
Emits the "context-menu-dismissed" signal.emitCreate
(NavigationAction navigationAction) Emits the "create" signal.boolean
emitDecidePolicy
(PolicyDecision decision, PolicyDecisionType decisionType) Emits the "decide-policy" signal.boolean
Emits the "enter-fullscreen" signal.void
Deprecated.boolean
Emits the "leave-fullscreen" signal.void
emitLoadChanged
(LoadEvent loadEvent) Emits the "load-changed" signal.boolean
emitLoadFailed
(LoadEvent loadEvent, String failingUri, GError error) Emits the "load-failed" signal.boolean
emitLoadFailedWithTlsErrors
(String failingUri, TlsCertificate certificate, Set<TlsCertificateFlags> errors) Emits the "load-failed-with-tls-errors" signal.void
emitMouseTargetChanged
(HitTestResult hitTestResult, int modifiers) Emits the "mouse-target-changed" signal.boolean
emitPermissionRequest
(PermissionRequest request) Emits the "permission-request" signal.boolean
emitPrint
(PrintOperation printOperation) Emits the "print" signal.boolean
Emits the "query-permission-state" signal.void
Emits the "ready-to-show" signal.void
emitResourceLoadStarted
(WebResource resource, URIRequest request) Emits the "resource-load-started" signal.void
Emits the "run-as-modal" signal.boolean
emitRunColorChooser
(ColorChooserRequest request) Emits the "run-color-chooser" signal.boolean
emitRunFileChooser
(FileChooserRequest request) Emits the "run-file-chooser" signal.boolean
emitScriptDialog
(ScriptDialog dialog) Emits the "script-dialog" signal.boolean
emitShowNotification
(Notification notification) Emits the "show-notification" signal.boolean
emitShowOptionMenu
(OptionMenu menu, Rectangle rectangle) Emits the "show-option-menu" signal.void
emitSubmitForm
(FormSubmissionRequest request) Emits the "submit-form" signal.boolean
emitUserMessageReceived
(UserMessage message) Emits the "user-message-received" signal.void
Emits the "web-process-terminated" signal.protected boolean
void
evaluateJavascript
(String script, long length, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously evaluatescript
in the script world with nameworldName
of the main frame current context in this WebView.evaluateJavascriptFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_evaluate_javascript().void
executeEditingCommand
(String command) Request to execute the givencommand
for this WebView.void
executeEditingCommandWithArgument
(String command, String argument) Request to execute the givencommand
withargument
for this WebView.Get the presentation type ofWebKitWebView
when created for automation.Obtains theWebKitBackForwardList
associated with the givenWebKitWebView
.void
getBackgroundColor
(RGBA rgba) Gets the color that is used to draw the this WebView background.Get the camera capture state of aWebKitWebView
.Gets the web context of this WebView.Returns the current custom character encoding name of this WebView.Gets the configured default Content-Security-Policy.Get the display capture state of aWebKitWebView
.Gets the web editor state of this WebView.double
Gets the value of theWebKitWebView
:estimated-load-progress property.Returns favicon currently associated to this WebView.Gets theWebKitFindController
.Get theWebKitInputMethodContext
currently in use by this WebView.Get theWebKitWebInspector
associated to this WebViewboolean
Gets the mute state of this WebView.boolean
Get whether the current web process of aWebKitWebView
is responsive.Return the main resource of this WebView.static MemoryLayout
The memory layout of the native struct.Get the microphone capture state of aWebKitWebView
.Get theWebKitNetworkSession
associated to this WebView.long
Get the identifier of theWebKitWebPage
corresponding to theWebKitWebView
Gets the current session state of this WebViewvoid
getSnapshot
(SnapshotRegion region, Set<SnapshotOptions> options, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion
.void
getSnapshot
(SnapshotRegion region, SnapshotOptions options, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion
.getSnapshotFinish
(AsyncResult result) Finishes an asynchronous operation started with webkit_web_view_get_snapshot().getTitle()
Gets the value of theWebKitWebView
:title property.boolean
getTlsInfo
(Out<TlsCertificate> certificate, Out<Set<TlsCertificateFlags>> errors) Retrieves theGTlsCertificate
associated with the main resource of this WebView.static Type
getType()
Get the GType of the WebView classgetUri()
Returns the current active URI of this WebView.Gets the user content manager associated to this WebView.Get the view'sWebKitWebExtensionMode
.Gets the default website policies.Gets theWebKitSettings
currently applied to this WebView.Get theWebKitWindowProperties
object.double
Set the zoom level of this WebView.void
goBack()
Loads the previous history item.void
Loads the next history item.void
goToBackForwardListItem
(BackForwardListItem listItem) Loads the specific history itemlistItem
.protected void
boolean
Get whether aWebKitWebView
was created withWebKitWebView
:is-controlled-by-automation property enabled.boolean
Gets whether the user is allowed to edit the HTML document.boolean
Gets the value of theWebKitWebView
:is-loading property.boolean
Gets the value of theWebKitWebView
:is-playing-audio property.protected boolean
void
loadAlternateHtml
(String content, String contentUri, @Nullable String baseUri) Load the givencontent
string for the URIcontentUri
.void
loadBytes
(Bytes bytes, @Nullable String mimeType, @Nullable String encoding, @Nullable String baseUri) Load the specifiedbytes
into this WebView using the givenmimeType
andencoding
.protected void
loadChanged
(LoadEvent loadEvent) protected boolean
loadFailed
(LoadEvent loadEvent, String failingUri, GError error) protected boolean
loadFailedWithTlsErrors
(String failingUri, TlsCertificate certificate, Set<TlsCertificateFlags> errors) void
Load the givencontent
string with the specifiedbaseUri
.void
loadPlainText
(String plainText) Load the specifiedplainText
string into this WebView.void
loadRequest
(URIRequest request) Requests loading of the specifiedWebKitURIRequest
.void
Requests loading of the specified URI string.protected void
mouseTargetChanged
(HitTestResult hitTestResult, int modifiers) This signal is emitted when the user is challenged with HTTP authentication.onClose
(WebView.CloseCallback handler) Emitted when closing aWebKitWebView
is requested.onContextMenu
(WebView.ContextMenuCallback handler) Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu.Emitted afterWebKitWebView
::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.onCreate
(WebView.CreateCallback handler) Emitted when the creation of a newWebKitWebView
is requested.This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource.Emitted when JavaScript code calls <function>element.webkitRequestFullScreen</function>.Deprecated.Emitted when theWebKitWebView
is about to restore its top level window out of its full screen state.onLoadChanged
(WebView.LoadChangedCallback handler) Emitted when a load operation inwebView
changes.onLoadFailed
(WebView.LoadFailedCallback handler) Emitted when an error occurs during a load operation.Emitted when a TLS error occurs during a load operation.This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element.This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.onPrint
(WebView.PrintCallback handler) Emitted when printing is requested onwebView
, usually by a JavaScript call, before the print dialog is shown.This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification.onReadyToShow
(WebView.ReadyToShowCallback handler) Emitted afterWebKitWebView
::create on the newly createdWebKitWebView
when it should be displayed to the user.Emitted when a new resource is going to be loaded.onRunAsModal
(WebView.RunAsModalCallback handler) Emitted afterWebKitWebView
::ready-to-show on the newly createdWebKitWebView
when JavaScript code calls <function>window.showModalDialog</function>.This signal is emitted when the user interacts with a <input type='color' /> HTML element, requesting from WebKit to show a dialog to select a color.This signal is emitted when the user interacts with a <input type='file' /> HTML element, requesting from WebKit to show a dialog to select one or more files to be uploaded.Emitted when JavaScript code calls <function>window.alert</function>, <function>window.confirm</function> or <function>window.prompt</function>, or when <function>onbeforeunload</function> event is fired.This signal is emitted when a notification should be presented to the user.This signal is emitted when a select element inwebView
needs to display a dropdown menu.onSubmitForm
(WebView.SubmitFormCallback handler) This signal is emitted when a form is about to be submitted.This signal is emitted when aWebKitUserMessage
is received from theWebKitWebPage
corresponding towebView
.This signal is emitted when the web process terminates abnormally due toreason
.protected boolean
permissionRequest
(PermissionRequest permissionRequest) protected boolean
print
(PrintOperation printOperation) protected boolean
protected void
void
reload()
Reloads the current contents of this WebView.void
Reloads the current contents of this WebView without using any cached data.protected void
resourceLoadStarted
(WebResource resource, URIRequest request) void
Restore the this WebView session state fromstate
protected void
protected boolean
runColorChooser
(ColorChooserRequest request) protected boolean
runFileChooser
(FileChooserRequest request) void
save
(SaveMode saveMode, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.saveFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_save().void
saveToFile
(File file, SaveMode saveMode, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.boolean
saveToFileFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_save_to_file().protected boolean
scriptDialog
(ScriptDialog dialog) void
sendMessageToPage
(UserMessage message, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Sendmessage
to theWebKitWebPage
corresponding to this WebView.sendMessageToPageFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_send_message_to_page().void
setBackgroundColor
(RGBA rgba) Sets the color that will be used to draw the this WebView background.void
Set the camera capture state of aWebKitWebView
.void
setCorsAllowlist
(@Nullable String[] allowlist) Sets theallowlist
for CORS.void
setCustomCharset
(@Nullable String charset) Sets the current custom character encoding override of this WebView.void
Set the display capture state of aWebKitWebView
.void
setEditable
(boolean editable) Sets whether the user is allowed to edit the HTML document.void
setInputMethodContext
(@Nullable InputMethodContext context) Set theWebKitInputMethodContext
to be used by this WebView.void
setIsMuted
(boolean muted) Sets the mute state of this WebView.void
Set the microphone capture state of aWebKitWebView
.void
setSettings
(Settings settings) Sets theWebKitSettings
to be applied to this WebView.void
setZoomLevel
(double zoomLevel) Set the zoom level of this WebView.protected boolean
showNotification
(Notification notification) protected boolean
showOptionMenu
(OptionMenu menu, Rectangle rectangle) void
Stops any ongoing loading operation in this WebView.protected void
submitForm
(FormSubmissionRequest request) void
Terminates the web process associated to this WebView.void
tryClose()
Tries to close the this WebView.protected boolean
userMessageReceived
(UserMessage message) protected boolean
protected void
Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
WebView
Create a WebView proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
WebView
Creates a newWebKitWebView
with the defaultWebKitWebContext
.Creates a new
WebKitWebView
with the defaultWebKitWebContext
and noWebKitUserContentManager
associated with it. See also webkit_web_view_new_with_context(), webkit_web_view_new_with_user_content_manager(), and webkit_web_view_new_with_settings().- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type.- Overrides:
asParent
in classWebViewBase
-
callAsyncJavascriptFunction
public void callAsyncJavascriptFunction(String body, long length, @Nullable @Nullable Variant arguments, @Nullable @Nullable String worldName, @Nullable @Nullable String sourceUri, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously callbody
witharguments
in the script world with nameworldName
of the main frame current context in this WebView. Thearguments
values must be one of the following types, or contain only the following GVariant types: number, string and dictionary. The result of the operation can be a Promise that will be properly passed to the callback. IfworldName
isnull
, the default world is used. Any value that is notnull
is a distin ct world. ThesourceUri
will be shown in exceptions and doesn't affect the behavior of the script. When not provided, the document URL is used.Note that if
WebKitSettings
:enable-javascript isfalse
, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKitSettings
:enable-javascript-markup.When the operation is finished,
callback
will be called. You can then call webkit_web_view_call_async_javascript_function_finish() to get the result of the operation.This is an example that shows how to pass arguments to a JS function that returns a Promise that resolves with the passed argument:
static void web_view_javascript_finished (GObject *object, GAsyncResult *result, gpointer user_data) { JSCValue *value; GError *error = NULL; value = webkit_web_view_call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning ("Error running javascript: %s", error->message); g_error_free (error); return; } if (jsc_value_is_number (value)) { gint32 int_value = jsc_value_to_string (value); JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value)); if (exception) g_warning ("Error running javascript: %s", jsc_exception_get_message (exception)); else g_print ("Script result: %d\\n", int_value); g_free (str_value); } else { g_warning ("Error running javascript: unexpected return value"); } g_object_unref (value); } static void web_view_evaluate_promise (WebKitWebView *web_view) { GVariantDict dict; g_variant_dict_init (&dict, NULL); g_variant_dict_insert (&dict, "count", "u", 42); GVariant *args = g_variant_dict_end (&dict); const gchar *body = "return new Promise((resolve) => { resolve(count); });"; webkit_web_view_call_async_javascript_function (web_view, body, -1, arguments, NULL, NULL, NULL, web_view_javascript_finished, NULL); }
- Parameters:
body
- the function bodylength
- length ofbody
, or -1 ifbody
is a nul-terminated stringarguments
- aGVariant
with formata{sv}
storing the function arguments, ornull
worldName
- the name of aWebKitScriptWorld
ornull
to use the defaultsourceUri
- the source URIcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the script finished
-
callAsyncJavascriptFunctionFinish
Finish an asynchronous operation started with webkit_web_view_call_async_javascript_function().- Parameters:
result
- aGAsyncResult
- Returns:
- a
JSCValue
with the return value of the async function ornull
in case of error - Throws:
GErrorException
- seeGError
-
canExecuteEditingCommand
public void canExecuteEditingCommand(String command, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously check if it is possible to execute the given editing command.When the operation is finished,
callback
will be called. You can then call webkit_web_view_can_execute_editing_command_finish() to get the result of the operation.- Parameters:
command
- the command to checkcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
canExecuteEditingCommandFinish
Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command().- Parameters:
result
- aGAsyncResult
- Returns:
true
if the editing command can be executed orfalse
otherwise- Throws:
GErrorException
- seeGError
-
canGoBack
public boolean canGoBack()Determines whether this WebView has a previous history item.- Returns:
true
if able to move back orfalse
otherwise.
-
canGoForward
public boolean canGoForward()Determines whether this WebView has a next history item.- Returns:
true
if able to move forward orfalse
otherwise.
-
canShowMimeType
Whether or not a MIME type can be displayed in this WebView.- Parameters:
mimeType
- a MIME type- Returns:
true
if the MIME typemimeType
can be displayed orfalse
otherwise
-
downloadUri
-
evaluateJavascript
public void evaluateJavascript(String script, long length, @Nullable @Nullable String worldName, @Nullable @Nullable String sourceUri, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously evaluatescript
in the script world with nameworldName
of the main frame current context in this WebView. IfworldName
isnull
, the default world is used. Any value that is notnull
is a distinct world. ThesourceUri
will be shown in exceptions and doesn't affect the behavior of the script. When not provided, the document URL is used.Note that if
WebKitSettings
:enable-javascript isfalse
, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKitSettings
:enable-javascript-markup.When the operation is finished,
callback
will be called. You can then call webkit_web_view_evaluate_javascript_finish() to get the result of the operation.This is an example of using webkit_web_view_evaluate_javascript() with a script returning a string:
static void web_view_javascript_finished (GObject *object, GAsyncResult *result, gpointer user_data) { JSCValue *value; GError *error = NULL; value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning ("Error running javascript: %s", error->message); g_error_free (error); return; } if (jsc_value_is_string (value)) { gchar *str_value = jsc_value_to_string (value); JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value)); if (exception) g_warning ("Error running javascript: %s", jsc_exception_get_message (exception)); else g_print ("Script result: %s\\n", str_value); g_free (str_value); } else { g_warning ("Error running javascript: unexpected return value"); } g_object_unref (value); } static void web_view_get_link_url (WebKitWebView *web_view, const gchar *link_id) { gchar *script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id); webkit_web_view_evaluate_javascript (web_view, script, -1, NULL, NULL, NULL, web_view_javascript_finished, NULL); g_free (script); }
- Parameters:
script
- the script to evaluatelength
- length ofscript
, or -1 ifscript
is a nul-terminated stringworldName
- the name of aWebKitScriptWorld
ornull
to use the defaultsourceUri
- the source URIcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the script finished
-
evaluateJavascriptFinish
Finish an asynchronous operation started with webkit_web_view_evaluate_javascript().- Parameters:
result
- aGAsyncResult
- Returns:
- a
JSCValue
with the result of the last executed statement in script ornull
in case of error - Throws:
GErrorException
- seeGError
-
executeEditingCommand
Request to execute the givencommand
for this WebView.You can use webkit_web_view_can_execute_editing_command() to check whether it's possible to execute the command.
- Parameters:
command
- the command to execute
-
executeEditingCommandWithArgument
Request to execute the givencommand
withargument
for this WebView.You can use webkit_web_view_can_execute_editing_command() to check whether it's possible to execute the command.
- Parameters:
command
- the command to executeargument
- the command argument
-
getAutomationPresentationType
Get the presentation type ofWebKitWebView
when created for automation.- Returns:
- a
WebKitAutomationBrowsingContextPresentation
.
-
getBackForwardList
Obtains theWebKitBackForwardList
associated with the givenWebKitWebView
.The
WebKitBackForwardList
is owned by theWebKitWebView
.- Returns:
- the
WebKitBackForwardList
-
getBackgroundColor
Gets the color that is used to draw the this WebView background.Gets the color that is used to draw the this WebView background before the actual contents are rendered. For more information see also webkit_web_view_set_background_color()
- Parameters:
rgba
- aGdkRGBA
to fill in with the background color
-
getCameraCaptureState
Get the camera capture state of aWebKitWebView
.- Returns:
- The
WebKitMediaCaptureState
of the camera device. IfWebKitSettings
:enable-mediastream isfalse
, this method will returnMediaCaptureState.NONE
.
-
getContext
Gets the web context of this WebView.- Returns:
- the
WebKitWebContext
of the view
-
getCustomCharset
Returns the current custom character encoding name of this WebView.- Returns:
- the current custom character encoding name or
null
if no custom character encoding has been set.
-
getDefaultContentSecurityPolicy
Gets the configured default Content-Security-Policy.- Returns:
- The default policy or
null
-
getDisplayCaptureState
Get the display capture state of aWebKitWebView
.- Returns:
- The
WebKitMediaCaptureState
of the display device. IfWebKitSettings
:enable-mediastream isfalse
, this method will returnMediaCaptureState.NONE
.
-
getEditorState
Gets the web editor state of this WebView.- Returns:
- the
WebKitEditorState
of the view
-
getEstimatedLoadProgress
public double getEstimatedLoadProgress()Gets the value of theWebKitWebView
:estimated-load-progress property.You can monitor the estimated progress of a load operation by connecting to the notify::estimated-load-progress signal of this WebView.
- Returns:
- an estimate of the of the percent complete for a document load as a range from 0.0 to 1.0.
-
getFavicon
Returns favicon currently associated to this WebView.Returns favicon currently associated to this WebView, if any. You can connect to notify::favicon signal of this WebView to be notified when the favicon is available.
- Returns:
- the favicon image or
null
if there's no icon associated with this WebView.
-
getFindController
Gets theWebKitFindController
.Gets the
WebKitFindController
that will allow the caller to query theWebKitWebView
for the text to look for.- Returns:
- the
WebKitFindController
associated to this particularWebKitWebView
.
-
getInputMethodContext
Get theWebKitInputMethodContext
currently in use by this WebView.Get the
WebKitInputMethodContext
currently in use by this WebView, ornull
if no input method is being used.- Returns:
- a
WebKitInputMethodContext
, ornull
-
getInspector
Get theWebKitWebInspector
associated to this WebView- Returns:
- the
WebKitWebInspector
of this WebView
-
getIsMuted
public boolean getIsMuted()Gets the mute state of this WebView.- Returns:
true
if this WebView audio is muted orfalse
is audio is not muted.
-
getIsWebProcessResponsive
public boolean getIsWebProcessResponsive()Get whether the current web process of aWebKitWebView
is responsive.- Returns:
true
if the web process attached to this WebView is responsive, orfalse
otherwise.
-
getMainResource
Return the main resource of this WebView.- Returns:
- the main
WebKitWebResource
of the view ornull
if nothing has been loaded.
-
getMicrophoneCaptureState
Get the microphone capture state of aWebKitWebView
.- Returns:
- The
WebKitMediaCaptureState
of the microphone device. IfWebKitSettings
:enable-mediastream isfalse
, this method will returnMediaCaptureState.NONE
.
-
getNetworkSession
Get theWebKitNetworkSession
associated to this WebView.- Returns:
- a
WebKitNetworkSession
-
getPageId
public long getPageId()Get the identifier of theWebKitWebPage
corresponding to theWebKitWebView
- Returns:
- the page ID of this WebView.
-
getSessionState
Gets the current session state of this WebView- Returns:
- a
WebKitWebViewSessionState
-
getWebViewSettings
Gets theWebKitSettings
currently applied to this WebView.If no other
WebKitSettings
have been explicitly applied to this WebView with webkit_web_view_set_settings(), the defaultWebKitSettings
will be returned. This method always returns a validWebKitSettings
object. To modify any of the this WebView settings, you can either create a newWebKitSettings
object with webkit_settings_new(), setting the desired preferences, and then replace the existing this WebView settings with webkit_web_view_set_settings() or get the existing this WebView settings and update it directly.WebKitSettings
objects can be shared by multipleWebKitWebView
<!-- -->s, so modifying the settings of aWebKitWebView
would affect otherWebKitWebView
<!-- -->s using the sameWebKitSettings
.- Returns:
- the
WebKitSettings
attached to this WebView
-
getSnapshot
public void getSnapshot(SnapshotRegion region, Set<SnapshotOptions> options, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion
.options
specifies how the snapshot should be rendered.When the operation is finished,
callback
will be called. You must call webkit_web_view_get_snapshot_finish() to get the result of the operation.- Parameters:
region
- theWebKitSnapshotRegion
for this snapshotoptions
-WebKitSnapshotOptions
for the snapshotcancellable
- aGCancellable
callback
- aGAsyncReadyCallback
-
getSnapshot
public void getSnapshot(SnapshotRegion region, SnapshotOptions options, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion
.options
specifies how the snapshot should be rendered.When the operation is finished,
callback
will be called. You must call webkit_web_view_get_snapshot_finish() to get the result of the operation.- Parameters:
region
- theWebKitSnapshotRegion
for this snapshotoptions
-WebKitSnapshotOptions
for the snapshotcancellable
- aGCancellable
callback
- aGAsyncReadyCallback
-
getSnapshotFinish
Finishes an asynchronous operation started with webkit_web_view_get_snapshot().- Parameters:
result
- aGAsyncResult
- Returns:
- an image with the retrieved snapshot, or
null
in case of error. - Throws:
GErrorException
- seeGError
-
getTitle
Gets the value of theWebKitWebView
:title property.You can connect to notify::title signal of this WebView to be notified when the title has been received.
- Returns:
- The main frame document title of this WebView.
-
getTlsInfo
Retrieves theGTlsCertificate
associated with the main resource of this WebView.Retrieves the
GTlsCertificate
associated with the main resource of this WebView, and theGTlsCertificateFlags
showing what problems, if any, have been found with that certificate. If the connection is not HTTPS, this function returnsfalse
. This function should be called after a response has been received from the server, so you can connect toWebKitWebView
::load-changed and call this function when it's emitted withLoadEvent.COMMITTED
event.Note that this function provides no information about the security of the web page if the current
WebKitTLSErrorsPolicy
isTLSErrorsPolicy.IGNORE
, as subresources of the page may be controlled by an attacker. This function may safely be used to determine the security status of the current page only if the currentWebKitTLSErrorsPolicy
isTLSErrorsPolicy.FAIL
, in which case subresources that fail certificate verification will be blocked.- Parameters:
certificate
- return location for aGTlsCertificate
errors
- return location for aGTlsCertificateFlags
the verification status ofcertificate
- Returns:
true
if the this WebView connection uses HTTPS and a response has been received from the server, orfalse
otherwise.
-
getUri
Returns the current active URI of this WebView.The active URI might change during a load operation:
<orderedlist> <listitem><para> When nothing has been loaded yet on this WebView the active URI is
null
. </para></listitem> <listitem><para> When a new load operation starts the active URI is the requested URI: <itemizedlist> <listitem><para> If the load operation was started by webkit_web_view_load_uri(), the requested URI is the given one. </para></listitem> <listitem><para> If the load operation was started by webkit_web_view_load_html(), the requested URI is "about:blank". </para></listitem> <listitem><para> If the load operation was started by webkit_web_view_load_alternate_html(), the requested URI is content URI provided. </para></listitem> <listitem><para> If the load operation was started by webkit_web_view_go_back() or webkit_web_view_go_forward(), the requested URI is the original URI of the previous/next item in theWebKitBackForwardList
of this WebView. </para></listitem> <listitem><para> If the load operation was started by webkit_web_view_go_to_back_forward_list_item(), the requested URI is the opriginal URI of the givenWebKitBackForwardListItem
. </para></listitem> </itemizedlist> </para></listitem> <listitem><para> If there is a server redirection during the load operation, the active URI is the redirected URI. When the signalWebKitWebView
::load-changed is emitted withLoadEvent.REDIRECTED
event, the active URI is already updated to the redirected URI. </para></listitem> <listitem><para> When the signalWebKitWebView
::load-changed is emitted withLoadEvent.COMMITTED
event, the active URI is the final one and it will not change unless a new load operation is started or a navigation action within the same page is performed. </para></listitem> </orderedlist>You can monitor the active URI by connecting to the notify::uri signal of this WebView.
- Returns:
- the current active URI of this WebView or
null
if nothing has been loaded yet.
-
getUserContentManager
Gets the user content manager associated to this WebView.- Returns:
- the
WebKitUserContentManager
associated with the view
-
getWebExtensionMode
Get the view'sWebKitWebExtensionMode
.- Returns:
- the
WebKitWebExtensionMode
-
getWebsitePolicies
Gets the default website policies.Gets the default website policies set on construction in the this WebView. These can be overridden on a per-origin basis via the
WebKitWebView
::decide-policy signal handler.See also webkit_policy_decision_use_with_policies().
- Returns:
- the default
WebKitWebsitePolicies
associated with the view.
-
getWindowProperties
Get theWebKitWindowProperties
object.Get the
WebKitWindowProperties
object containing the properties that the window containing this WebView should have.- Returns:
- the
WebKitWindowProperties
of this WebView
-
getZoomLevel
public double getZoomLevel()Set the zoom level of this WebView.Get the zoom level of this WebView, i.e. the factor by which the view contents are scaled with respect to their original size.
- Returns:
- the current zoom level of this WebView
-
goBack
public void goBack()Loads the previous history item.You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal. -
goForward
public void goForward()Loads the next history item.You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal. -
goToBackForwardListItem
Loads the specific history itemlistItem
.You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal.- Parameters:
listItem
- aWebKitBackForwardListItem
-
isControlledByAutomation
public boolean isControlledByAutomation()Get whether aWebKitWebView
was created withWebKitWebView
:is-controlled-by-automation property enabled.Only
WebKitWebView
<!-- -->s controlled by automation can be used in an automation session.- Returns:
true
if this WebView is controlled by automation, orfalse
otherwise.
-
isEditable
public boolean isEditable()Gets whether the user is allowed to edit the HTML document.When this WebView is not editable an element in the HTML document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default a
WebKitWebView
is not editable.- Returns:
true
if the user is allowed to edit the HTML document, orfalse
otherwise.
-
isLoading
public boolean isLoading()Gets the value of theWebKitWebView
:is-loading property.You can monitor when a
WebKitWebView
is loading a page by connecting to notify::is-loading signal of this WebView. This is useful when you are interesting in knowing when the view is loading something but not in the details about the status of the load operation, for example to start a spinner when the view is loading a page and stop it when it finishes.- Returns:
true
if this WebView is loading a page orfalse
otherwise.
-
isPlayingAudio
public boolean isPlayingAudio()Gets the value of theWebKitWebView
:is-playing-audio property.You can monitor when a page in a
WebKitWebView
is playing audio by connecting to the notify::is-playing-audio signal of this WebView. This is useful when the application wants to provide visual feedback when a page is producing sound.- Returns:
true
if a page in this WebView is playing audio orfalse
otherwise.
-
loadAlternateHtml
public void loadAlternateHtml(String content, String contentUri, @Nullable @Nullable String baseUri) Load the givencontent
string for the URIcontentUri
.This allows clients to display page-loading errors in the
WebKitWebView
itself. When this method is called fromWebKitWebView
::load-failed signal to show an error page, then the back-forward list is maintained appropriately. For everything else this method works the same way as webkit_web_view_load_html().- Parameters:
content
- the new content to display as the main page of the this WebViewcontentUri
- the URI for the alternate page contentbaseUri
- the base URI for relative locations ornull
-
loadBytes
public void loadBytes(Bytes bytes, @Nullable @Nullable String mimeType, @Nullable @Nullable String encoding, @Nullable @Nullable String baseUri) Load the specifiedbytes
into this WebView using the givenmimeType
andencoding
.When
mimeType
isnull
, it defaults to "text/html". Whenencoding
isnull
, it defaults to "UTF-8". WhenbaseUri
isnull
, it defaults to "about:blank". You can monitor the load operation by connecting toWebKitWebView
::load-changed signal.- Parameters:
bytes
- input data to loadmimeType
- the MIME type ofbytes
, ornull
encoding
- the character encoding ofbytes
, ornull
baseUri
- the base URI for relative locations ornull
-
loadHtml
Load the givencontent
string with the specifiedbaseUri
.If
baseUri
is notnull
, relative URLs in thecontent
will be resolved againstbaseUri
and absolute local paths must be children of thebaseUri
. For security reasons absolute local paths that are not children ofbaseUri
will cause the web process to terminate. If you need to include URLs incontent
that are local paths in a different directory thanbaseUri
you can build a data URI for them. WhenbaseUri
isnull
, it defaults to "about:blank". The mime type of the document will be "text/html". You can monitor the load operation by connecting toWebKitWebView
::load-changed signal.- Parameters:
content
- The HTML string to loadbaseUri
- The base URI for relative locations ornull
-
loadPlainText
Load the specifiedplainText
string into this WebView.The mime type of document will be "text/plain". You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal.- Parameters:
plainText
- The plain text to load
-
loadRequest
Requests loading of the specifiedWebKitURIRequest
.You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal.- Parameters:
request
- aWebKitURIRequest
to load
-
loadUri
Requests loading of the specified URI string.You can monitor the load operation by connecting to
WebKitWebView
::load-changed signal.- Parameters:
uri
- an URI string
-
reload
public void reload()Reloads the current contents of this WebView.See also webkit_web_view_reload_bypass_cache().
-
reloadBypassCache
public void reloadBypassCache()Reloads the current contents of this WebView without using any cached data. -
restoreSessionState
Restore the this WebView session state fromstate
- Parameters:
state
- aWebKitWebViewSessionState
-
save
public void save(SaveMode saveMode, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.Asynchronously save the current web page associated to the
WebKitWebView
into a self-contained format using the mode specified insaveMode
.When the operation is finished,
callback
will be called. You can then call webkit_web_view_save_finish() to get the result of the operation.- Parameters:
saveMode
- theWebKitSaveMode
specifying how the web page should be saved.cancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
saveFinish
Finish an asynchronous operation started with webkit_web_view_save().- Parameters:
result
- aGAsyncResult
- Returns:
- a
GInputStream
with the result of saving the current web page ornull
in case of error. - Throws:
GErrorException
- seeGError
-
saveToFile
public void saveToFile(File file, SaveMode saveMode, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.Asynchronously save the current web page associated to the
WebKitWebView
into a self-contained format using the mode specified insaveMode
and writing it tofile
.When the operation is finished,
callback
will be called. You can then call webkit_web_view_save_to_file_finish() to get the result of the operation.- Parameters:
file
- theGFile
where the current web page should be saved to.saveMode
- theWebKitSaveMode
specifying how the web page should be saved.cancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
saveToFileFinish
Finish an asynchronous operation started with webkit_web_view_save_to_file().- Parameters:
result
- aGAsyncResult
- Returns:
true
if the web page was successfully saved to a file orfalse
otherwise.- Throws:
GErrorException
- seeGError
-
sendMessageToPage
public void sendMessageToPage(UserMessage message, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Sendmessage
to theWebKitWebPage
corresponding to this WebView.If
message
is floating, it's consumed. If you don't expect any reply, or you simply want to ignore it, you can passnull
ascallback
. When the operation is finished,callback
will be called. You can then call webkit_web_view_send_message_to_page_finish() to get the message reply.- Parameters:
message
- aWebKitUserMessage
cancellable
- aGCancellable
ornull
to ignorecallback
- (nullable): AGAsyncReadyCallback
to call when the request is satisfied ornull
-
sendMessageToPageFinish
Finish an asynchronous operation started with webkit_web_view_send_message_to_page().- Parameters:
result
- aGAsyncResult
- Returns:
- a
WebKitUserMessage
with the reply ornull
in case of error. - Throws:
GErrorException
- seeGError
-
setBackgroundColor
Sets the color that will be used to draw the this WebView background.Sets the color that will be used to draw the this WebView background before the actual contents are rendered. Note that if the web page loaded in this WebView specifies a background color, it will take precedence over the
rgba
color. By default the this WebView background color is opaque white.- Parameters:
rgba
- aGdkRGBA
-
setCameraCaptureState
Set the camera capture state of aWebKitWebView
.If
WebKitSettings
:enable-mediastream isfalse
, this method will have no visible effect. Once the state of the device has been set toMediaCaptureState.NONE
it cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state
- aWebKitMediaCaptureState
-
setCorsAllowlist
Sets theallowlist
for CORS.Sets the
allowlist
for which Cross-Origin Resource Sharing checks are disabled in this WebView. URI patterns must be of the form[protocol]://[host]/[path]
, each component may contain the wildcard character (*
) to represent zero or more other characters. All three components are required and must not be omitted from the URI patterns.Disabling CORS checks permits resources from other origins to load allowlisted resources. It does not permit the allowlisted resources to load resources from other origins.
If this function is called multiple times, only the allowlist set by the most recent call will be effective.
- Parameters:
allowlist
- an allowlist of URI patterns, ornull
-
setCustomCharset
Sets the current custom character encoding override of this WebView.The custom character encoding will override any text encoding detected via HTTP headers or META tags. Calling this method will stop any current load operation and reload the current page. Setting the custom character encoding to
null
removes the character encoding override.- Parameters:
charset
- a character encoding name ornull
-
setDisplayCaptureState
Set the display capture state of aWebKitWebView
.If
WebKitSettings
:enable-mediastream isfalse
, this method will have no visible effect. Once the state of the device has been set toMediaCaptureState.NONE
it cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state
- aWebKitMediaCaptureState
-
setEditable
public void setEditable(boolean editable) Sets whether the user is allowed to edit the HTML document.If
editable
istrue
, this WebView allows the user to edit the HTML document. Ifeditable
isfalse
, an element in this WebView's document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default aWebKitWebView
is not editable.Normally, a HTML document is not editable unless the elements within the document are editable. This function provides a way to make the contents of a
WebKitWebView
editable without altering the document or DOM structure.- Parameters:
editable
- agboolean
indicating the editable state
-
setInputMethodContext
Set theWebKitInputMethodContext
to be used by this WebView.Set the
WebKitInputMethodContext
to be used by this WebView, ornull
to not use any input method. Note that the sameWebKitInputMethodContext
can't be set on more than oneWebKitWebView
at the same time.- Parameters:
context
- theWebKitInputMethodContext
to set, ornull
-
setIsMuted
public void setIsMuted(boolean muted) Sets the mute state of this WebView.- Parameters:
muted
- mute flag
-
setMicrophoneCaptureState
Set the microphone capture state of aWebKitWebView
.If
WebKitSettings
:enable-mediastream isfalse
, this method will have no visible effect. Once the state of the device has been set toMediaCaptureState.NONE
it cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state
- aWebKitMediaCaptureState
-
setSettings
Sets theWebKitSettings
to be applied to this WebView.The existing
WebKitSettings
of this WebView will be replaced bysettings
. New settings are applied immediately on this WebView. The sameWebKitSettings
object can be shared by multipleWebKitWebView
<!-- -->s.- Parameters:
settings
- aWebKitSettings
-
setZoomLevel
public void setZoomLevel(double zoomLevel) Set the zoom level of this WebView.Set the zoom level of this WebView, i.e. the factor by which the view contents are scaled with respect to their original size.
- Parameters:
zoomLevel
- the zoom level
-
stopLoading
public void stopLoading()Stops any ongoing loading operation in this WebView.This method does nothing if no content is being loaded. If there is a loading operation in progress, it will be cancelled and
WebKitWebView
::load-failed signal will be emitted withNetworkError.CANCELLED
error. -
terminateWebProcess
public void terminateWebProcess()Terminates the web process associated to this WebView.When the web process gets terminated using this method, the
WebKitWebView
::web-process-terminated signal is emitted withWebProcessTerminationReason.TERMINATED_BY_API
as the reason for termination. -
tryClose
public void tryClose()Tries to close the this WebView.This will fire the onbeforeunload event to ask the user for confirmation to close the page. If there isn't an onbeforeunload event handler or the user confirms to close the page, the
WebKitWebView
::close signal is emitted, otherwise nothing happens. -
authenticate
-
close
protected void close() -
contextMenu
-
contextMenuDismissed
protected void contextMenuDismissed() -
decidePolicy
-
enterFullscreen
protected boolean enterFullscreen() -
insecureContentDetected
-
leaveFullscreen
protected boolean leaveFullscreen() -
loadChanged
-
loadFailed
-
loadFailedWithTlsErrors
protected boolean loadFailedWithTlsErrors(String failingUri, TlsCertificate certificate, Set<TlsCertificateFlags> errors) -
mouseTargetChanged
-
permissionRequest
-
print
-
queryPermissionState
-
readyToShow
protected void readyToShow() -
resourceLoadStarted
-
runAsModal
protected void runAsModal() -
runColorChooser
-
runFileChooser
-
scriptDialog
-
showNotification
-
showOptionMenu
-
submitForm
-
userMessageReceived
-
webProcessCrashed
protected boolean webProcessCrashed() -
webProcessTerminated
-
onAuthenticate
public SignalConnection<WebView.AuthenticateCallback> onAuthenticate(WebView.AuthenticateCallback handler) This signal is emitted when the user is challenged with HTTP authentication. To let the application access or supply the credentials as well as to allow the client application to either cancel the request or perform the authentication, the signal will pass an instance of theWebKitAuthenticationRequest
in therequest
argument. To handle this signal asynchronously you should keep a ref of the request and returntrue
. To disable HTTP authentication entirely, connect to this signal and simply returntrue
.The default signal handler will run a default authentication dialog asynchronously for the user to interact with.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitAuthenticate
Emits the "authenticate" signal. SeeonAuthenticate(org.gnome.webkit.WebView.AuthenticateCallback)
. -
onClose
Emitted when closing aWebKitWebView
is requested. This occurs when a call is made from JavaScript's <function>window.close</function> function or after trying to close thewebView
with webkit_web_view_try_close(). It is the owner's responsibility to handle this signal to hide or destroy theWebKitWebView
, if necessary.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitClose
public void emitClose()Emits the "close" signal. SeeonClose(org.gnome.webkit.WebView.CloseCallback)
. -
onContextMenu
public SignalConnection<WebView.ContextMenuCallback> onContextMenu(WebView.ContextMenuCallback handler) Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu. <itemizedlist> <listitem><para> To customize the proposed menu you can use webkit_context_menu_prepend(), webkit_context_menu_append() or webkit_context_menu_insert() to add newWebKitContextMenuItem
<!-- -->s tocontextMenu
, webkit_context_menu_move_item() to reorder existing items, or webkit_context_menu_remove() to remove an existing item. The signal handler should returnfalse
, and the menu represented bycontextMenu
will be shown. </para></listitem> <listitem><para> To prevent the menu from being displayed you can just connect to this signal and returntrue
so that the proposed menu will not be shown. </para></listitem> <listitem><para> To build your own menu, you can remove all items from the proposed menu with webkit_context_menu_remove_all(), add your own items and returnfalse
so that the menu will be shown. You can also ignore the proposedWebKitContextMenu
, build your ownGtkMenu
and returntrue
to prevent the proposed menu from being shown. </para></listitem> <listitem><para> If you just want the default menu to be shown always, simply don't connect to this signal because showing the proposed context menu is the default behaviour. </para></listitem> </itemizedlist>If the signal handler returns
false
the context menu represented bycontextMenu
will be shown, if it returntrue
the context menu will not be shown.The proposed
WebKitContextMenu
passed incontextMenu
argument is only valid during the signal emission.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitContextMenu
Emits the "context-menu" signal. SeeonContextMenu(org.gnome.webkit.WebView.ContextMenuCallback)
. -
onContextMenuDismissed
public SignalConnection<WebView.ContextMenuDismissedCallback> onContextMenuDismissed(WebView.ContextMenuDismissedCallback handler) Emitted afterWebKitWebView
::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitContextMenuDismissed
public void emitContextMenuDismissed()Emits the "context-menu-dismissed" signal. SeeonContextMenuDismissed(org.gnome.webkit.WebView.ContextMenuDismissedCallback)
. -
onCreate
Emitted when the creation of a newWebKitWebView
is requested. If this signal is handled the signal handler should return the newly createdWebKitWebView
.The
WebKitNavigationAction
parameter contains information about the navigation action that triggered this signal.The new
WebKitWebView
must be related towebView
, seeWebKitWebView
:related-view for more details.The new
WebKitWebView
should not be displayed to the user until theWebKitWebView
::ready-to-show signal is emitted.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
onDecidePolicy
public SignalConnection<WebView.DecidePolicyCallback> onDecidePolicy(WebView.DecidePolicyCallback handler) This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource. TheWebKitNavigationPolicyDecision
passed in thedecision
argument is a generic type, but should be casted to a more specific type when making the decision. For example:static gboolean decide_policy_cb (WebKitWebView *web_view, WebKitPolicyDecision *decision, WebKitPolicyDecisionType type) { switch (type) { case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: { WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break; } case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: { WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break; } case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision); // Make a policy decision here break; default: // Making no decision results in webkit_policy_decision_use() return FALSE; } return TRUE; }
It is possible to make policy decision asynchronously, by simply calling g_object_ref() on the
decision
argument and returningtrue
to block the default signal handler. If the last reference is removed on aWebKitPolicyDecision
and no decision has been made explicitly, webkit_policy_decision_use() will be the default policy decision. The default signal handler will simply call webkit_policy_decision_use(). Only the first policy decision chosen for a givenWebKitPolicyDecision
will have any affect.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDecidePolicy
Emits the "decide-policy" signal. SeeonDecidePolicy(org.gnome.webkit.WebView.DecidePolicyCallback)
. -
onEnterFullscreen
public SignalConnection<WebView.EnterFullscreenCallback> onEnterFullscreen(WebView.EnterFullscreenCallback handler) Emitted when JavaScript code calls <function>element.webkitRequestFullScreen</function>. If the signal is not handled theWebKitWebView
will proceed to full screen its top level window. This signal can be used by client code to request permission to the user prior doing the full screen transition and eventually prepare the top-level window (e.g. hide some widgets that would otherwise be part of the full screen window).- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitEnterFullscreen
public boolean emitEnterFullscreen()Emits the "enter-fullscreen" signal. SeeonEnterFullscreen(org.gnome.webkit.WebView.EnterFullscreenCallback)
. -
onInsecureContentDetected
@Deprecated public SignalConnection<WebView.InsecureContentDetectedCallback> onInsecureContentDetected(WebView.InsecureContentDetectedCallback handler) Deprecated.Prior to 2.46, this signal was emitted when insecure content was loaded in a secure content. Since 2.46, this signal is generally no longer emitted.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitInsecureContentDetected
Deprecated.Emits the "insecure-content-detected" signal. SeeonInsecureContentDetected(org.gnome.webkit.WebView.InsecureContentDetectedCallback)
. -
onLeaveFullscreen
public SignalConnection<WebView.LeaveFullscreenCallback> onLeaveFullscreen(WebView.LeaveFullscreenCallback handler) Emitted when theWebKitWebView
is about to restore its top level window out of its full screen state. This signal can be used by client code to restore widgets hidden during theWebKitWebView
::enter-fullscreen stage for instance.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLeaveFullscreen
public boolean emitLeaveFullscreen()Emits the "leave-fullscreen" signal. SeeonLeaveFullscreen(org.gnome.webkit.WebView.LeaveFullscreenCallback)
. -
onLoadChanged
public SignalConnection<WebView.LoadChangedCallback> onLoadChanged(WebView.LoadChangedCallback handler) Emitted when a load operation inwebView
changes. The signal is always emitted withLoadEvent.STARTED
when a new load request is made andLoadEvent.FINISHED
when the load finishes successfully or due to an error. When the ongoing load operation failsWebKitWebView
::load-failed signal is emitted beforeWebKitWebView
::load-changed is emitted withLoadEvent.FINISHED
. If a redirection is received from the server, this signal is emitted withLoadEvent.REDIRECTED
after the initial emission withLoadEvent.STARTED
and beforeLoadEvent.COMMITTED
. When the page content starts arriving the signal is emitted withLoadEvent.COMMITTED
event.You can handle this signal and use a switch to track any ongoing load operation.
static void web_view_load_changed (WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer user_data) { switch (load_event) { case WEBKIT_LOAD_STARTED: // New load, we have now a provisional URI provisional_uri = webkit_web_view_get_uri (web_view); // Here we could start a spinner or update the // location bar with the provisional URI break; case WEBKIT_LOAD_REDIRECTED: redirected_uri = webkit_web_view_get_uri (web_view); break; case WEBKIT_LOAD_COMMITTED: // The load is being performed. Current URI is // the final one and it won't change unless a new // load is requested or a navigation within the // same page is performed uri = webkit_web_view_get_uri (web_view); break; case WEBKIT_LOAD_FINISHED: // Load finished, we can now stop the spinner break; } }
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLoadChanged
Emits the "load-changed" signal. SeeonLoadChanged(org.gnome.webkit.WebView.LoadChangedCallback)
. -
onLoadFailed
public SignalConnection<WebView.LoadFailedCallback> onLoadFailed(WebView.LoadFailedCallback handler) Emitted when an error occurs during a load operation. If the error happened when starting to load data for a pageloadEvent
will beLoadEvent.STARTED
. If it happened while loading a committed data sourceloadEvent
will beLoadEvent.COMMITTED
. Since a load error causes the load operation to finish, the signal WebKitWebView::load-changed will always be emitted withLoadEvent.FINISHED
event right after this one.By default, if the signal is not handled, a stock error page will be displayed. You need to handle the signal if you want to provide your own error page.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLoadFailed
Emits the "load-failed" signal. SeeonLoadFailed(org.gnome.webkit.WebView.LoadFailedCallback)
. -
onLoadFailedWithTlsErrors
public SignalConnection<WebView.LoadFailedWithTlsErrorsCallback> onLoadFailedWithTlsErrors(WebView.LoadFailedWithTlsErrorsCallback handler) Emitted when a TLS error occurs during a load operation. To allow an exception for thiscertificate
and the host offailingUri
use webkit_web_context_allow_tls_certificate_for_host().To handle this signal asynchronously you should call g_object_ref() on
certificate
and returntrue
.If
false
is returned,WebKitWebView
::load-failed will be emitted. The load will finish regardless of the returned value.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLoadFailedWithTlsErrors
public boolean emitLoadFailedWithTlsErrors(String failingUri, TlsCertificate certificate, Set<TlsCertificateFlags> errors) Emits the "load-failed-with-tls-errors" signal. SeeonLoadFailedWithTlsErrors(org.gnome.webkit.WebView.LoadFailedWithTlsErrorsCallback)
. -
onMouseTargetChanged
public SignalConnection<WebView.MouseTargetChangedCallback> onMouseTargetChanged(WebView.MouseTargetChangedCallback handler) This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element. To determine what type of element the mouse cursor is over, a Hit Test is performed on the current mouse coordinates and the result is passed in thehitTestResult
argument. Themodifiers
argument is a bitmask ofGdkModifierType
flags indicating the state of modifier keys. The signal is emitted again when the mouse is moved out of the current element with a newhitTestResult
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMouseTargetChanged
Emits the "mouse-target-changed" signal. SeeonMouseTargetChanged(org.gnome.webkit.WebView.MouseTargetChangedCallback)
. -
onPermissionRequest
public SignalConnection<WebView.PermissionRequestCallback> onPermissionRequest(WebView.PermissionRequestCallback handler) This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.A possible way to use this signal could be through a dialog allowing the user decide what to do with the request:
static gboolean permission_request_cb (WebKitWebView *web_view, WebKitPermissionRequest *request, GtkWindow *parent_window) { GtkWidget *dialog = gtk_message_dialog_new (parent_window, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Allow Permission Request?"); gtk_widget_show (dialog); gint result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: webkit_permission_request_allow (request); break; default: webkit_permission_request_deny (request); break; } gtk_widget_destroy (dialog); return TRUE; }
It is possible to handle permission requests asynchronously, by simply calling g_object_ref() on the
request
argument and returningtrue
to block the default signal handler. If the last reference is removed on aWebKitPermissionRequest
and the request has not been handled, webkit_permission_request_deny() will be the default action.If the signal is not handled, the
request
will be completed automatically by the specificWebKitPermissionRequest
that could allow or deny it. Check the documentation of classes implementingWebKitPermissionRequest
interface to know their default action.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPermissionRequest
Emits the "permission-request" signal. SeeonPermissionRequest(org.gnome.webkit.WebView.PermissionRequestCallback)
. -
onPrint
Emitted when printing is requested onwebView
, usually by a JavaScript call, before the print dialog is shown. This signal can be used to set the initial print settings and page setup ofprintOperation
to be used as default values in the print dialog. You can call webkit_print_operation_set_print_settings() and webkit_print_operation_set_page_setup() and then returnfalse
to propagate the event so that the print dialog is shown.You can connect to this signal and return
true
to cancel the print operation or implement your own print dialog.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPrint
Emits the "print" signal. SeeonPrint(org.gnome.webkit.WebView.PrintCallback)
. -
onQueryPermissionState
public SignalConnection<WebView.QueryPermissionStateCallback> onQueryPermissionState(WebView.QueryPermissionStateCallback handler) This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification. You can reply to the query using webkit_permission_state_query_finish().You can handle the query asynchronously by calling webkit_permission_state_query_ref() on
query
and returningtrue
. If the last reference ofquery
is removed and the query has not been handled, the query result will be set toWEBKIT_QUERY_PERMISSION_PROMPT
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitQueryPermissionState
Emits the "query-permission-state" signal. SeeonQueryPermissionState(org.gnome.webkit.WebView.QueryPermissionStateCallback)
. -
onReadyToShow
public SignalConnection<WebView.ReadyToShowCallback> onReadyToShow(WebView.ReadyToShowCallback handler) Emitted afterWebKitWebView
::create on the newly createdWebKitWebView
when it should be displayed to the user. When this signal is emitted all the information about how the window should look, including size, position, whether the location, status and scrollbars should be displayed, is already set on theWebKitWindowProperties
ofwebView
. See also webkit_web_view_get_window_properties().- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitReadyToShow
public void emitReadyToShow()Emits the "ready-to-show" signal. SeeonReadyToShow(org.gnome.webkit.WebView.ReadyToShowCallback)
. -
onResourceLoadStarted
public SignalConnection<WebView.ResourceLoadStartedCallback> onResourceLoadStarted(WebView.ResourceLoadStartedCallback handler) Emitted when a new resource is going to be loaded. Therequest
parameter contains theWebKitURIRequest
that will be sent to the server. You can monitor the load operation by connecting to the different signals ofresource
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitResourceLoadStarted
Emits the "resource-load-started" signal. SeeonResourceLoadStarted(org.gnome.webkit.WebView.ResourceLoadStartedCallback)
. -
onRunAsModal
public SignalConnection<WebView.RunAsModalCallback> onRunAsModal(WebView.RunAsModalCallback handler) Emitted afterWebKitWebView
::ready-to-show on the newly createdWebKitWebView
when JavaScript code calls <function>window.showModalDialog</function>. The purpose of this signal is to allow the client application to prepare the new view to behave as modal. Once the signal is emitted a new main loop will be run to block user interaction in the parentWebKitWebView
until the new dialog is closed.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRunAsModal
public void emitRunAsModal()Emits the "run-as-modal" signal. SeeonRunAsModal(org.gnome.webkit.WebView.RunAsModalCallback)
. -
onRunColorChooser
public SignalConnection<WebView.RunColorChooserCallback> onRunColorChooser(WebView.RunColorChooserCallback handler) This signal is emitted when the user interacts with a <input type='color' /> HTML element, requesting from WebKit to show a dialog to select a color. To let the application know the details of the color chooser, as well as to allow the client application to either cancel the request or perform an actual color selection, the signal will pass an instance of theWebKitColorChooserRequest
in therequest
argument.It is possible to handle this request asynchronously by increasing the reference count of the request.
The default signal handler will asynchronously run a regular
GtkColorChooser
for the user to interact with.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRunColorChooser
Emits the "run-color-chooser" signal. SeeonRunColorChooser(org.gnome.webkit.WebView.RunColorChooserCallback)
. -
onRunFileChooser
public SignalConnection<WebView.RunFileChooserCallback> onRunFileChooser(WebView.RunFileChooserCallback handler) This signal is emitted when the user interacts with a <input type='file' /> HTML element, requesting from WebKit to show a dialog to select one or more files to be uploaded. To let the application know the details of the file chooser, as well as to allow the client application to either cancel the request or perform an actual selection of files, the signal will pass an instance of theWebKitFileChooserRequest
in therequest
argument.The default signal handler will asynchronously run a regular
GtkFileChooserDialog
for the user to interact with.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitRunFileChooser
Emits the "run-file-chooser" signal. SeeonRunFileChooser(org.gnome.webkit.WebView.RunFileChooserCallback)
. -
onScriptDialog
public SignalConnection<WebView.ScriptDialogCallback> onScriptDialog(WebView.ScriptDialogCallback handler) Emitted when JavaScript code calls <function>window.alert</function>, <function>window.confirm</function> or <function>window.prompt</function>, or when <function>onbeforeunload</function> event is fired. Thedialog
parameter should be used to build the dialog. If the signal is not handled a different dialog will be built and shown depending on the dialog type: <itemizedlist> <listitem><para>ScriptDialogType.ALERT
: message dialog with a single Close button. </para></listitem> <listitem><para>ScriptDialogType.CONFIRM
: message dialog with OK and Cancel buttons. </para></listitem> <listitem><para>ScriptDialogType.PROMPT
: message dialog with OK and Cancel buttons and a text entry with the default text. </para></listitem> <listitem><para>ScriptDialogType.BEFORE_UNLOAD_CONFIRM
: message dialog with Stay and Leave buttons. </para></listitem> </itemizedlist>It is possible to handle the script dialog request asynchronously, by simply caling webkit_script_dialog_ref() on the
dialog
argument and calling webkit_script_dialog_close() when done. If the last reference is removed on aWebKitScriptDialog
and the dialog has not been closed, webkit_script_dialog_close() will be called.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitScriptDialog
Emits the "script-dialog" signal. SeeonScriptDialog(org.gnome.webkit.WebView.ScriptDialogCallback)
. -
onShowNotification
public SignalConnection<WebView.ShowNotificationCallback> onShowNotification(WebView.ShowNotificationCallback handler) This signal is emitted when a notification should be presented to the user. Thenotification
is kept alive until either: 1) the web page cancels it or 2) a navigation happens.The default handler will emit a notification using libnotify, if built with support for it.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitShowNotification
Emits the "show-notification" signal. SeeonShowNotification(org.gnome.webkit.WebView.ShowNotificationCallback)
. -
onShowOptionMenu
public SignalConnection<WebView.ShowOptionMenuCallback> onShowOptionMenu(WebView.ShowOptionMenuCallback handler) This signal is emitted when a select element inwebView
needs to display a dropdown menu. This signal can be used to show a custom menu, usingmenu
to get the details of all items that should be displayed. The area of the element in theWebKitWebView
is given asrectangle
parameter, it can be used to position the menu. To handle this signal asynchronously you should keep a ref of themenu
.The default signal handler will pop up a
GtkMenu
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitShowOptionMenu
Emits the "show-option-menu" signal. SeeonShowOptionMenu(org.gnome.webkit.WebView.ShowOptionMenuCallback)
. -
onSubmitForm
public SignalConnection<WebView.SubmitFormCallback> onSubmitForm(WebView.SubmitFormCallback handler) This signal is emitted when a form is about to be submitted. Therequest
argument passed contains information about the text fields of the form. This is typically used to store login information that can be used later to pre-fill the form. The form will not be submitted until webkit_form_submission_request_submit() is called.It is possible to handle the form submission request asynchronously, by simply calling g_object_ref() on the
request
argument and calling webkit_form_submission_request_submit() when done to continue with the form submission. If the last reference is removed on aWebKitFormSubmissionRequest
and the form has not been submitted, webkit_form_submission_request_submit() will be called.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSubmitForm
Emits the "submit-form" signal. SeeonSubmitForm(org.gnome.webkit.WebView.SubmitFormCallback)
. -
onUserMessageReceived
public SignalConnection<WebView.UserMessageReceivedCallback> onUserMessageReceived(WebView.UserMessageReceivedCallback handler) This signal is emitted when aWebKitUserMessage
is received from theWebKitWebPage
corresponding towebView
. You can reply to the message using webkit_user_message_send_reply().You can handle the user message asynchronously by calling g_object_ref() on
message
and returningtrue
. If the last reference ofmessage
is removed and the message has not been replied to, the operation in theWebKitWebPage
will finish with errorUserMessageError.USER_MESSAGE_UNHANDLED_MESSAGE
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitUserMessageReceived
Emits the "user-message-received" signal. SeeonUserMessageReceived(org.gnome.webkit.WebView.UserMessageReceivedCallback)
. -
onWebProcessTerminated
public SignalConnection<WebView.WebProcessTerminatedCallback> onWebProcessTerminated(WebView.WebProcessTerminatedCallback handler) This signal is emitted when the web process terminates abnormally due toreason
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitWebProcessTerminated
Emits the "web-process-terminated" signal. SeeonWebProcessTerminated(org.gnome.webkit.WebView.WebProcessTerminatedCallback)
. -
builder
AWebView.Builder
object constructs aWebView
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withWebView.Builder.build()
.
-