2 * Copyright © 2003 Marco Pesenti Gritti
3 * Copyright © 2003 Christian Persch
4 * Copyright © 2005 Jean-François Rameau
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * $Id: ephy-adblock-manager.c 6952 2007-03-11 19:42:02Z chpe $
24 #include "ephy-debug.h"
26 #include "ephy-adblock-manager.h"
27 #include "ephy-adblock.h"
29 struct _EphyAdBlockManagerPrivate
34 G_DEFINE_TYPE (EphyAdBlockManager
, ephy_adblock_manager
, G_TYPE_OBJECT
);
36 #define EPHY_ADBLOCK_MANAGER_GET_PRIVATE(object) \
37 (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
38 EPHY_TYPE_ADBLOCK_MANAGER, EphyAdBlockManagerPrivate))
42 * ephy_adblock_manager_set_blocker:
43 * @shell: a #EphyAdBlockManager
44 * @blocker: the new blocker or NULL
46 * Set a new ad blocker. If #blocker is %NULL,
47 * ad blocking is toggled off.
51 ephy_adblock_manager_set_blocker (EphyAdBlockManager
*self
,
54 self
->priv
->blocker
= blocker
;
58 * ephy_adblock_manager_should_load:
59 * @shell: a #EphyAdBlockManager
60 * @url: the target url to be loaded or not
61 * @AdUriCheckType: what check to be applied (image, script, ...)
63 * Check if an url is to be loaded or not
65 * ReturnValue: TRUE if the url is to be loaded
68 ephy_adblock_manager_should_load (EphyAdBlockManager
*self
,
71 AdUriCheckType check_type
)
73 if (self
->priv
->blocker
!= NULL
)
75 return ephy_adblock_should_load (self
->priv
->blocker
,
81 /* default: let's process any url */
86 ephy_adblock_manager_init (EphyAdBlockManager
*self
)
88 EphyAdBlockManagerPrivate
*priv
;
90 LOG ("ephy_adblock_manager_init");
92 priv
= EPHY_ADBLOCK_MANAGER_GET_PRIVATE(self
);
98 ephy_adblock_manager_class_init (EphyAdBlockManagerClass
*klass
)
100 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
102 g_signal_new ("rules_changed",
103 G_OBJECT_CLASS_TYPE (object_class
),
105 G_STRUCT_OFFSET (EphyAdBlockManagerClass
, rules_changed
),
107 g_cclosure_marshal_VOID__VOID
,
112 g_type_class_add_private (object_class
, sizeof (EphyAdBlockManagerPrivate
));
116 * ephy_adblock_manager_edit_rule:
117 * @shell: a #EphyAdBlockManager
118 * @url: the target url on which the rule is based
119 * @allowed: TRUE if the url has to be blocked.
121 * Ask to the blocker a new rule based on @url.
125 ephy_adblock_manager_edit_rule (EphyAdBlockManager
*self
,
129 if (self
->priv
->blocker
!= NULL
)
131 ephy_adblock_edit_rule (self
->priv
->blocker
,
138 * ephy_adblock_manager_has_blocker:
139 * @shell: a #EphyAdBlockManager
141 * Check if Epiphany has currently an active blocker
143 * ReturnValue: TRUE if an active blocker is running
146 ephy_adblock_manager_has_blocker (EphyAdBlockManager
*self
)
148 return self
->priv
->blocker
!= NULL
;