aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Rego Casasnovas <rego@igalia.com>2013-02-25 20:22:30 +0800
committerXan Lopez <xan@igalia.com>2013-03-02 22:10:08 +0800
commit81cbba2fe0acce1de3d78749415fe6eb2374fd71 (patch)
tree3dc37eb94f09daf3d67a65e227d931b1ad4120d1
parent4b8da0f21ae7ea5a47dbf4a0afce79b1437c3bf2 (diff)
downloadgsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar.gz
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar.bz2
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar.lz
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar.xz
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.tar.zst
gsoc2013-epiphany-81cbba2fe0acce1de3d78749415fe6eb2374fd71.zip
Implement get web app title in WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=694144
-rw-r--r--embed/web-extension/ephy-web-extension.c9
-rw-r--r--src/window-commands.c65
2 files changed, 62 insertions, 12 deletions
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index d6e9f5391..8d82c1a77 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -31,6 +31,10 @@ static const char introspection_xml[] =
" <arg type='t' name='page_id' direction='in'/>"
" <arg type='b' name='has_modified_forms' direction='out'/>"
" </method>"
+ " <method name='GetWebAppTitle'>"
+ " <arg type='t' name='page_id' direction='in'/>"
+ " <arg type='s' name='title' direction='out'/>"
+ " </method>"
" </interface>"
"</node>";
@@ -64,6 +68,11 @@ handle_method_call (GDBusConnection *connection,
gboolean has_modifed_forms = ephy_web_dom_utils_has_modified_forms (document);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", has_modifed_forms));
+ } else if (g_strcmp0 (method_name, "GetWebAppTitle") == 0) {
+ WebKitDOMDocument *document = webkit_web_page_get_dom_document (web_page);
+ char *title = ephy_web_dom_utils_get_application_title (document);
+
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", title ? title : ""));
}
}
diff --git a/src/window-commands.c b/src/window-commands.c
index 04b1e29b2..8d774e3fb 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -696,17 +696,10 @@ get_special_case_application_title_for_host (const char *host)
}
static void
-fill_default_application_title (EphyApplicationDialogData *data)
+set_default_application_title (EphyApplicationDialogData *data,
+ char *title)
{
- char *title = NULL;
-#ifdef HAVE_WEBKIT2
- /* TODO: DOM Bindindgs */
-#else
- WebKitDOMDocument *document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (data->view));
- title = ephy_web_dom_utils_get_application_title (document);
-#endif
-
- if (title == NULL)
+ if (title == NULL || title[0] == '\0')
{
SoupURI *uri;
const char *host;
@@ -717,7 +710,7 @@ fill_default_application_title (EphyApplicationDialogData *data)
if (host != NULL && host[0] != '\0')
title = get_special_case_application_title_for_host (host);
- if (title == NULL)
+ if (title == NULL || title[0] == '\0')
{
if (g_str_has_prefix (host, "www."))
title = g_strdup (host + strlen ("www."));
@@ -728,7 +721,7 @@ fill_default_application_title (EphyApplicationDialogData *data)
soup_uri_free (uri);
}
- if (title == NULL)
+ if (title == NULL || title[0] == '\0')
{
title = g_strdup (ephy_web_view_get_title (data->view));
}
@@ -737,6 +730,54 @@ fill_default_application_title (EphyApplicationDialogData *data)
g_free (title);
}
+#ifdef HAVE_WEBKIT2
+static void
+fill_default_application_title_cb (GObject *source,
+ GAsyncResult *async_result,
+ gpointer user_data)
+{
+ EphyApplicationDialogData *data = user_data;
+ GVariant *result;
+ char *title = NULL;
+
+ result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source),
+ async_result,
+ NULL);
+
+ if (result)
+ {
+ g_variant_get (result, "(s)", &title);
+ g_variant_unref (result);
+ }
+
+ set_default_application_title (data, title);
+}
+#endif
+
+static void
+fill_default_application_title (EphyApplicationDialogData *data)
+{
+#ifdef HAVE_WEBKIT2
+ GDBusProxy *web_extension;
+ web_extension = ephy_embed_shell_get_web_extension_proxy (ephy_embed_shell_get_default ());
+ if (web_extension)
+ g_dbus_proxy_call (web_extension,
+ "GetWebAppTitle",
+ g_variant_new("(t)", webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (data->view))),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ fill_default_application_title_cb,
+ data);
+ else
+ set_default_application_title (data, NULL);
+#else
+ WebKitDOMDocument *document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (data->view));
+ char *title = ephy_web_dom_utils_get_application_title (document);
+ set_default_application_title (data, title);
+#endif
+}
+
static void
notify_launch_cb (NotifyNotification *notification,
char *action,