aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorManuel Rego Casasnovas <rego@igalia.com>2013-02-25 20:13:59 +0800
committerXan Lopez <xan@igalia.com>2013-03-02 22:10:03 +0800
commit4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2 (patch)
treebe69885a4313c81c3e7391a0e4d10956fab88b53 /lib
parentc69239cebfe7d95a5863e9d2f3762ceb2e6c91a3 (diff)
downloadgsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar.gz
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar.bz2
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar.lz
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar.xz
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.tar.zst
gsoc2013-epiphany-4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2.zip
Move code to get application title from DOM to ephy-dom-utils
https://bugzilla.gnome.org/show_bug.cgi?id=694144
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-web-dom-utils.c35
-rw-r--r--lib/ephy-web-dom-utils.h2
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/ephy-web-dom-utils.c b/lib/ephy-web-dom-utils.c
index 40b324bb0..184cf6769 100644
--- a/lib/ephy-web-dom-utils.c
+++ b/lib/ephy-web-dom-utils.c
@@ -96,3 +96,38 @@ ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document)
return FALSE;
}
+
+/**
+ * ephy_web_dom_utils_get_application_title:
+ * @document: the DOM document.
+ *
+ * Returns web application title if it is defined in &lt;meta&gt; elements of
+ * @document.
+ **/
+char *
+ephy_web_dom_utils_get_application_title (WebKitDOMDocument *document)
+{
+ WebKitDOMNodeList *metas;
+ char *title = NULL;
+ gulong length, i;
+
+ metas = webkit_dom_document_get_elements_by_tag_name (document, "meta");
+ length = webkit_dom_node_list_get_length (metas);
+
+ for (i = 0; i < length && title == NULL; i++) {
+ char *name;
+ char *property;
+ WebKitDOMNode *node = webkit_dom_node_list_item (metas, i);
+
+ name = webkit_dom_html_meta_element_get_name (WEBKIT_DOM_HTML_META_ELEMENT (node));
+ property = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "property");
+ if (g_strcmp0 (name, "application-name") == 0
+ || g_strcmp0 (property, "og:site_name") == 0) {
+ title = webkit_dom_html_meta_element_get_content (WEBKIT_DOM_HTML_META_ELEMENT (node));
+ }
+ g_free (property);
+ g_free (name);
+ }
+
+ return title;
+}
diff --git a/lib/ephy-web-dom-utils.h b/lib/ephy-web-dom-utils.h
index f3cde8184..d98344c70 100644
--- a/lib/ephy-web-dom-utils.h
+++ b/lib/ephy-web-dom-utils.h
@@ -35,6 +35,8 @@ G_BEGIN_DECLS
gboolean ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document);
+char * ephy_web_dom_utils_get_application_title (WebKitDOMDocument *document);
+
G_END_DECLS
#endif