aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed.c49
-rw-r--r--embed/ephy-embed.h13
-rw-r--r--embed/mozilla/EphyBrowser.cpp33
-rw-r--r--embed/mozilla/EphyBrowser.h2
-rw-r--r--embed/mozilla/mozilla-embed.cpp7
5 files changed, 99 insertions, 5 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index a8476cd5c..5e43262f6 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -31,9 +31,9 @@ static void ephy_embed_base_init (gpointer g_class);
GType
ephy_embed_chrome_get_type (void)
{
- static GType etype = 0;
+ static GType type = 0;
- if (etype == 0)
+ if (G_UNLIKELY (type == 0))
{
static const GFlagsValue values[] =
{
@@ -44,10 +44,32 @@ ephy_embed_chrome_get_type (void)
{ 0, NULL, NULL }
};
- etype = g_flags_register_static ("EphyEmbedChrome", values);
+ type = g_flags_register_static ("EphyEmbedChrome", values);
+ }
+
+ return type;
+}
+
+GType
+ephy_embed_document_type_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GEnumValue values[] =
+ {
+ { EMBED_DOCUMENT_HTML, "EMBED_DOCUMENT_HTML", "html" },
+ { EMBED_DOCUMENT_XML, "EMBED_DOCUMENT_XML", "xml" },
+ { EMBED_DOCUMENT_IMAGE, "EMBED_DOCUMENT_IMAGE", "image" },
+ { EMBED_DOCUMENT_OTHER, "EMBED_DOCUMENT_OTHER", "other" },
+ { 0, NULL, NULL }
+ };
+
+ type = g_enum_register_static ("EphyEmbedDocumentType", values);
}
- return etype;
+ return type;
}
GType
@@ -129,7 +151,7 @@ ephy_embed_base_init (gpointer g_class)
g_signal_new ("ge_context_menu",
EPHY_TYPE_EMBED,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyEmbedIface, context_menu),
+ G_STRUCT_OFFSET (EphyEmbedIface, dom_context_menu),
g_signal_accumulator_true_handled, NULL,
ephy_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN,
@@ -318,6 +340,23 @@ ephy_embed_base_init (gpointer g_class)
G_TYPE_NONE,
0);
+/**
+ * EphyEmbed::ge-document-type:
+ * @embed:
+ * @type: the new document type
+ *
+ * The ::ge-document-type signal is emitted when @embed determines the type of its document.
+ **/
+ g_signal_new ("ge_document_type",
+ EPHY_TYPE_EMBED,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyEmbedIface, document_type),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_EMBED_DOCUMENT_TYPE);
+
initialized = TRUE;
}
}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index c3d5a1a88..ab0a900d7 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -37,6 +37,7 @@ G_BEGIN_DECLS
#define EPHY_EMBED_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_EMBED, EphyEmbedIface))
#define EPHY_TYPE_EMBED_CHROME_MASK (ephy_embed_chrome_get_type ())
+#define EPHY_TYPE_EMBED_DOCUMENT_TYPE (ephy_embed_document_type_get_type ())
typedef struct _EphyEmbed EphyEmbed;
typedef struct _EphyEmbedIface EphyEmbedIface;
@@ -88,6 +89,14 @@ typedef enum
STATE_IS_SECURE_HIGH
} EmbedSecurityLevel;
+typedef enum
+{
+ EMBED_DOCUMENT_HTML,
+ EMBED_DOCUMENT_XML,
+ EMBED_DOCUMENT_IMAGE,
+ EMBED_DOCUMENT_OTHER
+} EmbedDocumentType;
+
struct _EphyEmbedIface
{
GTypeInterface base_iface;
@@ -133,6 +142,8 @@ struct _EphyEmbedIface
const char *uri);
gboolean (* modal_alert) (EphyEmbed *embed);
void (* modal_alert_closed) (EphyEmbed *embed);
+ void (* document_type) (EphyEmbed *embed,
+ EmbedDocumentType type);
/* Methods */
void (* load_url) (EphyEmbed *embed,
@@ -192,6 +203,8 @@ struct _EphyEmbedIface
GType ephy_embed_chrome_get_type (void);
+GType ephy_embed_document_type_get_type (void);
+
GType ephy_embed_get_type (void);
/* Base */
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 8dffaa74d..2894b6e56 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -73,8 +73,11 @@
#include "nsIScriptSecurityManager.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
+#include <nsIDOMHTMLDocument.h>
+#include <nsIDOMXMLDocument.h>
#ifdef ALLOW_PRIVATE_API
+#include <content/nsIImageDocument.h>
/* not frozen yet */
#include "nsIContentPolicy.h"
/* will never be frozen */
@@ -1129,3 +1132,33 @@ EphyBrowser::ShowCertificate ()
return NS_OK;
#endif
}
+
+EmbedDocumentType
+EphyBrowser::GetDocumentType ()
+{
+ EmbedDocumentType type = EMBED_DOCUMENT_OTHER;
+
+ nsresult rv;
+ nsCOMPtr<nsIDOMDocument> domDoc;
+ rv = GetDocument (getter_AddRefs (domDoc));
+ NS_ENSURE_SUCCESS (rv, type);
+
+ nsCOMPtr<nsIDOMHTMLDocument> htmlDoc (do_QueryInterface (domDoc));
+ nsCOMPtr<nsIDOMXMLDocument> xmlDoc (do_QueryInterface (domDoc));
+ nsCOMPtr<nsIImageDocument> imgDoc (do_QueryInterface (domDoc));
+
+ if (xmlDoc)
+ {
+ type = EMBED_DOCUMENT_XML;
+ }
+ else if (imgDoc)
+ {
+ type = EMBED_DOCUMENT_IMAGE;
+ }
+ else if (htmlDoc)
+ {
+ type = EMBED_DOCUMENT_HTML;
+ }
+
+ return type;
+}
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 56962d183..05e93235e 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -147,6 +147,8 @@ public:
nsresult GetSecurityInfo (PRUint32 *aState, nsACString &aDescription);
nsresult ShowCertificate ();
+ EmbedDocumentType GetDocumentType ();
+
nsCOMPtr<nsIWebBrowser> mWebBrowser;
private:
GtkWidget *mEmbed;
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index fd71b5cb9..4a33a80ff 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -789,6 +789,13 @@ update_load_state (MozillaEmbed *membed, gint state)
{
MozillaEmbedPrivate *priv = membed->priv;
+ if (state & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT &&
+ state & (GTK_MOZ_EMBED_FLAG_START | GTK_MOZ_EMBED_FLAG_STOP))
+ {
+ g_signal_emit_by_name (membed, "ge-document-type",
+ priv->browser->GetDocumentType ());
+ }
+
if (state & GTK_MOZ_EMBED_FLAG_IS_NETWORK)
{
if (state & GTK_MOZ_EMBED_FLAG_START)