diff options
-rw-r--r-- | embed/Makefile.am | 2 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 55 | ||||
-rw-r--r-- | embed/ephy-permission-manager.c | 284 | ||||
-rw-r--r-- | embed/ephy-permission-manager.h | 132 | ||||
-rw-r--r-- | embed/ephy-web-view.c | 47 | ||||
-rw-r--r-- | src/epiphany.h.in | 1 |
6 files changed, 3 insertions, 518 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am index 3e44814fb..3efa9ed26 100644 --- a/embed/Makefile.am +++ b/embed/Makefile.am @@ -29,7 +29,6 @@ INST_H_FILES = \ ephy-embed-shell.h \ ephy-embed-utils.h \ ephy-overview.h \ - ephy-permission-manager.h \ ephy-web-view.h @@ -53,7 +52,6 @@ libephyembed_la_SOURCES = \ ephy-encodings.c \ ephy-file-monitor.c \ ephy-overview.c \ - ephy-permission-manager.c \ ephy-request-about.c \ ephy-embed-prefs.c \ ephy-web-view.c \ diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index 190beaeec..35e57b9de 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -27,7 +27,6 @@ #include "ephy-embed-shell.h" #include "ephy-embed-type-builtins.h" #include "ephy-file-helpers.h" -#include "ephy-permission-manager.h" #include "ephy-prefs.h" #include "ephy-profile-utils.h" #include "ephy-request-about.h" @@ -54,11 +53,7 @@ struct _EphyEmbedSinglePrivate { #endif }; -static void ephy_permission_manager_iface_init (EphyPermissionManagerIface *iface); - -G_DEFINE_TYPE_WITH_CODE (EphyEmbedSingle, ephy_embed_single, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (EPHY_TYPE_PERMISSION_MANAGER, - ephy_permission_manager_iface_init)) +G_DEFINE_TYPE (EphyEmbedSingle, ephy_embed_single, G_TYPE_OBJECT) static void form_auth_data_free (EphyEmbedSingleFormAuthData *data) @@ -233,54 +228,6 @@ ephy_embed_single_class_init (EphyEmbedSingleClass *klass) g_type_class_add_private (object_class, sizeof (EphyEmbedSinglePrivate)); } -static void -impl_permission_manager_add (EphyPermissionManager *manager, - const char *host, - const char *type, - EphyPermission permission) -{ -} - -static void -impl_permission_manager_remove (EphyPermissionManager *manager, - const char *host, - const char *type) -{ -} - -static void -impl_permission_manager_clear (EphyPermissionManager *manager) -{ -} - -static EphyPermission -impl_permission_manager_test (EphyPermissionManager *manager, - const char *host, - const char *type) -{ - g_return_val_if_fail (type != NULL && type[0] != '\0', EPHY_PERMISSION_DEFAULT); - - return (EphyPermission)0; -} - -static GList * -impl_permission_manager_list (EphyPermissionManager *manager, - const char *type) -{ - GList *list = NULL; - return list; -} - -static void -ephy_permission_manager_iface_init (EphyPermissionManagerIface *iface) -{ - iface->add = impl_permission_manager_add; - iface->remove = impl_permission_manager_remove; - iface->clear = impl_permission_manager_clear; - iface->test = impl_permission_manager_test; - iface->list = impl_permission_manager_list; -} - #ifndef HAVE_WEBKIT2 static void cache_size_cb (GSettings *settings, diff --git a/embed/ephy-permission-manager.c b/embed/ephy-permission-manager.c deleted file mode 100644 index 19bdace60..000000000 --- a/embed/ephy-permission-manager.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003 Christian Persch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "ephy-permission-manager.h" - -#include "ephy-embed-type-builtins.h" -#include "ephy-debug.h" - -G_DEFINE_BOXED_TYPE (EphyPermissionInfo, ephy_permission_info, - ephy_permission_info_copy, ephy_permission_info_free) - -/** - * ephy_permission_info_new: - * @host: a host name - * @type: an #EphyPermissionType - * @permission: whether @host should be allowed to do what @type specifies - * - * Return value: the new #EphyPermissionInfo - **/ -EphyPermissionInfo * -ephy_permission_info_new (const char *host, - const char *type, - EphyPermission permission) -{ - EphyPermissionInfo *info = g_slice_new0 (EphyPermissionInfo); - - info->host = g_strdup (host); - info->qtype = g_quark_from_string (type); - info->permission = permission; - - return info; -} - -/** - * ephy_permission_info_copy: - * @info: an #EphyPermissionInfo - * - * Return value: a copy of @info - **/ -EphyPermissionInfo * -ephy_permission_info_copy (const EphyPermissionInfo *info) -{ - EphyPermissionInfo *copy = g_slice_new0 (EphyPermissionInfo); - - copy->host = g_strdup (info->host); - copy->qtype = info->qtype; - copy->permission = info->permission; - - return copy; -} - -/** - * ephy_permission_info_free: - * @info: an #EphyPermissionInfo - * - * Frees @info. - **/ -void -ephy_permission_info_free (EphyPermissionInfo *info) -{ - if (info != NULL) - { - g_free (info->host); - g_slice_free (EphyPermissionInfo, info); - } -} - -/* EphyPermissionManager */ - -static void ephy_permission_manager_base_init (gpointer g_class); - -GType -ephy_permission_manager_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - const GTypeInfo our_info = - { - sizeof (EphyPermissionManagerIface), - ephy_permission_manager_base_init, - NULL, - }; - - type = g_type_register_static (G_TYPE_INTERFACE, - "EphyPermissionManager", - &our_info, - (GTypeFlags) 0); - } - - return type; -} - -static void -ephy_permission_manager_base_init (gpointer g_class) -{ - static gboolean initialised = FALSE; - - if (initialised == FALSE) - { - /** - * EphyPermissionManager::permission-added: - * @manager: the #EphyPermissionManager - * @info: a #EphyPermissionInfo - * - * The permission-added signal is emitted when a permission entry has - * been added. - */ - g_signal_new ("permission-added", - EPHY_TYPE_PERMISSION_MANAGER, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyPermissionManagerIface, added), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, - EPHY_TYPE_PERMISSION_INFO | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * EphyPermissionManager::permission-changed: - * @manager: the #EphyPermissionManager - * @info: a #EphyPermissionInfo - * - * The permission-changed signal is emitted when a permission entry has - * been changed. - */ - g_signal_new ("permission-changed", - EPHY_TYPE_PERMISSION_MANAGER, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyPermissionManagerIface, changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, - EPHY_TYPE_PERMISSION_INFO | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * EphyPermissionManager::permission-deleted: - * @manager: the #EphyPermissionManager - * @info: a #EphyPermissionInfo - * - * The permission-deleted signal is emitted when a permission entry has - * been deleted. - */ - g_signal_new ("permission-deleted", - EPHY_TYPE_PERMISSION_MANAGER, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyPermissionManagerIface, deleted), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, - EPHY_TYPE_PERMISSION_INFO | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * EphyPermissionManager::permissions-cleared: - * @manager: the #EphyPermissionManager - * - * The permissions-cleared signal is emitted when the permissions - * database has been cleared. - */ - g_signal_new ("permissions-cleared", - EPHY_TYPE_PERMISSION_MANAGER, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyPermissionManagerIface, cleared), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - initialised = TRUE; - } -} - -/** - * ephy_permission_manager_add_permission: - * @manager: the #EphyPermissionManager - * @host: a website URL - * @type: a string to identify the type of the permission - * @permission: either %EPHY_PERMISSION_ALLOWED or %EPHY_PERMISSION_DENIED - * - * Adds the specified permission to the permissions database. - **/ -void -ephy_permission_manager_add_permission (EphyPermissionManager *manager, - const char *host, - const char *type, - EphyPermission permission) -{ - EphyPermissionManagerIface *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - iface->add (manager, host, type, permission); -} - -/** - * ephy_permission_manager_remove_permission: - * @manager: the #EphyPermissionManager - * @host: a website URL - * @type: a string to identify the type of the permission - * - * Removes the specified permission from the permissions database. This implies - * that the browser should use defaults when next visiting the specified - * @host's web pages. - **/ -void -ephy_permission_manager_remove_permission (EphyPermissionManager *manager, - const char *host, - const char *type) -{ - EphyPermissionManagerIface *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - iface->remove (manager, host, type); -} - -/** - * ephy_permission_manager_clear_permission: - * @manager: the #EphyPermissionManager - * - * Clears the permissions database. This cannot be undone. - **/ -void -ephy_permission_manager_clear_permissions (EphyPermissionManager *manager) -{ - EphyPermissionManagerIface *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - iface->clear (manager); -} - -/** - * ephy_permission_manager_test_permission: - * @manager: the #EphyPermissionManager - * @host: a website URL - * @type: a string to identify the type of the permission - * - * Retrieves an #EphyPermissionType from the permissions database. If there is - * no entry for this @type and @host, it will return %EPHY_PERMISSION_DEFAULT. - * In that case, the caller may need to determine the appropriate default - * behavior. - * - * Return value: the permission of type #EphyPermission - **/ -EphyPermission -ephy_permission_manager_test_permission (EphyPermissionManager *manager, - const char *host, - const char *type) -{ - EphyPermissionManagerIface *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - return iface->test (manager, host, type); -} - -/** - * ephy_permission_manager_list_permissions: - * @manager: the #EphyPermissionManager - * @type: a string to identify the type of the permission - * - * Lists all permission entries of type @type in the permissions database, each - * as its own #EphyPermissionInfo. These entries must be freed using - * ephy_permission_info_free(). - * - * Return value: (transfer none) (element-type EphyPermissionInfo): the list of permission database entries - **/ -GList * -ephy_permission_manager_list_permissions (EphyPermissionManager *manager, - const char *type) -{ - EphyPermissionManagerIface *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - return iface->list (manager, type); -} diff --git a/embed/ephy-permission-manager.h b/embed/ephy-permission-manager.h deleted file mode 100644 index e09e82dfe..000000000 --- a/embed/ephy-permission-manager.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003 Christian Persch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION) -#error "Only <epiphany/epiphany.h> can be included directly." -#endif - -#ifndef EPHY_PERMISSION_MANAGER_H -#define EPHY_PERMISSION_MANAGER_H - -#include <glib-object.h> -#include <glib.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_PERMISSION_MANAGER (ephy_permission_manager_get_type ()) -#define EPHY_PERMISSION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManager)) -#define EPHY_PERMISSION_MANAGER_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManagerIface)) -#define EPHY_IS_PERMISSION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_PERMISSION_MANAGER)) -#define EPHY_IS_PERMISSION_MANAGER_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_PERMISSION_MANAGER)) -#define EPHY_PERMISSION_MANAGER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_PERMISSION_MANAGER, EphyPermissionManagerIface)) - -#define EPHY_TYPE_PERMISSION_INFO (ephy_permission_info_get_type ()) - -#define EPHY_PERMISSION_TYPE_COOKIE "cookie" -#define EPHY_PERMISSION_TYPE_IMAGE "image" -#define EPHY_PERMISSION_TYPE_POPUP "popup" - -typedef enum -{ - EPHY_PERMISSION_ALLOWED, - EPHY_PERMISSION_DENIED, - EPHY_PERMISSION_DEFAULT -} EphyPermission; - -typedef struct _EphyPermissionInfo EphyPermissionInfo; - -typedef struct _EphyPermissionManager EphyPermissionManager; -typedef struct _EphyPermissionManagerIface EphyPermissionManagerIface; - -struct _EphyPermissionInfo -{ - char *host; - GQuark qtype; - EphyPermission permission; -}; - -struct _EphyPermissionManagerIface -{ - GTypeInterface base_iface; - - /* Signals */ - void (* added) (EphyPermissionManager *manager, - EphyPermissionInfo *info); - void (* changed) (EphyPermissionManager *manager, - EphyPermissionInfo *info); - void (* deleted) (EphyPermissionManager *manager, - EphyPermissionInfo *info); - void (* cleared) (EphyPermissionManager *manager); - - /* Methods */ - void (* add) (EphyPermissionManager *manager, - const char *host, - const char *type, - EphyPermission permission); - void (* remove) (EphyPermissionManager *manager, - const char *host, - const char *type); - void (* clear) (EphyPermissionManager *manager); - EphyPermission (* test) (EphyPermissionManager *manager, - const char *host, - const char *type); - GList * (* list) (EphyPermissionManager *manager, - const char *type); -}; - -/* EphyPermissionInfo */ - -GType ephy_permission_get_type (void); - -GType ephy_permission_info_get_type (void); - -EphyPermissionInfo *ephy_permission_info_new (const char *host, - const char *type, - EphyPermission permission); - -EphyPermissionInfo *ephy_permission_info_copy (const EphyPermissionInfo *info); - -void ephy_permission_info_free (EphyPermissionInfo *info); - -/* EphyPermissionManager */ - -GType ephy_permission_manager_get_type (void); - -void ephy_permission_manager_add_permission (EphyPermissionManager *manager, - const char *host, - const char *type, - EphyPermission permission); - -void ephy_permission_manager_remove_permission (EphyPermissionManager *manager, - const char *host, - const char *type); - -void ephy_permission_manager_clear_permissions (EphyPermissionManager *manager); - -EphyPermission ephy_permission_manager_test_permission (EphyPermissionManager *manager, - const char *host, - const char *type); - -GList * ephy_permission_manager_list_permissions (EphyPermissionManager *manager, - const char *type); - -G_END_DECLS - -#endif diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index a2e6ce95f..e65358026 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -38,7 +38,6 @@ #include "ephy-file-monitor.h" #include "ephy-history-service.h" #include "ephy-overview.h" -#include "ephy-permission-manager.h" #include "ephy-prefs.h" #include "ephy-profile-utils.h" #include "ephy-settings.h" @@ -283,24 +282,6 @@ static void ephy_web_view_set_popups_allowed (EphyWebView *view, gboolean allowed) { - const char *location; - EphyPermissionManager *manager; - EphyPermission permission; - - manager = EPHY_PERMISSION_MANAGER - (ephy_embed_shell_get_embed_single (ephy_embed_shell_get_default ())); - g_return_if_fail (EPHY_IS_PERMISSION_MANAGER (manager)); - - permission = allowed ? EPHY_PERMISSION_ALLOWED - : EPHY_PERMISSION_DENIED; - - location = ephy_web_view_get_address (view); - g_return_if_fail (location != NULL); - - ephy_permission_manager_add_permission (manager, location, - EPHY_PERMISSION_TYPE_POPUP, - permission); - if (allowed) { popups_manager_show_all (view); } else { @@ -311,38 +292,14 @@ ephy_web_view_set_popups_allowed (EphyWebView *view, static gboolean ephy_web_view_get_popups_allowed (EphyWebView *view) { - EphyPermissionManager *permission_manager; - EphyPermission response; const char *location; gboolean allow; - permission_manager = EPHY_PERMISSION_MANAGER - (ephy_embed_shell_get_embed_single (ephy_embed_shell_get_default ())); - g_return_val_if_fail (EPHY_IS_PERMISSION_MANAGER (permission_manager), - FALSE); - location = ephy_web_view_get_address (view); if (location == NULL) return FALSE;/* FALSE, TRUE… same thing */ - response = ephy_permission_manager_test_permission - (permission_manager, location, EPHY_PERMISSION_TYPE_POPUP); - - switch (response) { - case EPHY_PERMISSION_ALLOWED: - allow = TRUE; - break; - case EPHY_PERMISSION_DENIED: - allow = FALSE; - break; - case EPHY_PERMISSION_DEFAULT: - default: - allow = g_settings_get_boolean (EPHY_SETTINGS_WEB, - EPHY_PREFS_WEB_ENABLE_POPUPS); - break; - } - - LOG ("ephy_web_view_get_popups_allowed: view %p, allowed: %d", view, allow); - + allow = g_settings_get_boolean (EPHY_SETTINGS_WEB, + EPHY_PREFS_WEB_ENABLE_POPUPS); return allow; } diff --git a/src/epiphany.h.in b/src/epiphany.h.in index 52550de1a..9c49f35c3 100644 --- a/src/epiphany.h.in +++ b/src/epiphany.h.in @@ -52,7 +52,6 @@ #include <epiphany/ephy-node-db.h> #include <epiphany/ephy-node.h> #include <epiphany/ephy-notebook.h> -#include <epiphany/ephy-permission-manager.h> #include <epiphany/ephy-session.h> #include <epiphany/ephy-shell.h> #include <epiphany/ephy-state.h> |