aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--NEWS1
-rw-r--r--doc/reference/tmpl/ephy-embed.sgml6
-rw-r--r--doc/reference/tmpl/ephy-glade.sgml13
-rw-r--r--doc/reference/tmpl/ephy-node-db.sgml101
-rw-r--r--doc/reference/tmpl/epiphany-unused.sgml106
-rw-r--r--embed/ephy-embed-single.c29
-rw-r--r--embed/ephy-embed-single.h19
-rw-r--r--embed/mozilla/EphyContentPolicy.cpp125
-rw-r--r--embed/mozilla/EphyContentPolicy.h2
-rw-r--r--lib/ephy-marshal.list1
11 files changed, 275 insertions, 144 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f5e9c043..54c4e9064 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2005-01-11 Christian Persch <chpe@cvs.gnome.org>
+ * embed/ephy-embed-single.c: (ephy_embed_single_iface_init):
+ * embed/ephy-embed-single.h:
+
+ Add "check-content" signal.
+
+ * embed/mozilla/EphyContentPolicy.cpp:
+ * embed/mozilla/EphyContentPolicy.h:
+
+ Emit from here.
+
+ * lib/ephy-marshal.list:
+
+ New marshal.
+
+2005-01-11 Christian Persch <chpe@cvs.gnome.org>
+
* embed/ephy-cookie-manager.h:
* embed/mozilla/EphySingle.cpp:
diff --git a/NEWS b/NEWS
index ad5606f93..8f78918fc 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,6 @@ Epiphany 1.5.4
New features
* Make extensions loading extensible
- * Add dbus backend (diabled by default; used by net-monitor extension)
Interface improvements
diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml
index 7c5a35a4d..271d504bf 100644
--- a/doc/reference/tmpl/ephy-embed.sgml
+++ b/doc/reference/tmpl/ephy-embed.sgml
@@ -197,6 +197,10 @@ be done by casting).
@:
@:
@:
+@:
+@:
+@:
+@:
@:
<!-- ##### SIGNAL EphyEmbed::ge-security-change ##### -->
@@ -221,12 +225,12 @@ be done by casting).
</para>
@base_iface:
+@context_menu:
@favicon:
@location:
@net_state:
@dom_mouse_click:
@dom_mouse_down:
-@context_menu:
@popup_blocked:
@security_change:
@zoom_change:
diff --git a/doc/reference/tmpl/ephy-glade.sgml b/doc/reference/tmpl/ephy-glade.sgml
index 4251a1684..faa726514 100644
--- a/doc/reference/tmpl/ephy-glade.sgml
+++ b/doc/reference/tmpl/ephy-glade.sgml
@@ -20,3 +20,16 @@ After retrieving a #GladeXML object from ephy_glade_widget_new(), regular
</para>
+<!-- ##### FUNCTION ephy_glade_widget_new ##### -->
+<para>
+
+</para>
+
+@file:
+@widget_name:
+@root:
+@data:
+@domain:
+@Returns:
+
+
diff --git a/doc/reference/tmpl/ephy-node-db.sgml b/doc/reference/tmpl/ephy-node-db.sgml
index f79f64142..3cffa4c64 100644
--- a/doc/reference/tmpl/ephy-node-db.sgml
+++ b/doc/reference/tmpl/ephy-node-db.sgml
@@ -28,3 +28,104 @@ and restored using ephy_node_db_load_from_file().
</para>
+<!-- ##### STRUCT EphyNodeDb ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EphyNodeDb:immutable ##### -->
+<para>
+%TRUE if no #EphyNode<!-- -->s can be added, removed or modified from this
+#EphyNodeDb
+</para>
+
+<!-- ##### ARG EphyNodeDb:name ##### -->
+<para>
+A string identifier unique to this #EphyNodeDb
+</para>
+
+<!-- ##### FUNCTION ephy_node_db_get_by_name ##### -->
+<para>
+
+</para>
+
+@name:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_new ##### -->
+<para>
+
+</para>
+
+@name:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_load_from_file ##### -->
+<para>
+
+</para>
+
+@db:
+@xml_file:
+@xml_root:
+@xml_version:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_write_to_xml_safe ##### -->
+<para>
+
+</para>
+
+@db:
+@filename:
+@root:
+@version:
+@comment:
+@node:
+@Varargs:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_get_name ##### -->
+<para>
+
+</para>
+
+@db:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_is_immutable ##### -->
+<para>
+
+</para>
+
+@db:
+@Returns:
+
+
+<!-- ##### FUNCTION ephy_node_db_set_immutable ##### -->
+<para>
+
+</para>
+
+@db:
+@immutable:
+
+
+<!-- ##### FUNCTION ephy_node_db_get_node_from_id ##### -->
+<para>
+
+</para>
+
+@db:
+@id:
+@Returns:
+<!-- # Unused Parameters # -->
+@Param2:
+
+
diff --git a/doc/reference/tmpl/epiphany-unused.sgml b/doc/reference/tmpl/epiphany-unused.sgml
index 017cc3b2b..a351ddb97 100644
--- a/doc/reference/tmpl/epiphany-unused.sgml
+++ b/doc/reference/tmpl/epiphany-unused.sgml
@@ -171,25 +171,6 @@ Represents the state of an #EphyEmbed with regards to networking negotiations.
</para>
-<!-- ##### STRUCT EphyNodeDb ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### ARG EphyNodeDb:immutable ##### -->
-<para>
-%TRUE if no #EphyNode<!-- -->s can be added, removed or modified from this
-#EphyNodeDb
-</para>
-
-
-<!-- ##### ARG EphyNodeDb:name ##### -->
-<para>
-A string identifier unique to this #EphyNodeDb
-</para>
-
-
<!-- ##### ARG EphyTab:blocked-popup-count ##### -->
<para>
@@ -251,93 +232,6 @@ A string identifier unique to this #EphyNodeDb
@Returns:
-<!-- ##### FUNCTION ephy_glade_widget_new ##### -->
-<para>
-
-</para>
-
-@file:
-@widget_name:
-@root:
-@data:
-@domain:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_get_by_name ##### -->
-<para>
-
-</para>
-
-@name:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_get_name ##### -->
-<para>
-
-</para>
-
-@db:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_get_node_from_id ##### -->
-<para>
-
-</para>
-
-@db:
-@id:
-@Returns:
-@Param2:
-
-<!-- ##### FUNCTION ephy_node_db_is_immutable ##### -->
-<para>
-
-</para>
-
-@db:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_load_from_file ##### -->
-<para>
-
-</para>
-
-@db:
-@xml_file:
-@xml_root:
-@xml_version:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_new ##### -->
-<para>
-
-</para>
-
-@name:
-@Returns:
-
-<!-- ##### FUNCTION ephy_node_db_set_immutable ##### -->
-<para>
-
-</para>
-
-@db:
-@immutable:
-
-<!-- ##### FUNCTION ephy_node_db_write_to_xml_safe ##### -->
-<para>
-
-</para>
-
-@db:
-@filename:
-@root:
-@version:
-@comment:
-@node:
-@Varargs:
-@Returns:
-
<!-- ##### FUNCTION ephy_shell_delete_on_exit ##### -->
<para>
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 012b11795..6f0d06321 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "ephy-embed-single.h"
+#include "ephy-embed-type-builtins.h"
#include "ephy-marshal.h"
static void ephy_embed_single_iface_init (gpointer g_class);
@@ -116,6 +117,34 @@ ephy_embed_single_iface_init (gpointer g_class)
G_TYPE_STRING,
G_TYPE_STRING);
+/**
+ * EphyEmbedSingle::check_content:
+ * @single:
+ * @type: the type of content
+ * @address: the address of the content
+ * @requesting_address: the address of the requesting content (may be empty)
+ * @mime_type_guess: a guess of the mime type of the content (may be empty)
+ * @mime_type: the MIME type of the content
+ *
+ * The ::check-content signal is emitted when Epiphany loads any content from
+ * anywhere.
+ *
+ * If a connected callback returns %TRUE, the
+ * signal emission will stop, and the load be aborted.
+ **/
+ g_signal_new ("check_content",
+ EPHY_TYPE_EMBED_SINGLE,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyEmbedSingleIface, check_content),
+ g_signal_accumulator_true_handled, NULL,
+ ephy_marshal_BOOLEAN__ENUM_STRING_STRING_STRING,
+ G_TYPE_BOOLEAN,
+ 4,
+ EPHY_TYPE_CONTENT_CHECK_TYPE,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
initialised = TRUE;
}
}
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index 7c3850b82..ceb2dcb19 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -35,6 +35,18 @@ G_BEGIN_DECLS
typedef struct _EphyEmbedSingle EphyEmbedSingle;
typedef struct _EphyEmbedSingleIface EphyEmbedSingleIface;
+typedef enum
+{
+ EPHY_CONTENT_CHECK_TYPE_OTHER = 1U,
+ EPHY_CONTENT_CHECK_TYPE_SCRIPT = 2U, /* Indicates an executable script (such as JavaScript) */
+ EPHY_CONTENT_CHECK_TYPE_IMAGE = 3U, /* Indicates an image (e.g., IMG elements) */
+ EPHY_CONTENT_CHECK_TYPE_STYLESHEET = 4U, /* Indicates a stylesheet (e.g., STYLE elements) */
+ EPHY_CONTENT_CHECK_TYPE_OBJECT = 5U, /* Indicates a generic object (plugin-handled content typically falls under this category) */
+ EPHY_CONTENT_CHECK_TYPE_DOCUMENT = 6U, /* Indicates a document at the top-level (i.e., in a browser) */
+ EPHY_CONTENT_CHECK_TYPE_SUBDOCUMENT = 7U, /* Indicates a document contained within another document (e.g., IFRAMEs, FRAMES, and OBJECTs) */
+ EPHY_CONTENT_CHECK_TYPE_REFRESH = 8U /* Indicates a timed refresh */
+} EphyContentCheckType;
+
struct _EphyEmbedSingleIface
{
GTypeInterface base_iface;
@@ -49,10 +61,15 @@ struct _EphyEmbedSingleIface
gboolean offline);
- gboolean (* add_sidebar) (EphyEmbedSingle *single,
+ gboolean (* add_sidebar) (EphyEmbedSingle *single,
const char * url,
const char * title);
+ gboolean (* check_content) (EphyEmbedSingle *single,
+ EphyContentCheckType type,
+ const char *address,
+ const char *requesting_address,
+ const char *mime_type_guess);
/* Methods */
GtkWidget * (* open_window) (EphyEmbedSingle *single,
diff --git a/embed/mozilla/EphyContentPolicy.cpp b/embed/mozilla/EphyContentPolicy.cpp
index 5eb2e5404..98f5f3afd 100644
--- a/embed/mozilla/EphyContentPolicy.cpp
+++ b/embed/mozilla/EphyContentPolicy.cpp
@@ -25,6 +25,8 @@
#include "EphyContentPolicy.h"
+#include "ephy-embed-shell.h"
+#include "ephy-embed-single.h"
#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
@@ -49,6 +51,8 @@ EphyContentPolicy::EphyContentPolicy()
mSafeProtocols = g_slist_prepend (mSafeProtocols, g_strdup ("https"));
mSafeProtocols = g_slist_prepend (mSafeProtocols, g_strdup ("http"));
+ mEmbedSingle = ephy_embed_shell_get_embed_single (embed_shell);
+ g_return_if_fail (mEmbedSingle);
}
EphyContentPolicy::~EphyContentPolicy()
@@ -69,33 +73,46 @@ EphyContentPolicy::ShouldLoad(PRUint32 aContentType,
nsISupports *aExtra,
PRInt16 *aDecision)
{
- if (!mLocked)
- {
- *aDecision = nsIContentPolicy::ACCEPT;
- return NS_OK;
- }
+ NS_ENSURE_ARG (aContentLocation);
- NS_ENSURE_TRUE (aContentLocation, NS_ERROR_FAILURE);
+ nsEmbedCString contentScheme;
+ aContentLocation->GetScheme (contentScheme);
- nsEmbedCString scheme;
- aContentLocation->GetScheme (scheme);
+ nsEmbedCString contentSpec;
+ aContentLocation->GetSpec (contentSpec);
- nsEmbedCString spec;
- aContentLocation->GetSpec (spec);
+ /* first general lockdown check */
+ if (mLocked &&
+ !g_slist_find_custom (mSafeProtocols, contentScheme.get(), (GCompareFunc) strcmp) &&
+ strcmp (contentSpec.get(), "about:blank") != 0)
+ {
+ *aDecision = nsIContentPolicy::REJECT_REQUEST;
+ return NS_OK;
+ }
- LOG ("ShouldLoad type=%d location=%s (scheme %s)", aContentType, spec.get(), scheme.get())
+ nsEmbedCString requestingSpec;
+ if (aRequestingLocation)
+ {
+ aRequestingLocation->GetSpec (requestingSpec);
+ }
- *aDecision = nsIContentPolicy::REJECT_REQUEST;
+ gboolean result = FALSE;
+ g_signal_emit_by_name (mEmbedSingle, "check-content",
+ (EphyContentCheckType) aContentType,
+ contentSpec.get(),
+ requestingSpec.get(),
+ nsEmbedCString(aMimeTypeGuess).get(),
+ &result);
- /* Allow the load if the protocol is in safe list, or it's about:blank */
- if (g_slist_find_custom (mSafeProtocols, scheme.get(), (GCompareFunc) strcmp)
- || strcmp (spec.get(), "about:blank") == 0)
+ if (result)
+ {
+ *aDecision = nsIContentPolicy::REJECT_REQUEST;
+ }
+ else
{
*aDecision = nsIContentPolicy::ACCEPT;
}
- LOG ("Decision: %sallowing load", *aDecision >= 0 ? "" : "DIS")
-
return NS_OK;
}
@@ -115,33 +132,71 @@ EphyContentPolicy::ShouldProcess(PRUint32 aContentType,
#else
/* boolean shouldLoad (in PRInt32 contentType, in nsIURI contentLocation, in nsISupports ctxt, in nsIDOMWindow window); */
-NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType,
- nsIURI *contentLocation,
- nsISupports *ctxt,
- nsIDOMWindow *window,
+NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 aContentType,
+ nsIURI *aContentLocation,
+ nsISupports *aContext,
+ nsIDOMWindow *aWindow,
PRBool *_retval)
{
- if (!mLocked)
- {
- *_retval = PR_TRUE;
- return NS_OK;
- }
+ NS_ENSURE_ARG (aContentLocation);
- nsEmbedCString scheme;
- contentLocation->GetScheme (scheme);
+ nsEmbedCString contentScheme;
+ aContentLocation->GetScheme (contentScheme);
- nsEmbedCString spec;
- contentLocation->GetSpec (spec);
+ nsEmbedCString contentSpec;
+ aContentLocation->GetSpec (contentSpec);
- *_retval = PR_FALSE;
+ /* first general lockdown check */
+ if (mLocked &&
+ !g_slist_find_custom (mSafeProtocols, contentScheme.get(), (GCompareFunc) strcmp) &&
+ strcmp (contentSpec.get(), "about:blank") != 0)
+ {
+ *_retval = PR_FALSE;
+ return NS_OK;
+ }
- /* Allow the load if the protocol is in safe list, or it's about:blank */
- if (g_slist_find_custom (mSafeProtocols, scheme.get(), (GCompareFunc) strcmp)
- || strcmp (spec.get(), "about:blank") == 0)
+ /* translate to variant-2 types */
+ EphyContentCheckType type;
+ switch (aContentType)
{
- *_retval = PR_TRUE;
+ case nsIContentPolicy::SCRIPT:
+ type = EPHY_CONTENT_CHECK_TYPE_SCRIPT;
+ break;
+ case nsIContentPolicy::IMAGE:
+ type = EPHY_CONTENT_CHECK_TYPE_IMAGE;
+ break;
+ case nsIContentPolicy::STYLESHEET:
+ type = EPHY_CONTENT_CHECK_TYPE_STYLESHEET;
+ break;
+ case nsIContentPolicy::OBJECT:
+ type = EPHY_CONTENT_CHECK_TYPE_OBJECT;
+ break;
+ case nsIContentPolicy::SUBDOCUMENT:
+ type = EPHY_CONTENT_CHECK_TYPE_SUBDOCUMENT;
+ break;
+ case nsIContentPolicy::CONTROL_TAG:
+ type = EPHY_CONTENT_CHECK_TYPE_REFRESH;
+ break;
+ case nsIContentPolicy::DOCUMENT:
+ type = EPHY_CONTENT_CHECK_TYPE_DOCUMENT;
+ break;
+ case nsIContentPolicy::OTHER:
+ case nsIContentPolicy::RAW_URL:
+ default:
+ type = EPHY_CONTENT_CHECK_TYPE_OTHER;
+ break;
}
+ gboolean result = FALSE;
+ g_signal_emit_by_name (mEmbedSingle, "check-content",
+ type,
+ contentSpec.get(),
+ "",
+ "",
+ &result);
+
+ *_retval = !result;
+
return NS_OK;
}
diff --git a/embed/mozilla/EphyContentPolicy.h b/embed/mozilla/EphyContentPolicy.h
index 5742f84f8..11e0ce9bd 100644
--- a/embed/mozilla/EphyContentPolicy.h
+++ b/embed/mozilla/EphyContentPolicy.h
@@ -23,6 +23,7 @@
#define EPHY_CONTENT_POLICY_H
#include <glib.h>
+#include <glib-object.h>
#include <nsISupports.h>
#include <nsIContentPolicy.h>
@@ -47,6 +48,7 @@ public:
EphyContentPolicy();
virtual ~EphyContentPolicy();
private:
+ GObject *mEmbedSingle;
gboolean mLocked;
GSList *mSafeProtocols;
};
diff --git a/lib/ephy-marshal.list b/lib/ephy-marshal.list
index bd2aab113..e088e8287 100644
--- a/lib/ephy-marshal.list
+++ b/lib/ephy-marshal.list
@@ -1,3 +1,4 @@
+BOOLEAN:ENUM,STRING,STRING,STRING
BOOLEAN:OBJECT
BOOLEAN:STRING,STRING
BOOLEAN:VOID