From 472eabd5dea5437ae9a7e2b8eefada0820a870dd Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Sat, 17 Jul 2021 20:11:04 +0300 Subject: permission_request: be more verbose about requests --- browser.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/browser.c b/browser.c index 56ecfd2..3408a9d 100644 --- a/browser.c +++ b/browser.c @@ -1153,22 +1153,30 @@ notebook_switch_page(GtkNotebook *nb, GtkWidget *p, guint idx, gpointer data) gboolean permission_request(WebKitWebView *v, WebKitPermissionRequest *r, gpointer data) { + struct Client *c = (struct Client *)data; + const gchar *h; char *permission_str; + + h = g_uri_get_host(g_uri_parse( + webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)), + G_URI_FLAGS_PARSE_RELAXED, + NULL)); + if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) { - permission_str = "Allow this site to see your location?"; + permission_str = "Allow '%s' to see your location?"; } else if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(r)) { - permission_str = "Allow notifications from this website?"; + permission_str = "Allow notifications from '%s'?"; } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(r)) { if (webkit_user_media_permission_is_for_audio_device( WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - permission_str = "Allow this site to access your microphone?"; + permission_str = "Allow '%s' to access your microphone?"; else if (webkit_user_media_permission_is_for_video_device( WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - permission_str = "Allow this site to access your webcam?"; + permission_str = "Allow '%s' to access your webcam?"; else return FALSE; } @@ -1180,7 +1188,7 @@ permission_request(WebKitWebView *v, WebKitPermissionRequest *r, gpointer data) GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - permission_str); + g_strdup_printf(permission_str, h)); gtk_widget_show(dialog); gint result = gtk_dialog_run(GTK_DIALOG(dialog)); switch(result) { -- cgit v1.2.3