Add config option for microphone and webcam access

This commit is contained in:
Quentin Rameau 2017-05-18 11:20:07 +02:00
parent f5be376ccc
commit bcd05ae321
2 changed files with 26 additions and 6 deletions

View File

@ -10,6 +10,8 @@ static char *cookiefile = "~/.surf/cookies.txt";
/* Webkit default features */ /* Webkit default features */
static Parameter defconfig[ParameterLast] = { static Parameter defconfig[ParameterLast] = {
SETB(AcceleratedCanvas, 1), SETB(AcceleratedCanvas, 1),
SETB(AccessMicrophone, 0),
SETB(AccessWebcam, 0),
SETB(Certificate, 0), SETB(Certificate, 0),
SETB(CaretBrowsing, 0), SETB(CaretBrowsing, 0),
SETV(CookiePolicies, "@Aa"), SETV(CookiePolicies, "@Aa"),

30
surf.c
View File

@ -61,6 +61,8 @@ enum {
typedef enum { typedef enum {
AcceleratedCanvas, AcceleratedCanvas,
AccessMicrophone,
AccessWebcam,
CaretBrowsing, CaretBrowsing,
Certificate, Certificate,
CookiePolicies, CookiePolicies,
@ -678,6 +680,10 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
case AcceleratedCanvas: case AcceleratedCanvas:
webkit_settings_set_enable_accelerated_2d_canvas(s, a->b); webkit_settings_set_enable_accelerated_2d_canvas(s, a->b);
break; break;
case AccessMicrophone:
return; /* do nothing */
case AccessWebcam:
return; /* do nothing */
case CaretBrowsing: case CaretBrowsing:
webkit_settings_set_enable_caret_browsing(s, a->b); webkit_settings_set_enable_caret_browsing(s, a->b);
refresh = 0; refresh = 0;
@ -1450,15 +1456,27 @@ mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers,
gboolean gboolean
permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c) permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c)
{ {
ParamName param = ParameterLast;
if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) { if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) {
if (curconfig[Geolocation].val.b) param = Geolocation;
webkit_permission_request_allow(r); } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(r)) {
else if (webkit_user_media_permission_is_for_audio_device(
webkit_permission_request_deny(r); WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r)))
return TRUE; param = AccessMicrophone;
else if (webkit_user_media_permission_is_for_video_device(
WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r)))
param = AccessWebcam;
} else {
return FALSE;
} }
return FALSE; if (curconfig[param].val.b)
webkit_permission_request_allow(r);
else
webkit_permission_request_deny(r);
return TRUE;
} }
gboolean gboolean