Signal

WebKit2WebView::permission-request

Declaration

gboolean
permission_request (
  WebKitWebView* self,
  WebKit2PermissionRequest* request,
  gpointer user_data
)

Description [src]

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 returning TRUE to block the default signal handler. If the last reference is removed on a WebKitPermissionRequest 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 specific WebKitPermissionRequest that could allow or deny it. Check the documentation of classes implementing WebKitPermissionRequest interface to know their default action.

Default handler:

The default handler is called after the handlers added via g_signal_connect().

Parameters

request WebKitPermissionRequest
 

The WebKitPermissionRequest.

 The data is owned by the caller of the function.

Return value

Returns: gboolean
 

TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.