Class WebView
- All Implemented Interfaces:
Accessible,Buildable,ConstraintTarget,Proxy
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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface declaration of theAuthenticateCallbackcallback.static classWebView.Builder<B extends WebView.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theCloseCallbackcallback.static interfaceFunctional interface declaration of theContextMenuCallbackcallback.static interfaceFunctional interface declaration of theContextMenuDismissedCallbackcallback.static interfaceFunctional interface declaration of theCreateCallbackcallback.static interfaceFunctional interface declaration of theDecidePolicyCallbackcallback.static interfaceFunctional interface declaration of theEnterFullscreenCallbackcallback.static interfaceDeprecated.static interfaceFunctional interface declaration of theLeaveFullscreenCallbackcallback.static interfaceFunctional interface declaration of theLoadChangedCallbackcallback.static interfaceFunctional interface declaration of theLoadFailedCallbackcallback.static interfaceFunctional interface declaration of theLoadFailedWithTlsErrorsCallbackcallback.static interfaceFunctional interface declaration of theMouseTargetChangedCallbackcallback.static interfaceFunctional interface declaration of thePermissionRequestCallbackcallback.static interfaceFunctional interface declaration of thePrintCallbackcallback.static interfaceFunctional interface declaration of theQueryPermissionStateCallbackcallback.static interfaceFunctional interface declaration of theReadyToShowCallbackcallback.static interfaceFunctional interface declaration of theResourceLoadStartedCallbackcallback.static interfaceFunctional interface declaration of theRunAsModalCallbackcallback.static interfaceFunctional interface declaration of theRunColorChooserCallbackcallback.static interfaceFunctional interface declaration of theRunFileChooserCallbackcallback.static interfaceFunctional interface declaration of theScriptDialogCallbackcallback.static interfaceFunctional interface declaration of theShowNotificationCallbackcallback.static interfaceFunctional interface declaration of theShowOptionMenuCallbackcallback.static interfaceFunctional interface declaration of theSubmitFormCallbackcallback.static interfaceFunctional interface declaration of theUserMessageReceivedCallbackcallback.static interfaceFunctional interface declaration of theWebProcessTerminatedCallbackcallback.static classNested classes/interfaces inherited from class org.webkitgtk.WebViewBase
WebViewBase.WebViewBaseClassNested 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.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterface -
Constructor Summary
ConstructorsConstructorDescriptionWebView()Creates a new WebView.WebView(MemorySegment address) Create a WebView proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected WebViewasParent()Returns this instance as if it were its parent type.protected booleanauthenticate(AuthenticationRequest request) static WebView.Builder<? extends WebView.Builder> builder()AWebView.Builderobject constructs aWebViewwith the specified properties.voidcallAsyncJavascriptFunction(String body, long length, @Nullable Variant arguments, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously callbodywithargumentsin the script world with nameworldNameof the main frame current context inwebView.Theargumentsvalues must be one of the following types, or contain only the following GVariant types: number, string and dictionary.Finish an asynchronous operation started with webkit_web_view_call_async_javascript_function().voidcanExecuteEditingCommand(String command, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously check if it is possible to execute the given editing command.booleanFinish an asynchronous operation started with webkit_web_view_can_execute_editing_command().booleanDetermines whether this WebView has a previous history item.booleanDetermines whether this WebView has a next history item.booleancanShowMimeType(String mimeType) Whether or not a MIME type can be displayed inwebView.protected voidclose()protected booleancontextMenu(ContextMenu contextMenu, HitTestResult hitTestResult) protected voidprotected Widgetcreate(NavigationAction navigationAction) protected booleandecidePolicy(PolicyDecision decision, PolicyDecisionType type) downloadUri(String uri) Requests downloading of the specified URI string forwebView.booleanemitAuthenticate(@Nullable AuthenticationRequest request) Emits the "authenticate" signal.voidEmits the "close" signal.booleanemitContextMenu(@Nullable ContextMenu contextMenu, @Nullable HitTestResult hitTestResult) Emits the "context-menu" signal.voidEmits the "context-menu-dismissed" signal.emitCreate(@Nullable NavigationAction navigationAction) Emits the "create" signal.booleanemitDecidePolicy(@Nullable PolicyDecision decision, PolicyDecisionType decisionType) Emits the "decide-policy" signal.booleanEmits the "enter-fullscreen" signal.voidDeprecated.booleanEmits the "leave-fullscreen" signal.voidemitLoadChanged(LoadEvent loadEvent) Emits the "load-changed" signal.booleanemitLoadFailed(LoadEvent loadEvent, String failingUri, @Nullable GError error) Emits the "load-failed" signal.booleanemitLoadFailedWithTlsErrors(String failingUri, @Nullable TlsCertificate certificate, Set<TlsCertificateFlags> errors) Emits the "load-failed-with-tls-errors" signal.voidemitMouseTargetChanged(@Nullable HitTestResult hitTestResult, int modifiers) Emits the "mouse-target-changed" signal.booleanemitPermissionRequest(@Nullable PermissionRequest request) Emits the "permission-request" signal.booleanemitPrint(@Nullable PrintOperation printOperation) Emits the "print" signal.booleanemitQueryPermissionState(@Nullable PermissionStateQuery query) Emits the "query-permission-state" signal.voidEmits the "ready-to-show" signal.voidemitResourceLoadStarted(@Nullable WebResource resource, @Nullable URIRequest request) Emits the "resource-load-started" signal.voidEmits the "run-as-modal" signal.booleanemitRunColorChooser(@Nullable ColorChooserRequest request) Emits the "run-color-chooser" signal.booleanemitRunFileChooser(@Nullable FileChooserRequest request) Emits the "run-file-chooser" signal.booleanemitScriptDialog(@Nullable ScriptDialog dialog) Emits the "script-dialog" signal.booleanemitShowNotification(@Nullable Notification notification) Emits the "show-notification" signal.booleanemitShowOptionMenu(@Nullable OptionMenu menu, @Nullable Rectangle rectangle) Emits the "show-option-menu" signal.voidemitSubmitForm(@Nullable FormSubmissionRequest request) Emits the "submit-form" signal.booleanemitUserMessageReceived(@Nullable UserMessage message) Emits the "user-message-received" signal.voidEmits the "web-process-terminated" signal.protected booleanvoidevaluateJavascript(String script, long length, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously evaluatescriptin the script world with nameworldNameof the main frame current context inwebView.IfworldNameisnull, the default world is used.evaluateJavascriptFinish(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_evaluate_javascript().voidexecuteEditingCommand(String command) Request to execute the givencommandforwebView.voidexecuteEditingCommandWithArgument(String command, String argument) Request to execute the givencommandwithargumentforwebView.Get the presentation type ofWebKitWebViewwhen created for automation.Obtains theWebKitBackForwardListassociated with the givenWebKitWebView.voidgetBackgroundColor(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 ofwebView.Returns the current custom character encoding name ofwebView.@Nullable StringGets the configured default Content-Security-Policy.Get the display capture state of aWebKitWebView.Gets the web editor state ofwebView.doubleGets the value of theWebKitWebView:estimated-load-progress property.Returns favicon currently associated towebView.Gets theWebKitFindController.@Nullable InputMethodContextGet theWebKitInputMethodContextcurrently in use bywebView.Get theWebKitWebInspectorassociated to this WebViewbooleanGets the mute state ofwebView.booleanGet whether the current web process of aWebKitWebViewis responsive.Return the main resource ofwebView.static MemoryLayoutThe memory layout of the native struct.Get the microphone capture state of aWebKitWebView.Get theWebKitNetworkSessionassociated towebView.longGet the identifier of theWebKitWebPagecorresponding to theWebKitWebViewGets the current session state of this WebViewvoidgetSnapshot(SnapshotRegion region, Set<SnapshotOptions> options, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion.voidgetSnapshot(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().booleangetThemeColor(RGBA rgba) Gets the theme color that is specified by the content in thewebView.If the this WebView doesn't have a theme color it will fill thergbawith transparent black content.getTitle()Gets the value of theWebKitWebView:title property.booleangetTlsInfo(Out<TlsCertificate> certificate, Out<Set<TlsCertificateFlags>> errors) Retrieves theGTlsCertificateassociated with the main resource ofwebView.static @Nullable TypegetType()Get the GType of the WebView classgetUri()Returns the current active URI ofwebView.Gets the user content manager associated towebView.Get the view'sWebKitWebExtensionMode.Gets the default website policies.Gets theWebKitSettingscurrently applied towebView.Get theWebKitWindowPropertiesobject.doubleSet the zoom level ofwebView.voidgoBack()Loads the previous history item.voidLoads the next history item.voidgoToBackForwardListItem(BackForwardListItem listItem) Loads the specific history itemlistItem.protected voidbooleanGet whether aWebKitWebViewwas created withWebKitWebView:is-controlled-by-automation property enabled.booleanGets whether the user is allowed to edit the HTML document.booleanGets the value of theWebKitWebView:is-loading property.booleanGets the value of theWebKitWebView:is-playing-audio property.protected booleanvoidloadAlternateHtml(String content, String contentUri, @Nullable String baseUri) Load the givencontentstring for the URIcontentUri.voidloadBytes(byte[] bytes, @Nullable String mimeType, @Nullable String encoding, @Nullable String baseUri) Load the specifiedbytesinto this WebView using the givenmimeTypeandencoding.protected voidloadChanged(LoadEvent loadEvent) protected booleanloadFailed(LoadEvent loadEvent, String failingUri, GError error) protected booleanloadFailedWithTlsErrors(String failingUri, TlsCertificate certificate, Set<TlsCertificateFlags> errors) voidLoad the givencontentstring with the specifiedbaseUri.voidloadPlainText(String plainText) Load the specifiedplainTextstring intowebView.voidloadRequest(URIRequest request) Requests loading of the specifiedWebKitURIRequest.voidRequests loading of the specified URI string.protected voidmouseTargetChanged(HitTestResult hitTestResult, int modifiers) This signal is emitted when the user is challenged with HTTP authentication.onClose(WebView.CloseCallback handler) Emitted when closing aWebKitWebViewis 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 newWebKitWebViewis 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 theWebKitWebViewis about to restore its top level window out of its full screen state.onLoadChanged(WebView.LoadChangedCallback handler) Emitted when a load operation inwebViewchanges.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 createdWebKitWebViewwhen 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 createdWebKitWebViewwhen 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 inwebViewneeds 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 aWebKitUserMessageis received from theWebKitWebPagecorresponding towebView.You can reply to the message using webkit_user_message_send_reply().This signal is emitted when the web process terminates abnormally due toreason.protected booleanpermissionRequest(PermissionRequest permissionRequest) protected booleanprint(PrintOperation printOperation) protected booleanprotected voidvoidreload()Reloads the current contents ofwebView.voidReloads the current contents of this WebView without using any cached data.protected voidresourceLoadStarted(WebResource resource, URIRequest request) voidRestore the this WebView session state fromstateprotected voidprotected booleanrunColorChooser(ColorChooserRequest request) protected booleanrunFileChooser(FileChooserRequest request) voidsave(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().voidsaveToFile(File file, SaveMode saveMode, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.booleansaveToFileFinish(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_save_to_file().protected booleanscriptDialog(ScriptDialog dialog) voidsendMessageToPage(UserMessage message, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Sendmessageto theWebKitWebPagecorresponding towebView.sendMessageToPageFinish(AsyncResult result) Finish an asynchronous operation started with webkit_web_view_send_message_to_page().voidsetBackgroundColor(RGBA rgba) Sets the color that will be used to draw the this WebView background.voidSet the camera capture state of aWebKitWebView.voidsetCorsAllowlist(@Nullable String @Nullable [] allowlist) Sets theallowlistfor CORS.voidsetCustomCharset(@Nullable String charset) Sets the current custom character encoding override ofwebView.voidSet the display capture state of aWebKitWebView.voidsetEditable(boolean editable) Sets whether the user is allowed to edit the HTML document.voidsetInputMethodContext(@Nullable InputMethodContext context) Set theWebKitInputMethodContextto be used bywebView.voidsetIsMuted(boolean muted) Sets the mute state ofwebView.voidSet the microphone capture state of aWebKitWebView.voidsetSettings(Settings settings) Sets theWebKitSettingsto be applied towebView.voidsetZoomLevel(double zoomLevel) Set the zoom level ofwebView.protected booleanshowNotification(Notification notification) protected booleanshowOptionMenu(OptionMenu menu, Rectangle rectangle) voidStops any ongoing loading operation inwebView.protected voidsubmitForm(FormSubmissionRequest request) voidTerminates the web process associated towebView.voidtryClose()Tries to close thewebView.protected booleanuserMessageReceived(UserMessage message) protected booleanprotected voidMethods 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, getLimitEvents, 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, setLimitEvents, 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, unsetStateFlagsMethods 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods 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
public WebView()Creates a new WebView.
-
-
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 Javasuperkeyword, 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:
asParentin classWebViewBase
-
callAsyncJavascriptFunction
public void callAsyncJavascriptFunction(String body, long length, @Nullable Variant arguments, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously callbodywithargumentsin the script world with nameworldNameof the main frame current context inwebView.Theargumentsvalues 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. IfworldNameisnull, the default world is used. Any value that is notnullis a distin ct world. ThesourceUriwill 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,
callbackwill 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 ifbodyis a nul-terminated stringarguments- aGVariantwith formata{sv}storing the function arguments, ornullworldName- the name of aWebKitScriptWorldornullto use the defaultsourceUri- the source URIcancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the script finished- Since:
- 2.40
-
callAsyncJavascriptFunctionFinish
Finish an asynchronous operation started with webkit_web_view_call_async_javascript_function().- Parameters:
result- aGAsyncResult- Returns:
- a
JSCValuewith the return value of the async function ornullin case of error - Throws:
GErrorException- seeGError- Since:
- 2.40
-
canExecuteEditingCommand
public void canExecuteEditingCommand(String command, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously check if it is possible to execute the given editing command.When the operation is finished,
callbackwill 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- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
canExecuteEditingCommandFinish
Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command().- Parameters:
result- aGAsyncResult- Returns:
trueif the editing command can be executed orfalseotherwise- Throws:
GErrorException- seeGError
-
canGoBack
public boolean canGoBack()Determines whether this WebView has a previous history item.- Returns:
trueif able to move back orfalseotherwise.
-
canGoForward
public boolean canGoForward()Determines whether this WebView has a next history item.- Returns:
trueif able to move forward orfalseotherwise.
-
canShowMimeType
Whether or not a MIME type can be displayed inwebView.- Parameters:
mimeType- a MIME type- Returns:
trueif the MIME typemimeTypecan be displayed orfalseotherwise
-
downloadUri
-
evaluateJavascript
public void evaluateJavascript(String script, long length, @Nullable String worldName, @Nullable String sourceUri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously evaluatescriptin the script world with nameworldNameof the main frame current context inwebView.IfworldNameisnull, the default world is used. Any value that is notnullis a distinct world. ThesourceUriwill 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,
callbackwill 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 ifscriptis a nul-terminated stringworldName- the name of aWebKitScriptWorldornullto use the defaultsourceUri- the source URIcancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the script finished- Since:
- 2.40
-
evaluateJavascriptFinish
Finish an asynchronous operation started with webkit_web_view_evaluate_javascript().- Parameters:
result- aGAsyncResult- Returns:
- a
JSCValuewith the result of the last executed statement in script ornullin case of error - Throws:
GErrorException- seeGError- Since:
- 2.40
-
executeEditingCommand
Request to execute the givencommandforwebView.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 givencommandwithargumentforwebView.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- Since:
- 2.10
-
getAutomationPresentationType
Get the presentation type ofWebKitWebViewwhen created for automation.- Returns:
- a
WebKitAutomationBrowsingContextPresentation. - Since:
- 2.28
-
getBackForwardList
Obtains theWebKitBackForwardListassociated with the givenWebKitWebView.The
WebKitBackForwardListis 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- aGdkRGBAto fill in with the background color- Since:
- 2.8
-
getCameraCaptureState
Get the camera capture state of aWebKitWebView.- Returns:
- The
WebKitMediaCaptureStateof the camera device. IfWebKitSettings:enable-mediastream isfalse, this method will returnMediaCaptureState.NONE. - Since:
- 2.34
-
getContext
Gets the web context ofwebView.- Returns:
- the
WebKitWebContextof the view
-
getCustomCharset
Returns the current custom character encoding name ofwebView.- Returns:
- the current custom character encoding name or
nullif no custom character encoding has been set.
-
getDefaultContentSecurityPolicy
Gets the configured default Content-Security-Policy.- Returns:
- The default policy or
null - Since:
- 2.38
-
getDisplayCaptureState
Get the display capture state of aWebKitWebView.- Returns:
- The
WebKitMediaCaptureStateof the display device. IfWebKitSettings:enable-mediastream isfalse, this method will returnMediaCaptureState.NONE. - Since:
- 2.34
-
getEditorState
Gets the web editor state ofwebView.- Returns:
- the
WebKitEditorStateof the view - Since:
- 2.10
-
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
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 towebView.Returns favicon currently associated to
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
nullif there's no icon associated withwebView.
-
getFindController
Gets theWebKitFindController.Gets the
WebKitFindControllerthat will allow the caller to query theWebKitWebViewfor the text to look for.- Returns:
- the
WebKitFindControllerassociated to this particularWebKitWebView.
-
getInputMethodContext
Get theWebKitInputMethodContextcurrently in use bywebView.Get the
WebKitInputMethodContextcurrently in use bywebView,ornullif no input method is being used.- Returns:
- a
WebKitInputMethodContext, ornull - Since:
- 2.28
-
getInspector
Get theWebKitWebInspectorassociated to this WebView- Returns:
- the
WebKitWebInspectorof this WebView
-
getIsMuted
public boolean getIsMuted()Gets the mute state ofwebView.- Returns:
trueif this WebView audio is muted orfalseis audio is not muted.- Since:
- 2.30
-
getIsWebProcessResponsive
public boolean getIsWebProcessResponsive()Get whether the current web process of aWebKitWebViewis responsive.- Returns:
trueif the web process attached to this WebView is responsive, orfalseotherwise.- Since:
- 2.34
-
getMainResource
Return the main resource ofwebView.- Returns:
- the main
WebKitWebResourceof the view ornullif nothing has been loaded.
-
getMicrophoneCaptureState
Get the microphone capture state of aWebKitWebView.- Returns:
- The
WebKitMediaCaptureStateof the microphone device. IfWebKitSettings:enable-mediastream isfalse, this method will returnMediaCaptureState.NONE. - Since:
- 2.34
-
getNetworkSession
Get theWebKitNetworkSessionassociated towebView.- Returns:
- a
WebKitNetworkSession - Since:
- 2.40
-
getPageId
public long getPageId()Get the identifier of theWebKitWebPagecorresponding to theWebKitWebView- Returns:
- the page ID of
webView.
-
getSessionState
Gets the current session state of this WebView- Returns:
- a
WebKitWebViewSessionState - Since:
- 2.12
-
getWebViewSettings
Gets theWebKitSettingscurrently applied towebView.If no other
WebKitSettingshave been explicitly applied to this WebView with webkit_web_view_set_settings(), the defaultWebKitSettingswill be returned. This method always returns a validWebKitSettingsobject. To modify any of the this WebView settings, you can either create a newWebKitSettingsobject 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.WebKitSettingsobjects can be shared by multipleWebKitWebView<!-- -->s, so modifying the settings of aWebKitWebViewwould affect otherWebKitWebView<!-- -->s using the sameWebKitSettings.- Returns:
- the
WebKitSettingsattached to this WebView
-
getSnapshot
public void getSnapshot(SnapshotRegion region, Set<SnapshotOptions> options, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion.optionsspecifies how the snapshot should be rendered.When the operation is finished,
callbackwill be called. You must call webkit_web_view_get_snapshot_finish() to get the result of the operation.- Parameters:
region- theWebKitSnapshotRegionfor this snapshotoptions-WebKitSnapshotOptionsfor the snapshotcancellable- aGCancellablecallback- aGAsyncReadyCallback
-
getSnapshot
public void getSnapshot(SnapshotRegion region, SnapshotOptions options, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously retrieves a snapshot of this WebView forregion.optionsspecifies how the snapshot should be rendered.When the operation is finished,
callbackwill be called. You must call webkit_web_view_get_snapshot_finish() to get the result of the operation.- Parameters:
region- theWebKitSnapshotRegionfor this snapshotoptions-WebKitSnapshotOptionsfor the snapshotcancellable- aGCancellablecallback- aGAsyncReadyCallback
-
getSnapshotFinish
Finishes an asynchronous operation started with webkit_web_view_get_snapshot().- Parameters:
result- aGAsyncResult- Returns:
- an image with the retrieved snapshot, or
nullin case of error. - Throws:
GErrorException- seeGError
-
getThemeColor
Gets the theme color that is specified by the content in thewebView.If the this WebView doesn't have a theme color it will fill thergbawith transparent black content.- Parameters:
rgba- aGdkRGBAto fill in with the theme color- Returns:
- Whether the currently loaded page defines a theme color.
- Since:
- 2.50
-
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
webView.
-
getTlsInfo
Retrieves theGTlsCertificateassociated with the main resource ofwebView.Retrieves the
GTlsCertificateassociated with the main resource ofwebView,and theGTlsCertificateFlagsshowing 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.COMMITTEDevent.Note that this function provides no information about the security of the web page if the current
WebKitTLSErrorsPolicyisTLSErrorsPolicy.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 currentWebKitTLSErrorsPolicyisTLSErrorsPolicy.FAIL, in which case subresources that fail certificate verification will be blocked.- Parameters:
certificate- return location for aGTlsCertificateerrors- return location for aGTlsCertificateFlagsthe verification status ofcertificate- Returns:
trueif the this WebView connection uses HTTPS and a response has been received from the server, orfalseotherwise.
-
getUri
Returns the current active URI ofwebView.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 theWebKitBackForwardListofwebView.</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.REDIRECTEDevent, the active URI is already updated to the redirected URI. </para></listitem> <listitem><para> When the signalWebKitWebView::load-changed is emitted withLoadEvent.COMMITTEDevent, 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
webView.- Returns:
- the current active URI of this WebView or
nullif nothing has been loaded yet.
-
getUserContentManager
Gets the user content manager associated towebView.- Returns:
- the
WebKitUserContentManagerassociated with the view - Since:
- 2.6
-
getWebExtensionMode
Get the view'sWebKitWebExtensionMode.- Returns:
- the
WebKitWebExtensionMode - Since:
- 2.38
-
getWebsitePolicies
Gets the default website policies.Gets the default website policies set on construction in the
webView.These can be overridden on a per-origin basis via theWebKitWebView::decide-policy signal handler.See also webkit_policy_decision_use_with_policies().
- Returns:
- the default
WebKitWebsitePoliciesassociated with the view. - Since:
- 2.30
-
getWindowProperties
Get theWebKitWindowPropertiesobject.Get the
WebKitWindowPropertiesobject containing the properties that the window containing this WebView should have.- Returns:
- the
WebKitWindowPropertiesof this WebView
-
getZoomLevel
public double getZoomLevel()Set the zoom level ofwebView.Get the zoom level of
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 aWebKitWebViewwas created withWebKitWebView:is-controlled-by-automation property enabled.Only
WebKitWebView<!-- -->s controlled by automation can be used in an automation session.- Returns:
trueif this WebView is controlled by automation, orfalseotherwise.- Since:
- 2.18
-
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
WebKitWebViewis not editable.- Returns:
trueif the user is allowed to edit the HTML document, orfalseotherwise.- Since:
- 2.8
-
isLoading
public boolean isLoading()Gets the value of theWebKitWebView:is-loading property.You can monitor when a
WebKitWebViewis loading a page by connecting to notify::is-loading signal ofwebView.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:
trueif this WebView is loading a page orfalseotherwise.
-
isPlayingAudio
public boolean isPlayingAudio()Gets the value of theWebKitWebView:is-playing-audio property.You can monitor when a page in a
WebKitWebViewis playing audio by connecting to the notify::is-playing-audio signal ofwebView.This is useful when the application wants to provide visual feedback when a page is producing sound.- Returns:
trueif a page in this WebView is playing audio orfalseotherwise.- Since:
- 2.8
-
loadAlternateHtml
Load the givencontentstring for the URIcontentUri.This allows clients to display page-loading errors in the
WebKitWebViewitself. 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(byte[] bytes, @Nullable String mimeType, @Nullable String encoding, @Nullable String baseUri) Load the specifiedbytesinto this WebView using the givenmimeTypeandencoding.When
mimeTypeisnull, it defaults to "text/html". Whenencodingisnull, it defaults to "UTF-8". WhenbaseUriisnull, 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,ornullencoding- the character encoding ofbytes,ornullbaseUri- the base URI for relative locations ornull- Since:
- 2.6
-
loadHtml
Load the givencontentstring with the specifiedbaseUri.If
baseUriis notnull, relative URLs in thecontentwill be resolved againstbaseUriand absolute local paths must be children of thebaseUri.For security reasons absolute local paths that are not children ofbaseUriwill cause the web process to terminate. If you need to include URLs incontentthat are local paths in a different directory thanbaseUriyou can build a data URI for them. WhenbaseUriisnull, 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 specifiedplainTextstring intowebView.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- aWebKitURIRequestto 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 ofwebView.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- Since:
- 2.12
-
save
public void save(SaveMode saveMode, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.Asynchronously save the current web page associated to the
WebKitWebViewinto a self-contained format using the mode specified insaveMode.When the operation is finished,
callbackwill be called. You can then call webkit_web_view_save_finish() to get the result of the operation.- Parameters:
saveMode- theWebKitSaveModespecifying how the web page should be saved.cancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
saveFinish
Finish an asynchronous operation started with webkit_web_view_save().- Parameters:
result- aGAsyncResult- Returns:
- a
GInputStreamwith the result of saving the current web page ornullin case of error. - Throws:
GErrorException- seeGError
-
saveToFile
public void saveToFile(File file, SaveMode saveMode, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously save the current web page.Asynchronously save the current web page associated to the
WebKitWebViewinto a self-contained format using the mode specified insaveModeand writing it tofile.When the operation is finished,
callbackwill be called. You can then call webkit_web_view_save_to_file_finish() to get the result of the operation.- Parameters:
file- theGFilewhere the current web page should be saved to.saveMode- theWebKitSaveModespecifying how the web page should be saved.cancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
saveToFileFinish
Finish an asynchronous operation started with webkit_web_view_save_to_file().- Parameters:
result- aGAsyncResult- Returns:
trueif the web page was successfully saved to a file orfalseotherwise.- Throws:
GErrorException- seeGError
-
sendMessageToPage
public void sendMessageToPage(UserMessage message, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Sendmessageto theWebKitWebPagecorresponding towebView.If
messageis floating, it's consumed. If you don't expect any reply, or you simply want to ignore it, you can passnullascallback.When the operation is finished,callbackwill be called. You can then call webkit_web_view_send_message_to_page_finish() to get the message reply.- Parameters:
message- aWebKitUserMessagecancellable- aGCancellableornullto ignorecallback- (nullable): AGAsyncReadyCallbackto call when the request is satisfied ornull- Since:
- 2.28
-
sendMessageToPageFinish
Finish an asynchronous operation started with webkit_web_view_send_message_to_page().- Parameters:
result- aGAsyncResult- Returns:
- a
WebKitUserMessagewith the reply ornullin case of error. - Throws:
GErrorException- seeGError- Since:
- 2.28
-
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
rgbacolor. By default the this WebView background color is opaque white.- Parameters:
rgba- aGdkRGBA- Since:
- 2.8
-
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.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state- aWebKitMediaCaptureState- Since:
- 2.34
-
setCorsAllowlist
Sets theallowlistfor CORS.Sets the
allowlistfor which Cross-Origin Resource Sharing checks are disabled inwebView.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- Since:
- 2.34
-
setCustomCharset
Sets the current custom character encoding override ofwebView.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
nullremoves 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.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state- aWebKitMediaCaptureState- Since:
- 2.34
-
setEditable
public void setEditable(boolean editable) Sets whether the user is allowed to edit the HTML document.If
editableistrue, this WebView allows the user to edit the HTML document. Ifeditableisfalse, an element inwebView'sdocument can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default aWebKitWebViewis 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
WebKitWebVieweditable without altering the document or DOM structure.- Parameters:
editable- agbooleanindicating the editable state- Since:
- 2.8
-
setInputMethodContext
Set theWebKitInputMethodContextto be used bywebView.Set the
WebKitInputMethodContextto be used bywebView,ornullto not use any input method. Note that the sameWebKitInputMethodContextcan't be set on more than oneWebKitWebViewat the same time.- Parameters:
context- theWebKitInputMethodContextto set, ornull- Since:
- 2.28
-
setIsMuted
public void setIsMuted(boolean muted) Sets the mute state ofwebView.- Parameters:
muted- mute flag- Since:
- 2.30
-
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.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.- Parameters:
state- aWebKitMediaCaptureState- Since:
- 2.34
-
setSettings
Sets theWebKitSettingsto be applied towebView.The existing
WebKitSettingsof this WebView will be replaced bysettings.New settings are applied immediately onwebView.The sameWebKitSettingsobject can be shared by multipleWebKitWebView<!-- -->s.- Parameters:
settings- aWebKitSettings
-
setZoomLevel
public void setZoomLevel(double zoomLevel) Set the zoom level ofwebView.Set the zoom level of
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 inwebView.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.CANCELLEDerror. -
terminateWebProcess
public void terminateWebProcess()Terminates the web process associated towebView.When the web process gets terminated using this method, the
WebKitWebView::web-process-terminated signal is emitted withWebProcessTerminationReason.TERMINATED_BY_APIas the reason for termination.- Since:
- 2.34
-
tryClose
public void tryClose()Tries to close thewebView.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.- Since:
- 2.12
-
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 theWebKitAuthenticationRequestin therequestargument. 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
- Since:
- 2.2
- See Also:
-
emitAuthenticate
Emits the "authenticate" signal. SeeonAuthenticate(org.webkitgtk.WebView.AuthenticateCallback). -
onClose
Emitted when closing aWebKitWebViewis requested. This occurs when a call is made from JavaScript's <function>window.close</function> function or after trying to close thewebViewwith 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.webkitgtk.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 bycontextMenuwill be shown. </para></listitem> <listitem><para> To prevent the menu from being displayed you can just connect to this signal and returntrueso 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 returnfalseso that the menu will be shown. You can also ignore the proposedWebKitContextMenu, build your ownGtkMenuand returntrueto 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
falsethe context menu represented bycontextMenuwill be shown, if it returntruethe context menu will not be shown.The proposed
WebKitContextMenupassed incontextMenuargument 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
public boolean emitContextMenu(@Nullable ContextMenu contextMenu, @Nullable HitTestResult hitTestResult) Emits the "context-menu" signal. SeeonContextMenu(org.webkitgtk.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.webkitgtk.WebView.ContextMenuDismissedCallback). -
onCreate
Emitted when the creation of a newWebKitWebViewis requested. If this signal is handled the signal handler should return the newly createdWebKitWebView.The
WebKitNavigationActionparameter contains information about the navigation action that triggered this signal.The new
WebKitWebViewmust be related towebView,seeWebKitWebView:related-view for more details.The new
WebKitWebViewshould not be displayed to the user until theWebKitWebView::ready-to-show signal is emitted.For creating views as response to automation tools requests, see the
WebKitAutomationSession::create-web-view signal.- 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. TheWebKitNavigationPolicyDecisionpassed in thedecisionargument 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
decisionargument and returningtrueto block the default signal handler. If the last reference is removed on aWebKitPolicyDecisionand 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 givenWebKitPolicyDecisionwill 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.webkitgtk.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 theWebKitWebViewwill 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.webkitgtk.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.webkitgtk.WebView.InsecureContentDetectedCallback). -
onLeaveFullscreen
public SignalConnection<WebView.LeaveFullscreenCallback> onLeaveFullscreen(WebView.LeaveFullscreenCallback handler) Emitted when theWebKitWebViewis 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.webkitgtk.WebView.LeaveFullscreenCallback). -
onLoadChanged
public SignalConnection<WebView.LoadChangedCallback> onLoadChanged(WebView.LoadChangedCallback handler) Emitted when a load operation inwebViewchanges. The signal is always emitted withLoadEvent.STARTEDwhen a new load request is made andLoadEvent.FINISHEDwhen 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.REDIRECTEDafter the initial emission withLoadEvent.STARTEDand beforeLoadEvent.COMMITTED. When the page content starts arriving the signal is emitted withLoadEvent.COMMITTEDevent.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.webkitgtk.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 pageloadEventwill beLoadEvent.STARTED. If it happened while loading a committed data sourceloadEventwill beLoadEvent.COMMITTED. Since a load error causes the load operation to finish, the signal WebKitWebView::load-changed will always be emitted withLoadEvent.FINISHEDevent 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.webkitgtk.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 thiscertificateand the host offailingUriuse webkit_web_context_allow_tls_certificate_for_host().To handle this signal asynchronously you should call g_object_ref() on
certificateand returntrue.If
falseis 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
- Since:
- 2.6
- See Also:
-
emitLoadFailedWithTlsErrors
public boolean emitLoadFailedWithTlsErrors(String failingUri, @Nullable TlsCertificate certificate, Set<TlsCertificateFlags> errors) Emits the "load-failed-with-tls-errors" signal. SeeonLoadFailedWithTlsErrors(org.webkitgtk.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 thehitTestResultargument. Themodifiersargument is a bitmask ofGdkModifierTypeflags 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.webkitgtk.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
requestargument and returningtrueto block the default signal handler. If the last reference is removed on aWebKitPermissionRequestand the request has not been handled, webkit_permission_request_deny() will be the default action.If the signal is not handled, the
requestwill be completed automatically by the specificWebKitPermissionRequestthat could allow or deny it. Check the documentation of classes implementingWebKitPermissionRequestinterface 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.webkitgtk.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 ofprintOperationto 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 returnfalseto propagate the event so that the print dialog is shown.You can connect to this signal and return
trueto 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.webkitgtk.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
queryand returningtrue. If the last reference ofqueryis 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
- Since:
- 2.40
- See Also:
-
emitQueryPermissionState
Emits the "query-permission-state" signal. SeeonQueryPermissionState(org.webkitgtk.WebView.QueryPermissionStateCallback). -
onReadyToShow
public SignalConnection<WebView.ReadyToShowCallback> onReadyToShow(WebView.ReadyToShowCallback handler) Emitted afterWebKitWebView::create on the newly createdWebKitWebViewwhen 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 theWebKitWindowPropertiesofwebView.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.webkitgtk.WebView.ReadyToShowCallback). -
onResourceLoadStarted
public SignalConnection<WebView.ResourceLoadStartedCallback> onResourceLoadStarted(WebView.ResourceLoadStartedCallback handler) Emitted when a new resource is going to be loaded. Therequestparameter contains theWebKitURIRequestthat 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.webkitgtk.WebView.ResourceLoadStartedCallback). -
onRunAsModal
public SignalConnection<WebView.RunAsModalCallback> onRunAsModal(WebView.RunAsModalCallback handler) Emitted afterWebKitWebView::ready-to-show on the newly createdWebKitWebViewwhen 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 parentWebKitWebViewuntil 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.webkitgtk.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 theWebKitColorChooserRequestin therequestargument.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
GtkColorChooserfor the user to interact with.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- Since:
- 2.8
- See Also:
-
emitRunColorChooser
Emits the "run-color-chooser" signal. SeeonRunColorChooser(org.webkitgtk.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 theWebKitFileChooserRequestin therequestargument.The default signal handler will asynchronously run a regular
GtkFileChooserDialogfor 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.webkitgtk.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. Thedialogparameter 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
dialogargument and calling webkit_script_dialog_close() when done. If the last reference is removed on aWebKitScriptDialogand 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.webkitgtk.WebView.ScriptDialogCallback). -
onShowNotification
public SignalConnection<WebView.ShowNotificationCallback> onShowNotification(WebView.ShowNotificationCallback handler) This signal is emitted when a notification should be presented to the user. Thenotificationis 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
- Since:
- 2.8
- See Also:
-
emitShowNotification
Emits the "show-notification" signal. SeeonShowNotification(org.webkitgtk.WebView.ShowNotificationCallback). -
onShowOptionMenu
public SignalConnection<WebView.ShowOptionMenuCallback> onShowOptionMenu(WebView.ShowOptionMenuCallback handler) This signal is emitted when a select element inwebViewneeds to display a dropdown menu. This signal can be used to show a custom menu, usingmenuto get the details of all items that should be displayed. The area of the element in theWebKitWebViewis given asrectangleparameter, 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
- Since:
- 2.18
- See Also:
-
emitShowOptionMenu
Emits the "show-option-menu" signal. SeeonShowOptionMenu(org.webkitgtk.WebView.ShowOptionMenuCallback). -
onSubmitForm
public SignalConnection<WebView.SubmitFormCallback> onSubmitForm(WebView.SubmitFormCallback handler) This signal is emitted when a form is about to be submitted. Therequestargument 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
requestargument and calling webkit_form_submission_request_submit() when done to continue with the form submission. If the last reference is removed on aWebKitFormSubmissionRequestand 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.webkitgtk.WebView.SubmitFormCallback). -
onUserMessageReceived
public SignalConnection<WebView.UserMessageReceivedCallback> onUserMessageReceived(WebView.UserMessageReceivedCallback handler) This signal is emitted when aWebKitUserMessageis received from theWebKitWebPagecorresponding 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
messageand returningtrue. If the last reference ofmessageis removed and the message has not been replied to, the operation in theWebKitWebPagewill finish with errorUserMessageError.USER_MESSAGE_UNHANDLED_MESSAGE.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- Since:
- 2.28
- See Also:
-
emitUserMessageReceived
Emits the "user-message-received" signal. SeeonUserMessageReceived(org.webkitgtk.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
- Since:
- 2.20
- See Also:
-
emitWebProcessTerminated
Emits the "web-process-terminated" signal. SeeonWebProcessTerminated(org.webkitgtk.WebView.WebProcessTerminatedCallback). -
builder
AWebView.Builderobject constructs aWebViewwith the specified properties. Use the variousset...()methods to set properties, and finish construction withWebView.Builder.build().- Returns:
- the builder object
-