aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-adblock.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-10-03 04:00:09 +0800
committerXan Lopez <xan@igalia.com>2012-10-03 05:21:15 +0800
commit9c54a252230ceaf38a3accd5504b3e4bd5959c48 (patch)
tree6a8c33d4e4e322c2352f71974bf488359c6fc7f7 /embed/ephy-adblock.c
parent7b72dcabf03b0d989da6cb42f4b5adccba54aa33 (diff)
downloadgsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar.gz
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar.bz2
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar.lz
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar.xz
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.tar.zst
gsoc2013-epiphany-9c54a252230ceaf38a3accd5504b3e4bd5959c48.zip
adblock: get rid of AdBlock interface
No need for this now, just make EphyAdBlock a concrete class implementing the adblock functionality. https://bugzilla.gnome.org/show_bug.cgi?id=681657
Diffstat (limited to 'embed/ephy-adblock.c')
-rw-r--r--embed/ephy-adblock.c106
1 files changed, 70 insertions, 36 deletions
diff --git a/embed/ephy-adblock.c b/embed/ephy-adblock.c
index 78aadbf3e..7a06ff8c6 100644
--- a/embed/ephy-adblock.c
+++ b/embed/ephy-adblock.c
@@ -1,13 +1,16 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
- * Copyright © 2003 Marco Pesenti Gritti
- * Copyright © 2003 Christian Persch
- * Copyright © 2005 Jean-François Rameau
+ * Copyright © 2011, 2012 Igalia S.L.
*
* 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.
*
+ * Some parts of this file based on the previous 'adblock' extension,
+ * licensed with the GNU General Public License 2 and later versions,
+ * Copyright (C) 2003 Marco Pesenti Gritti, Christian Persch.
+ *
* 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
@@ -15,48 +18,79 @@
*
* 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.
- *
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
-
#include "ephy-adblock.h"
-GType
-ephy_adblock_get_type (void)
+#include "ephy-adblock-manager.h"
+#include "ephy-debug.h"
+#include "ephy-embed-shell.h"
+#include "ephy-file-helpers.h"
+#include "uri-tester.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#define EPHY_ADBLOCK_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ADBLOCK, EphyAdBlockPrivate))
+
+struct EphyAdBlockPrivate
{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EphyAdBlockIface),
- NULL,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EphyAdBlock",
- &our_info, 0);
- }
-
- return type;
+ UriTester *tester;
+};
+
+G_DEFINE_TYPE (EphyAdBlock, ephy_adblock, G_TYPE_OBJECT)
+
+/* Private functions. */
+
+static void
+ephy_adblock_init (EphyAdBlock *adblock)
+{
+ LOG ("EphyAdblock initialising");
+
+ adblock->priv = EPHY_ADBLOCK_GET_PRIVATE (adblock);
+ adblock->priv->tester = uri_tester_new ();
+}
+
+static void
+ephy_adblock_dispose (GObject *object)
+{
+ EphyAdBlock *adblock = NULL;
+
+ LOG ("EphyAdblock disposing");
+
+ adblock = EPHY_ADBLOCK (object);
+ g_clear_object (&adblock->priv->tester);
+
+ G_OBJECT_CLASS (ephy_adblock_parent_class)->dispose (object);
+}
+
+static void
+ephy_adblock_class_init (EphyAdBlockClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = ephy_adblock_dispose;
+
+ g_type_class_add_private (object_class, sizeof (EphyAdBlockPrivate));
}
gboolean
ephy_adblock_should_load (EphyAdBlock *adblock,
- EphyEmbed *embed,
- const char *url,
- AdUriCheckType check_type)
+ EphyEmbed *embed,
+ const char *url,
+ AdUriCheckType type)
{
- EphyAdBlockIface *iface = EPHY_ADBLOCK_GET_IFACE (adblock);
-
- if (iface->should_load)
- {
- return iface->should_load (adblock, embed, url, check_type);
- }
-
- return TRUE;
+ EphyWebView* web_view = NULL;
+ const char *address = NULL;
+
+ g_return_val_if_fail (adblock != NULL, TRUE);
+ g_return_val_if_fail (embed != NULL, TRUE);
+ g_return_val_if_fail (url, TRUE);
+
+ web_view = ephy_embed_get_web_view (embed);
+ address = ephy_web_view_get_address (web_view);
+
+ return !uri_tester_test_uri (adblock->priv->tester, url, address, type);
}