[hackers] [surf] Add config option for microphone and webcam access || Quentin Rameau
commit bcd05ae321de686840fd560931f2894f62ba8345
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu May 18 11:20:07 2017 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sun May 21 17:13:02 2017 +0200
Add config option for microphone and webcam access
diff --git a/config.def.h b/config.def.h
index 50dd739..3a159ec 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -10,6 +10,8 @@ static char *cookiefile = "~/.surf/cookies.txt";
/* Webkit default features */
static Parameter defconfig[ParameterLast] = {
SETB(AcceleratedCanvas, 1),
+ SETB(AccessMicrophone, 0),
+ SETB(AccessWebcam, 0),
SETB(Certificate, 0),
SETB(CaretBrowsing, 0),
SETV(CookiePolicies, "_AT_Aa"),
diff --git a/surf.c b/surf.c
index 2d3a6f5..c11a095 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -61,6 +61,8 @@ enum {
typedef enum {
AcceleratedCanvas,
+ AccessMicrophone,
+ AccessWebcam,
CaretBrowsing,
Certificate,
CookiePolicies,
_AT_@ -678,6 +680,10 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
case AcceleratedCanvas:
webkit_settings_set_enable_accelerated_2d_canvas(s, a->b);
break;
+ case AccessMicrophone:
+ return; /* do nothing */
+ case AccessWebcam:
+ return; /* do nothing */
case CaretBrowsing:
webkit_settings_set_enable_caret_browsing(s, a->b);
refresh = 0;
_AT_@ -1450,15 +1456,27 @@ mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers,
gboolean
permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c)
{
+ ParamName param = ParameterLast;
+
if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) {
- if (curconfig[Geolocation].val.b)
- webkit_permission_request_allow(r);
- else
- webkit_permission_request_deny(r);
- return TRUE;
+ param = Geolocation;
+ } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(r)) {
+ if (webkit_user_media_permission_is_for_audio_device(
+ WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r)))
+ 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
Received on Sat Jun 03 2017 - 10:39:13 CEST
This archive was generated by hypermail 2.3.0
: Sat Jun 03 2017 - 10:48:19 CEST