Index: ephy-embed-single.c =================================================================== RCS file: /cvs/gnome/epiphany/embed/ephy-embed-single.c,v retrieving revision 1.40 diff -u -r1.40 ephy-embed-single.c --- ephy-embed-single.c 18 Nov 2005 19:24:16 -0000 1.40 +++ ephy-embed-single.c 13 Dec 2005 20:29:45 -0000 @@ -124,6 +124,26 @@ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); /** + * EphyEmbedSingle::should-load: + * @single: + * @url: The url to be checked + * @content_type: what the url is pointing to + * + * The ::should-load signal is emitted when an url is requested. Returning TRUE means + * that the url is accepted. Otherwise, the url is rejected and therefore not loaded. + **/ + g_signal_new ("should-load", + EPHY_TYPE_EMBED_SINGLE, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyEmbedSingleIface, should_load), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__STRING_UINT, + G_TYPE_BOOLEAN, + 2, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_UINT | G_SIGNAL_TYPE_STATIC_SCOPE); + +/** * EphyEmbedSingle::add-search-engine * @single: * @url: The url of the search engine definition file Index: ephy-embed-single.h =================================================================== RCS file: /cvs/gnome/epiphany/embed/ephy-embed-single.h,v retrieving revision 1.34 diff -u -r1.34 ephy-embed-single.h --- ephy-embed-single.h 18 Nov 2005 19:24:16 -0000 1.34 +++ ephy-embed-single.h 13 Dec 2005 20:29:46 -0000 @@ -58,6 +58,10 @@ const char *icon_url, const char *title); + gboolean (* should_load) (EphyEmbedSingle *single, + const char *url, + guint content_type); + /* Methods */ GtkWidget * (* open_window) (EphyEmbedSingle *single, Index: mozilla/EphyContentPolicy.cpp =================================================================== RCS file: /cvs/gnome/epiphany/embed/mozilla/EphyContentPolicy.cpp,v retrieving revision 1.17 diff -u -r1.17 EphyContentPolicy.cpp --- mozilla/EphyContentPolicy.cpp 19 Nov 2005 13:21:57 -0000 1.17 +++ mozilla/EphyContentPolicy.cpp 13 Dec 2005 20:29:46 -0000 @@ -76,17 +76,28 @@ *aDecision = nsIContentPolicy::ACCEPT; - PRBool isHttp = PR_FALSE, isHttps = PR_FALSE; - aContentLocation->SchemeIs ("http", &isHttp); - aContentLocation->SchemeIs ("https", &isHttps); - if (isHttp || isHttps) return NS_OK; - /* We have to always allow these, else forms and scrollbars break */ PRBool isChrome = PR_FALSE, isResource = PR_FALSE; aContentLocation->SchemeIs ("chrome", &isChrome); aContentLocation->SchemeIs ("resource", &isResource); if (isChrome || isResource) return NS_OK; + gboolean result = FALSE; + nsEmbedCString spec; + aContentLocation->GetSpec(spec); + + g_signal_emit_by_name (mEmbedSingle, "should-load", spec.get (), aContentType, &result); + if (result) + { + *aDecision = nsIContentPolicy::REJECT_REQUEST; + return NS_OK; + } + + PRBool isHttp = PR_FALSE, isHttps = PR_FALSE; + aContentLocation->SchemeIs ("http", &isHttp); + aContentLocation->SchemeIs ("https", &isHttps); + if (isHttp || isHttps) return NS_OK; + nsEmbedCString contentSpec; aContentLocation->GetSpec (contentSpec); if (strcmp (contentSpec.get(), "about:blank") == 0) return NS_OK; @@ -155,7 +166,6 @@ { *_retval = PR_FALSE; } - return NS_OK; } -------------------------------------------------------------------------------------- adblock extension -------------------------------------------------------------------------------------- static gboolean ephy_adblock_extension_should_load_cb (GObject *object, const char *url, AdUriCheckType type, EphyAdblockExtension *extension) { return ad_uri_tester_test_uri (extension->priv->tester, url, type); } -------------------------------------------------------------------------------------- page-info extension -------------------------------------------------------------------------------------- Index: page-info-dialog.c =================================================================== RCS file: /cvs/gnome/epiphany-extensions/extensions/page-info/page-info-dialog.c,v retrieving revision 1.50 diff -u -r1.50 page-info-dialog.c --- page-info-dialog.c 30 Oct 2005 19:21:11 -0000 1.50 +++ page-info-dialog.c 13 Dec 2005 20:33:19 -0000 @@ -33,8 +33,10 @@ #include #include +#include #include #include +#include /* non-installed ephy headers */ #include "ephy-gui.h" @@ -48,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -891,6 +894,7 @@ enum { + COL_MEDIUM_BLOCKED, COL_MEDIUM_URL, COL_MEDIUM_TYPE, COL_MEDIUM_TYPE_TEXT, @@ -902,6 +906,7 @@ enum { + TV_COL_MEDIUM_BLOCKED, TV_COL_MEDIUM_URL, TV_COL_MEDIUM_TYPE_TEXT, TV_COL_MEDIUM_ALT, @@ -1200,7 +1205,8 @@ g_signal_connect (box, "realize", G_CALLBACK (page_info_media_box_realize_cb), dialog); - liststore = gtk_list_store_new (7, + liststore = gtk_list_store_new (8, + G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, @@ -1233,6 +1239,16 @@ media_treeview_selection_changed_cb, page, NULL); + renderer = gtk_cell_renderer_toggle_new (); + gtk_tree_view_insert_column_with_attributes (treeview, + TV_COL_MEDIUM_BLOCKED, _("Blocked"), + renderer, + "active", COL_MEDIUM_BLOCKED, + NULL); + column = gtk_tree_view_get_column (treeview, COL_MEDIUM_BLOCKED); + gtk_tree_view_column_set_reorderable (column, TRUE); + gtk_tree_view_column_set_sort_column_id (column, TV_COL_MEDIUM_BLOCKED);+ renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (treeview, TV_COL_MEDIUM_URL, @@ -1337,7 +1353,11 @@ PageInfoDialog *dialog = ipage->dialog; GtkListStore *store = tpage->store; GtkTreeIter iter; - GList *media, *l; + GList *media, *l; + GObject *single; + gboolean result; + + single = ephy_embed_shell_get_embed_single (embed_shell); media = dialog->priv->page_info->media; @@ -1345,8 +1365,11 @@ { EmbedPageMedium *media = (EmbedPageMedium *) l->data; + g_signal_emit_by_name (single, "should-load", media->url, 3U, &result); + gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, + COL_MEDIUM_BLOCKED, result, COL_MEDIUM_URL, media->url, COL_MEDIUM_TYPE_TEXT, mozilla_embed_type_to_string (media->type), COL_MEDIUM_ALT, media->alt, @@ -1390,6 +1413,7 @@ enum { + COL_LINK_BLOCKED, COL_LINK_URL, COL_LINK_TITLE, COL_LINK_REL @@ -1448,7 +1472,8 @@ treeview = GTK_TREE_VIEW (ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[PROP_LINKS_LINK_TREEVIEW].id)); - liststore = gtk_list_store_new (3, + liststore = gtk_list_store_new (4, + G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); @@ -1474,6 +1499,16 @@ G_CALLBACK(page_info_drag_begin_cb), NULL); + renderer = gtk_cell_renderer_toggle_new (); + gtk_tree_view_insert_column_with_attributes (treeview, + COL_LINK_BLOCKED, _("Blocked"), + renderer, + "active", COL_LINK_BLOCKED,+ NULL); + column = gtk_tree_view_get_column (treeview, COL_LINK_BLOCKED); + gtk_tree_view_column_set_reorderable (column, TRUE); + gtk_tree_view_column_set_sort_column_id (column, COL_LINK_BLOCKED); + renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (treeview, COL_LINK_URL, @@ -1526,6 +1561,10 @@ GtkListStore *store = tpage->store; GtkTreeIter iter; GList *links, *l; + GObject *single; + gboolean result; + + single = ephy_embed_shell_get_embed_single (embed_shell); links = dialog->priv->page_info->links; @@ -1533,8 +1572,11 @@ { EmbedPageLink *link = (EmbedPageLink *) l->data; + g_signal_emit_by_name (single, "should-load", link->url, 1U, &result); + gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, + COL_LINK_BLOCKED, result, COL_LINK_URL, link->url, COL_LINK_TITLE, link->title, COL_LINK_REL, link->rel,