aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-06-08 16:24:05 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-26 20:37:47 +0800
commit990ee247b9613724f764b1bca2ff721e5688fcd8 (patch)
tree43a7431a4905c0ca0757b4726b5bb36050a14696 /embed
parentd434d5dde2cb2cd239d8d38b3a369466677e84a4 (diff)
downloadgsoc2013-epiphany-990ee247b9613724f764b1bca2ff721e5688fcd8.tar.gz
gsoc2013-epiphany-990ee247b9613724f764b1bca2ff721e5688fcd8.tar.zst
gsoc2013-epiphany-990ee247b9613724f764b1bca2ff721e5688fcd8.zip
Port plugins about handler to WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=678625
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-about-handler.c58
-rw-r--r--embed/ephy-about-handler.h3
-rw-r--r--embed/ephy-embed-single.c55
3 files changed, 105 insertions, 11 deletions
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index c8d0bc697..12f0ad71e 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -51,12 +51,64 @@ read_css_style ()
}
}
+void
+_ephy_about_handler_handle_plugins (GString *data_str, GList *plugin_list)
+{
+#ifdef HAVE_WEBKIT2
+ GList *p;
+
+ read_css_style ();
+
+ g_string_append_printf (data_str, "<head><title>%s</title>" \
+ "<style type=\"text/css\">%s</style></head><body>",
+ _("Installed plugins"),
+ css_style);
+
+ g_string_append_printf (data_str, "<h1>%s</h1>", _("Installed plugins"));
+
+ for (p = plugin_list; p; p = p->next) {
+ WebKitPlugin *plugin = WEBKIT_PLUGIN (p->data);
+ GList *m, *mime_types;
+
+ /* TODO: Enable/disable plugins in WebKit2 */
+ g_string_append_printf (data_str, "<h2>%s</h2>%s<br>%s: <b>%s</b>" \
+ "<table id=\"plugin-table\">" \
+ " <thead><tr><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>",
+ webkit_plugin_get_name (plugin),
+ webkit_plugin_get_description (plugin),
+ _("Enabled"), /*webkit_plugin_get_enabled (plugin)*/ TRUE ? _("Yes") : _("No"),
+ _("MIME type"), _("Description"), _("Suffixes"));
+
+ mime_types = webkit_plugin_get_mime_info_list (plugin);
+
+ for (m = mime_types; m; m = m->next) {
+ WebKitMimeInfo *mime_info = (WebKitMimeInfo *) m->data;
+ const gchar * const *extensions;
+ guint i;
+
+ g_string_append_printf (data_str, "<tr><td>%s</td><td>%s</td><td>",
+ webkit_mime_info_get_mime_type (mime_info),
+ webkit_mime_info_get_description (mime_info));
+
+ extensions = webkit_mime_info_get_extensions (mime_info);
+ for (i = 0; extensions && extensions[i] != NULL; i++)
+ g_string_append_printf (data_str, "%s%c", extensions[i],
+ extensions[i + 1] ? ',' : ' ');
+
+ g_string_append (data_str, "</td></tr>");
+ }
+
+ g_string_append (data_str, "</tbody></table>");
+ }
+
+ g_string_append (data_str, "</body>");
+#endif
+}
+
static void
ephy_about_handler_handle_plugins (GString *data_str)
{
-#ifdef HAVE_WEBKIT2
- /* TODO: Plugins */
-#else
+#ifndef HAVE_WEBKIT2
WebKitWebPluginDatabase* database = webkit_get_web_plugin_database ();
GSList *plugin_list, *p;
diff --git a/embed/ephy-about-handler.h b/embed/ephy-about-handler.h
index 2bc5bd823..d73d9fd7e 100644
--- a/embed/ephy-about-handler.h
+++ b/embed/ephy-about-handler.h
@@ -13,4 +13,7 @@
GString *ephy_about_handler_handle (const char *about);
+void _ephy_about_handler_handle_plugins (GString *data_str,
+ GList *plugin_list);
+
#endif /* EPHY_ABOUT_HANDLER_H */
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 926b362e5..c927ba89c 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -340,19 +340,58 @@ cache_size_cb (GSettings *settings,
#ifdef HAVE_WEBKIT2
static void
-about_request_cb (WebKitURISchemeRequest *request,
- gpointer user_data)
+complete_about_request_for_contents (WebKitURISchemeRequest *request,
+ gchar *data,
+ gsize data_length)
{
- GString *contents;
GInputStream *stream;
- gint stream_length;
- contents = ephy_about_handler_handle (webkit_uri_scheme_request_get_path (request));
- stream_length = contents->len;
- stream = g_memory_input_stream_new_from_data (g_string_free (contents, FALSE), stream_length, g_free);
- webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
+ stream = g_memory_input_stream_new_from_data (data, data_length, g_free);
+ webkit_uri_scheme_request_finish (request, stream, data_length, "text/html");
g_object_unref (stream);
}
+
+static void
+get_plugins_cb (WebKitWebContext *web_context,
+ GAsyncResult *result,
+ WebKitURISchemeRequest *request)
+{
+ GList *plugins;
+ GString *data_str;
+ gsize data_length;
+
+ data_str = g_string_new("<html>");
+ plugins = webkit_web_context_get_plugins_finish (web_context, result, NULL);
+ _ephy_about_handler_handle_plugins (data_str, plugins);
+ g_string_append (data_str, "</html>");
+
+ data_length = data_str->len;
+ complete_about_request_for_contents (request, g_string_free (data_str, FALSE), data_length);
+ g_object_unref (request);
+}
+
+static void
+about_request_cb (WebKitURISchemeRequest *request,
+ gpointer user_data)
+{
+ const gchar *path;
+
+ path = webkit_uri_scheme_request_get_path (request);
+ if (!g_strcmp0 (path, "plugins")) {
+ /* Plugins API is async in WebKit2 */
+ webkit_web_context_get_plugins (webkit_web_context_get_default (),
+ NULL,
+ (GAsyncReadyCallback) get_plugins_cb,
+ g_object_ref (request));
+ } else {
+ GString *contents;
+ gsize data_length;
+
+ contents = ephy_about_handler_handle (path);
+ data_length = contents->len;
+ complete_about_request_for_contents (request, g_string_free (contents, FALSE), data_length);
+ }
+}
#endif
/**