summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@redhat.com>2023-05-01 16:15:04 -0500
committerMarge Bot <marge-bot@gnome.org>2023-05-07 22:22:46 +0000
commit5a79d275c7c3b6efc0c0bd9aa1efbc0dcf7e8f6d (patch)
tree0d2b0fd1cb4bf7db8f7afb43b0accfe5334dbec8
parentc96d97686cbf003950eca530fab1c5ae5c6adab6 (diff)
downloadepiphany-5a79d275c7c3b6efc0c0bd9aa1efbc0dcf7e8f6d.tar.gz
permissions-manager: clarify which permissions are stored
Most permissions get remembered in the permissions store, but the storage access ("cookies") permission gets requested each time, and I'm about to add a second permission type (clipboard access) that behaves the same, and webcam/microphone is also a bit simple. Note this incidentally fixes some incorrect handling of the cookies permission in ephy-window.c, where when we're dealing with a cookies permission we execute code that assumes webcam/microphone permission. Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1327>
-rw-r--r--embed/ephy-web-view.c6
-rw-r--r--lib/ephy-permissions-manager.c24
-rw-r--r--lib/ephy-permissions-manager.h2
-rw-r--r--src/ephy-window.c4
4 files changed, 30 insertions, 6 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 206dff747..97da49b0d 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -971,11 +971,11 @@ permission_request_cb (WebKitWebView *web_view,
permissions_manager = ephy_embed_shell_get_permissions_manager (ephy_embed_shell_get_default ());
- if (permission_type != EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE) {
+ if (ephy_permission_is_stored_by_permissions_manager (permission_type)) {
permission = ephy_permissions_manager_get_permission (permissions_manager,
permission_type,
origin);
- } else {
+ } else if (permission_type == EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE) {
EphyPermission video_permission;
EphyPermission mic_permission;
@@ -990,6 +990,8 @@ permission_request_cb (WebKitWebView *web_view,
permission = video_permission;
else
permission = EPHY_PERMISSION_UNDECIDED;
+ } else {
+ permission = EPHY_PERMISSION_UNDECIDED;
}
switch (permission) {
diff --git a/lib/ephy-permissions-manager.c b/lib/ephy-permissions-manager.c
index 4e1cfd458..9901bc99e 100644
--- a/lib/ephy-permissions-manager.c
+++ b/lib/ephy-permissions-manager.c
@@ -154,6 +154,8 @@ ephy_permissions_manager_new (void)
static const char *
permission_type_to_string (EphyPermissionType type)
{
+ g_assert (ephy_permission_is_stored_by_permissions_manager (type));
+
switch (type) {
case EPHY_PERMISSION_TYPE_SHOW_NOTIFICATIONS:
return "notifications-permission";
@@ -174,6 +176,24 @@ permission_type_to_string (EphyPermissionType type)
}
}
+/* Some permissions do not get remembered by the permissions manager. Generally,
+ * Epiphany prompts every time such permission is requested. But
+ * ACCESS_WEBCAM_AND_MICROPHONE is special: only separate ACCESS_MICROPHONE and
+ * ACCESS_WEBCAM permissions get stored.
+ */
+gboolean
+ephy_permission_is_stored_by_permissions_manager (EphyPermissionType type)
+{
+ switch (type) {
+ case EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE:
+ /* fallthrough */
+ case EPHY_PERMISSION_TYPE_COOKIES:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
EphyPermission
ephy_permissions_manager_get_permission (EphyPermissionsManager *manager,
EphyPermissionType type,
@@ -181,7 +201,7 @@ ephy_permissions_manager_get_permission (EphyPermissionsManager *manager,
{
GSettings *settings;
- g_assert (type != EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE);
+ g_assert (ephy_permission_is_stored_by_permissions_manager (type));
settings = ephy_permissions_manager_get_settings_for_origin (manager, origin);
return g_settings_get_enum (settings, permission_type_to_string (type));
@@ -263,7 +283,7 @@ ephy_permissions_manager_set_permission (EphyPermissionsManager *manager,
WebKitSecurityOrigin *webkit_origin;
GSettings *settings;
- g_assert (type != EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE);
+ g_assert (ephy_permission_is_stored_by_permissions_manager (type));
webkit_origin = webkit_security_origin_new_for_uri (origin);
if (webkit_origin == NULL)
diff --git a/lib/ephy-permissions-manager.h b/lib/ephy-permissions-manager.h
index a4da16c7c..788774a49 100644
--- a/lib/ephy-permissions-manager.h
+++ b/lib/ephy-permissions-manager.h
@@ -67,4 +67,6 @@ void ephy_permissions_manager_export_to_js_context (EphyPerm
JSCContext *js_context,
JSCValue *js_namespace);
+gboolean ephy_permission_is_stored_by_permissions_manager (EphyPermissionType type);
+
G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index a64e04865..3ec07da86 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2712,12 +2712,12 @@ set_permission (EphyPermissionPopover *popover,
EphyPermissionType permission_type = ephy_permission_popover_get_permission_type (popover);
const char *origin = ephy_permission_popover_get_origin (popover);
- if (permission_type != (EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE | EPHY_PERMISSION_TYPE_COOKIES)) {
+ if (ephy_permission_is_stored_by_permissions_manager (permission_type)) {
ephy_permissions_manager_set_permission (permissions_manager,
permission_type, origin,
response ? EPHY_PERMISSION_PERMIT
: EPHY_PERMISSION_DENY);
- } else {
+ } else if (EPHY_PERMISSION_TYPE_ACCESS_WEBCAM_AND_MICROPHONE) {
ephy_permissions_manager_set_permission (permissions_manager,
EPHY_PERMISSION_TYPE_ACCESS_WEBCAM,
origin,