Package org.webkitgtk
Interface WebView.PermissionRequestCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
WebView
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public static interface WebView.PermissionRequestCallback
extends FunctionPointer
Functional interface declaration of the
PermissionRequestCallback callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanrun(@Nullable PermissionRequest request) 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.default MemorySegmenttoCallback(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)method.default intupcall(MemorySegment sourceWebView, MemorySegment request) Theupcallmethod is called from native code.
-
Method Details
-
run
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. -
upcall
Theupcallmethod is called from native code. The parameters are marshaled andrun(org.webkitgtk.PermissionRequest)is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)method.- Specified by:
toCallbackin interfaceFunctionPointer- Parameters:
arena- the arena in which the function pointer is allocated- Returns:
- the native function pointer
-