[epiphany/pgriffis/web-extension/notifications: 2/3] WebExtensions: Respect notifications permission
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/pgriffis/web-extension/notifications: 2/3] WebExtensions: Respect notifications permission
- Date: Thu, 9 Jun 2022 13:25:50 +0000 (UTC)
commit 801c3ecd7c0bb302b396de131d05ee2015142e46
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed Jun 8 19:43:46 2022 -0500
WebExtensions: Respect notifications permission
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1141>
src/webextension/api/notifications.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/webextension/api/notifications.c b/src/webextension/api/notifications.c
index 09f4f2332..fcf8c841d 100644
--- a/src/webextension/api/notifications.c
+++ b/src/webextension/api/notifications.c
@@ -68,9 +68,15 @@ ephy_web_extension_api_notifications_handler (EphyWebExtension *self,
GTask *task)
{
g_autoptr (GError) error = NULL;
- guint idx;
- for (idx = 0; idx < G_N_ELEMENTS (notifications_handlers); idx++) {
+ if (!ephy_web_extension_has_permission (self, "notifications")) {
+ g_warning ("Extension %s tried to use notifications without permission.", ephy_web_extension_get_name
(self));
+ error = g_error_new_literal (WEB_EXTENSION_ERROR, WEB_EXTENSION_ERROR_PERMISSION_DENIED, "Permission
Denied");
+ g_task_return_error (task, g_steal_pointer (&error));
+ return;
+ }
+
+ for (guint idx = 0; idx < G_N_ELEMENTS (notifications_handlers); idx++) {
EphyWebExtensionSyncApiHandler handler = notifications_handlers[idx];
char *ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]