[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

xan at webkit.org xan at webkit.org
Wed Dec 22 18:28:33 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f29e6a3418dac765e4412e907e5b361aa9f444ed
Author: xan at webkit.org <xan at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Dec 11 16:25:39 2010 +0000

    2010-12-11  Xan Lopez  <xlopez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Add APIs for plugin management
            https://bugs.webkit.org/show_bug.cgi?id=50827
    
            Add WebKitWebPluginDatabase and WebKitWebPlugin classes for basic
            plugin management at the client level. For now they provide
            "read-only" access to the plugin list.
    
            * GNUmakefile.am: add new files to the build.
            * tests/testwebplugindatabase.c: Test that the database contains
            the test plugin, which should always be loaded.
            * webkit/webkit.h: add new headers.
            * webkit/webkitdefines.h: add new defines.
            * webkit/webkitwebplugin.cpp: An new class representing a plugin object.
            * webkit/webkitwebplugin.h: ditto.
            * webkit/webkitwebplugindatabase.cpp: A new class that contains the list of active plugins.
            * webkit/webkitwebplugindatabase.h: ditto.
            * webkit/webkitwebplugindatabaseprivate.h: Private header.
            * webkit/webkitwebpluginprivate.h: Private header.
            * webkit/webkitwebview.cpp:
            (webkit_get_web_plugin_database): returns the WebKitWebPluginDatabase for this session.
            * webkit/webkitwebview.h: add method to header.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73858 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 3fc3aa9..760039b 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,29 @@
+2010-12-11  Xan Lopez  <xlopez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Add APIs for plugin management
+        https://bugs.webkit.org/show_bug.cgi?id=50827
+
+        Add WebKitWebPluginDatabase and WebKitWebPlugin classes for basic
+        plugin management at the client level. For now they provide
+        "read-only" access to the plugin list.
+
+        * GNUmakefile.am: add new files to the build.
+        * tests/testwebplugindatabase.c: Test that the database contains
+        the test plugin, which should always be loaded.
+        * webkit/webkit.h: add new headers.
+        * webkit/webkitdefines.h: add new defines.
+        * webkit/webkitwebplugin.cpp: An new class representing a plugin object.
+        * webkit/webkitwebplugin.h: ditto.
+        * webkit/webkitwebplugindatabase.cpp: A new class that contains the list of active plugins.
+        * webkit/webkitwebplugindatabase.h: ditto.
+        * webkit/webkitwebplugindatabaseprivate.h: Private header.
+        * webkit/webkitwebpluginprivate.h: Private header.
+        * webkit/webkitwebview.cpp:
+        (webkit_get_web_plugin_database): returns the WebKitWebPluginDatabase for this session.
+        * webkit/webkitwebview.h: add method to header.
+
 2010-12-10  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
 
         Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/GNUmakefile.am b/WebKit/gtk/GNUmakefile.am
index f4007db..dd46959 100644
--- a/WebKit/gtk/GNUmakefile.am
+++ b/WebKit/gtk/GNUmakefile.am
@@ -127,6 +127,8 @@ webkitgtk_static_h_api += \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebhistoryitem.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebinspector.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebnavigationaction.h \
+	$(srcdir)/WebKit/gtk/webkit/webkitwebplugin.h \
+	$(srcdir)/WebKit/gtk/webkit/webkitwebplugindatabase.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebpolicydecision.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebresource.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebsettings.h \
@@ -200,6 +202,10 @@ webkitgtk_sources += \
 	WebKit/gtk/webkit/webkitwebnavigationactionprivate.h \
 	WebKit/gtk/webkit/webkitwebpolicydecision.cpp \
 	WebKit/gtk/webkit/webkitwebresource.cpp \
+	WebKit/gtk/webkit/webkitwebplugin.cpp \
+	WebKit/gtk/webkit/webkitwebpluginprivate.h \
+	WebKit/gtk/webkit/webkitwebplugindatabase.cpp \
+	WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h \
 	WebKit/gtk/webkit/webkitwebsettings.cpp \
 	WebKit/gtk/webkit/webkitwebview.cpp \
 	WebKit/gtk/webkit/webkitwebviewprivate.h \
@@ -395,6 +401,7 @@ TEST_PROGS += \
 	Programs/unittests/testwebsettings \
 	Programs/unittests/testwebresource \
 	Programs/unittests/testwebdatasource \
+	Programs/unittests/testwebplugindatabase \
 	Programs/unittests/testwebview \
 	Programs/unittests/testkeyevents \
 	Programs/unittests/testcopyandpaste
@@ -450,6 +457,11 @@ Programs_unittests_testwebframe_CFLAGS = $(webkit_tests_cflags)
 Programs_unittests_testwebframe_LDADD = $(webkit_tests_ldadd)
 Programs_unittests_testwebframe_LDFLAGS = $(webkit_tests_ldflags)
 
+Programs_unittests_testwebplugindatabase_SOURCES = WebKit/gtk/tests/testwebplugindatabase.c
+Programs_unittests_testwebplugindatabase_CFLAGS = -DTEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" $(webkit_tests_cflags)
+Programs_unittests_testwebplugindatabase_LDADD = $(webkit_tests_ldadd)
+Programs_unittests_testwebplugindatabase_LDFLAGS = $(webkit_tests_ldflags)
+
 Programs_unittests_testwebbackforwardlist_SOURCES = WebKit/gtk/tests/testwebbackforwardlist.c
 Programs_unittests_testwebbackforwardlist_CFLAGS = $(webkit_tests_cflags)
 Programs_unittests_testwebbackforwardlist_LDADD = $(webkit_tests_ldadd)
diff --git a/WebKit/gtk/tests/testwebplugindatabase.c b/WebKit/gtk/tests/testwebplugindatabase.c
new file mode 100644
index 0000000..802f250
--- /dev/null
+++ b/WebKit/gtk/tests/testwebplugindatabase.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#if GTK_CHECK_VERSION(2, 14, 0)
+
+/* This function is not public, so we need an extern declaration */
+extern void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* view, const gchar* directory);
+
+static void test_webkit_web_plugin_database_get_plugins()
+{
+    WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    WebKitWebPluginDatabase* database;
+    GSList* pluginList, *p;
+    gboolean found = FALSE;
+
+    webkit_web_settings_add_extra_plugin_directory(view, TEST_PLUGIN_DIR);
+    g_object_ref_sink(G_OBJECT(view));
+
+    database = webkit_get_web_plugin_database();
+    pluginList = webkit_web_plugin_database_get_plugins(database);
+    for (p = pluginList; p; p = p->next) {
+        WebKitWebPlugin* plugin = (WebKitWebPlugin*)p->data;
+        if (!g_strcmp0(webkit_web_plugin_get_name(plugin), "WebKit Test PlugIn") &&
+            !g_strcmp0(webkit_web_plugin_get_description(plugin), "Simple Netscape plug-in that handles test content for WebKit"))
+            found = TRUE;
+    }
+    webkit_web_plugin_database_plugins_list_free(pluginList);
+    g_assert(found);
+
+    g_object_unref(view);
+}
+
+int main(int argc, char** argv)
+{
+    g_thread_init(NULL);
+    gtk_test_init(&argc, &argv, NULL);
+
+    g_test_bug_base("https://bugs.webkit.org/");
+    g_test_add_func("/webkit/webplugindatabase/getplugins", test_webkit_web_plugin_database_get_plugins);
+    return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+    g_critical("You will need at least gtk-2.14.0 to run the unit tests. Doing nothing now.");
+    return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h
index 2428f62..c0d0e31 100644
--- a/WebKit/gtk/webkit/webkit.h
+++ b/WebKit/gtk/webkit/webkit.h
@@ -39,6 +39,8 @@
 #include <webkit/webkitwebview.h>
 #include <webkit/webkitwebbackforwardlist.h>
 #include <webkit/webkitwebhistoryitem.h>
+#include <webkit/webkitwebplugin.h>
+#include <webkit/webkitwebplugindatabase.h>
 #include <webkit/webkitwebpolicydecision.h>
 #include <webkit/webkitwebnavigationaction.h>
 #include <webkit/webkitwebresource.h>
diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h
index 399cb4c..b0b607b 100644
--- a/WebKit/gtk/webkit/webkitdefines.h
+++ b/WebKit/gtk/webkit/webkitdefines.h
@@ -95,6 +95,12 @@ typedef struct _WebKitGeolocationPolicyDecisionClass WebKitGeolocationPolicyDeci
 typedef struct _WebKitViewportAttributes WebKitViewportAttributes;
 typedef struct _WebKitViewportAttributesClass WebKitViewportAttributesClass;
 
+typedef struct _WebKitWebPluginDatabase        WebKitWebPluginDatabase;
+typedef struct _WebKitWebPluginDatabaseClass   WebKitWebPluginDatabaseClass;
+
+typedef struct _WebKitWebPlugin      WebKitWebPlugin;
+typedef struct _WebKitWebPluginClass WebKitWebPluginClass;
+
 G_END_DECLS
 
 #endif
diff --git a/WebKit/gtk/webkit/webkitwebplugin.cpp b/WebKit/gtk/webkit/webkitwebplugin.cpp
new file mode 100644
index 0000000..86f7438
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebplugin.cpp
@@ -0,0 +1,165 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "webkitwebplugin.h"
+
+#include "PluginPackage.h"
+#include "webkitprivate.h"
+#include "webkitwebpluginprivate.h"
+
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitWebPlugin, webkit_web_plugin, G_TYPE_OBJECT)
+
+static void freeMIMEType(WebKitWebPluginMIMEType* mimeType)
+{
+    if (mimeType->name)
+        g_free(mimeType->name);
+    if (mimeType->description)
+        g_free(mimeType->description);
+    if (mimeType->extensions)
+        g_strfreev(mimeType->extensions);
+    g_slice_free(WebKitWebPluginMIMEType, mimeType);
+}
+
+void webkit_web_plugin_mime_type_list_free(GSList* list)
+{
+    for (GSList* p = list; p; p = p->next)
+        freeMIMEType((WebKitWebPluginMIMEType*)p->data);
+    g_slist_free(list);
+}
+
+static void webkit_web_plugin_finalize(GObject* object)
+{
+    WebKitWebPluginPrivate* priv = WEBKIT_WEB_PLUGIN(object)->priv;
+
+    if (priv->mimeTypes)
+        webkit_web_plugin_mime_type_list_free(priv->mimeTypes);
+
+    delete WEBKIT_WEB_PLUGIN(object)->priv;
+
+    G_OBJECT_CLASS(webkit_web_plugin_parent_class)->dispose(object);
+}
+
+static void webkit_web_plugin_class_init(WebKitWebPluginClass* klass)
+{
+    webkit_init();
+
+    GObjectClass* gobjectClass = reinterpret_cast<GObjectClass*>(klass);
+
+    gobjectClass->finalize = webkit_web_plugin_finalize;
+
+    g_type_class_add_private(klass, sizeof(WebKitWebPluginPrivate));
+}
+
+static void webkit_web_plugin_init(WebKitWebPlugin *plugin)
+{
+    WebKitWebPluginPrivate* priv = WEBKIT_WEB_PLUGIN_GET_PRIVATE(plugin);
+    plugin->priv = priv = new WebKitWebPluginPrivate();
+}
+
+namespace WebKit {
+WebKitWebPlugin* kitNew(WebCore::PluginPackage* package)
+{
+    WebKitWebPlugin* plugin = WEBKIT_WEB_PLUGIN(g_object_new(WEBKIT_TYPE_WEB_PLUGIN, 0));
+
+    plugin->priv->corePlugin = package;
+
+    return plugin;
+}
+}
+
+/**
+ * webkit_web_plugin_get_name:
+ * @plugin: a #WebKitWebPlugin
+ *
+ * Returns: the name string for @plugin.
+ *
+ * Since: 1.3.8
+ */
+const char* webkit_web_plugin_get_name(WebKitWebPlugin* plugin)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0);
+
+    WebKitWebPluginPrivate* priv = plugin->priv;
+
+    if (!priv->name.length())
+        priv->name = priv->corePlugin->name().utf8();
+
+    return priv->name.data();
+}
+
+/**
+ * webkit_web_plugin_get_description:
+ * @plugin: a #WebKitWebPlugin
+ *
+ * Returns: the description string for @plugin.
+ *
+ * Since: 1.3.8
+ */
+const char* webkit_web_plugin_get_description(WebKitWebPlugin* plugin)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0);
+
+    WebKitWebPluginPrivate* priv = plugin->priv;
+
+    if (!priv->description.length())
+        priv->description = priv->corePlugin->description().utf8();
+
+    return priv->description.data();
+}
+
+/**
+ * webkit_web_plugin_get_mimetypes:
+ * @plugin: a #WebKitWebPlugin
+ *
+ * Returns all the #WebKitWebPluginMIMEType that @plugin is handling
+ * at the moment.
+ *
+ * Returns: (transfer container) (element-type WebKitWebPluginMIMEType): a #GSList of #WebKitWebPluginMIMEType
+ *
+ * Since: 1.3.8
+ */
+GSList* webkit_web_plugin_get_mimetypes(WebKitWebPlugin* plugin)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0);
+
+    WebKitWebPluginPrivate* priv = plugin->priv;
+
+    if (priv->mimeTypes)
+        return priv->mimeTypes;
+
+    const MIMEToDescriptionsMap& mimeToDescriptions = priv->corePlugin->mimeToDescriptions();
+    MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
+
+    for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
+        WebKitWebPluginMIMEType* mimeType = g_slice_new0(WebKitWebPluginMIMEType);
+        mimeType->name = g_strdup(it->first.utf8().data());
+        mimeType->description = g_strdup(it->second.utf8().data());
+
+        Vector<String> extensions = priv->corePlugin->mimeToExtensions().get(it->first);
+        mimeType->extensions = static_cast<gchar**>(g_malloc0(extensions.size() + 1));
+        for (unsigned i = 0; i < extensions.size(); i++)
+            mimeType->extensions[i] = g_strdup(extensions[i].utf8().data());
+
+        priv->mimeTypes = g_slist_append(priv->mimeTypes, mimeType);
+    }
+
+    return priv->mimeTypes;
+}
diff --git a/WebKit/gtk/webkit/webkitwebplugin.h b/WebKit/gtk/webkit/webkitwebplugin.h
new file mode 100644
index 0000000..8907d70
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebplugin.h
@@ -0,0 +1,83 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef webkitwebplugin_h
+#define webkitwebplugin_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_PLUGIN            (webkit_web_plugin_get_type())
+#define WEBKIT_WEB_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPlugin))
+#define WEBKIT_WEB_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPluginClass))
+#define WEBKIT_IS_WEB_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_PLUGIN))
+#define WEBKIT_IS_WEB_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_PLUGIN))
+#define WEBKIT_WEB_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPluginClass))
+
+typedef struct _WebKitWebPluginPrivate WebKitWebPluginPrivate;
+
+/**
+ * WebKitWebPluginMIMEType:
+ * @name: the name of the MIME type.
+ * @description: the description of the MIME type.
+ * @extensions: the extensions associated with this MIME type.
+ *
+ * A structure representing one of the MIME types associated with a
+ * plugin. A #GSList of these objects will be returned by
+ * #webkit_web_plugin_get_mimetypes, use
+ * #webkit_web_plugin_mime_type_list_free to free it.
+ *
+ * Since: 1.3.8
+ */
+typedef struct _WebKitWebPluginMIMEType {
+    char* name;
+    char* description;
+    char** extensions;
+} WebKitWebPluginMIMEType;
+
+WEBKIT_API void
+webkit_web_plugin_mime_type_list_free (GSList*);
+
+struct _WebKitWebPluginClass {
+    GObjectClass parentClass;
+};
+
+struct _WebKitWebPlugin {
+    GObject parentInstance;
+
+    WebKitWebPluginPrivate* priv;
+};
+
+WEBKIT_API GType
+webkit_web_plugin_get_type        (void) G_GNUC_CONST;
+
+WEBKIT_API const char*
+webkit_web_plugin_get_name        (WebKitWebPlugin*);
+
+WEBKIT_API const char*
+webkit_web_plugin_get_description (WebKitWebPlugin*);
+
+WEBKIT_API GSList*
+webkit_web_plugin_get_mimetypes   (WebKitWebPlugin*);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitwebplugindatabase.cpp b/WebKit/gtk/webkit/webkitwebplugindatabase.cpp
new file mode 100644
index 0000000..584ad97
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebplugindatabase.cpp
@@ -0,0 +1,139 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "webkitwebplugindatabase.h"
+
+#include "PluginDatabase.h"
+#include "webkitprivate.h"
+#include "webkitwebplugindatabaseprivate.h"
+#include "webkitwebpluginprivate.h"
+
+using namespace WebKit;
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitWebPluginDatabase, webkit_web_plugin_database, G_TYPE_OBJECT)
+
+static void webkit_web_plugin_database_dispose(GObject* object)
+{
+    G_OBJECT_CLASS(webkit_web_plugin_database_parent_class)->dispose(object);
+}
+
+static void webkit_web_plugin_database_class_init(WebKitWebPluginDatabaseClass* klass)
+{
+    webkit_init();
+
+    GObjectClass* gobjectClass = reinterpret_cast<GObjectClass*>(klass);
+
+    gobjectClass->dispose = webkit_web_plugin_database_dispose;
+
+    g_type_class_add_private(klass, sizeof(WebKitWebPluginDatabasePrivate));
+}
+
+static void webkit_web_plugin_database_init(WebKitWebPluginDatabase* database)
+{
+    WebKitWebPluginDatabasePrivate* priv = WEBKIT_WEB_PLUGIN_DATABASE_GET_PRIVATE(database);
+    database->priv = priv;
+
+    priv->coreDatabase = PluginDatabase::installedPlugins();
+}
+
+/**
+ * webkit_web_plugin_database_list_free:
+ * @list: a #WebKitWebPluginDatabasePluginList
+ *
+ * Frees @list.
+ *
+ * Since: 1.3.8
+ */
+void webkit_web_plugin_database_plugins_list_free(GSList* list)
+{
+    g_return_if_fail(list);
+
+    for (GSList* p = list; p; p = p->next)
+        g_object_unref(p->data);
+
+    g_slist_free(list);
+}
+
+/**
+ * webkit_web_plugin_database_get_plugins:
+ * @database: a #WebKitWebPluginDatabase
+ *
+ * Returns all #WebKitWebPlugin available in @database.
+ *
+ * Returns: (transfer full) (element-type WebKitWebPlugin): a #GSList of #WebKitWebPlugin
+ *
+ * Since: 1.3.8
+ */
+GSList* webkit_web_plugin_database_get_plugins(WebKitWebPluginDatabase* database)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database), 0);
+
+    GSList* gPlugins = 0;
+    const Vector<PluginPackage*>& plugins = database->priv->coreDatabase->plugins();
+
+    for (unsigned int i = 0; i < plugins.size(); ++i) {
+        PluginPackage* plugin = plugins[i];
+        gPlugins = g_slist_append(gPlugins, kitNew(plugin));
+    }
+
+    return gPlugins;
+}
+
+/**
+ * webkit_web_plugin_database_get_plugin_for_mimetype:
+ * @database: a #WebKitWebPluginDatabase
+ * @mimeType: a mime type
+ *
+ * Returns the #WebKitWebPlugin that is handling @mimeType in the
+ * @database, or %NULL if there's none doing so.
+ *
+ * Returns: (transfer full): a #WebKitWebPlugin
+ *
+ * Since: 1.3.8
+ */
+WebKitWebPlugin* webkit_web_plugin_database_get_plugin_for_mimetype(WebKitWebPluginDatabase* database, const char* mimeType)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database), 0);
+    g_return_val_if_fail(mimeType, 0);
+
+    return kitNew(database->priv->coreDatabase->pluginForMIMEType(mimeType));
+}
+
+/**
+ * webkit_web_plugin_database_refresh:
+ * @database: a #WebKitWebPluginDatabase
+ *
+ * Refreshes @database adding new plugins that are now in use and
+ * removing those that have been disabled or are otherwise no longer
+ * available.
+ *
+ * Since: 1.3.8
+ */
+void webkit_web_plugin_database_refresh(WebKitWebPluginDatabase* database)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database));
+
+    database->priv->coreDatabase->refresh();
+}
+
+WebKitWebPluginDatabase* webkit_web_plugin_database_new(void)
+{
+    return WEBKIT_WEB_PLUGIN_DATABASE(g_object_new(WEBKIT_TYPE_WEB_PLUGIN_DATABASE, 0));
+}
diff --git a/WebKit/gtk/webkit/webkitwebplugindatabase.h b/WebKit/gtk/webkit/webkitwebplugindatabase.h
new file mode 100644
index 0000000..0b02c26
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebplugindatabase.h
@@ -0,0 +1,64 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef webkitwebplugindatabase_h
+#define webkitwebplugindatabase_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_PLUGIN_DATABASE            (webkit_web_plugin_database_get_type())
+#define WEBKIT_WEB_PLUGIN_DATABASE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabase))
+#define WEBKIT_WEB_PLUGIN_DATABASE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabaseClass))
+#define WEBKIT_IS_WEB_PLUGIN_DATABASE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE))
+#define WEBKIT_IS_WEB_PLUGIN_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_PLUGIN_DATABASE))
+#define WEBKIT_WEB_PLUGIN_DATABASE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabaseClass))
+
+typedef struct _WebKitWebPluginDatabasePrivate WebKitWebPluginDatabasePrivate;
+
+struct _WebKitWebPluginDatabaseClass {
+    GObjectClass parentClass;
+};
+
+struct _WebKitWebPluginDatabase {
+    GObject parentInstance;
+
+    WebKitWebPluginDatabasePrivate* priv;
+};
+
+WEBKIT_API GType
+webkit_web_plugin_database_get_type                (void) G_GNUC_CONST;
+
+WEBKIT_API void
+webkit_web_plugin_database_plugins_list_free       (GSList*);
+
+WEBKIT_API GSList*
+webkit_web_plugin_database_get_plugins             (WebKitWebPluginDatabase*);
+
+WEBKIT_API WebKitWebPlugin*
+webkit_web_plugin_database_get_plugin_for_mimetype (WebKitWebPluginDatabase*, const char *);
+
+WEBKIT_API void
+webkit_web_plugin_database_refresh                 (WebKitWebPluginDatabase*);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h b/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h
new file mode 100644
index 0000000..aa99570
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebplugindatabaseprivate_h
+#define webkitwebplugindatabaseprivate_h
+
+#include <glib-object.h>
+
+namespace WebCore {
+class PluginDatabase;
+}
+
+extern "C" {
+
+#define WEBKIT_WEB_PLUGIN_DATABASE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabasePrivate))
+typedef struct _WebKitWebPluginDatabasePrivate WebKitWebPluginDatabasePrivate;
+struct _WebKitWebPluginDatabasePrivate {
+    WebCore::PluginDatabase* coreDatabase;
+};
+
+WebKitWebPluginDatabase* webkit_web_plugin_database_new();
+
+}
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitwebpluginprivate.h b/WebKit/gtk/webkit/webkitwebpluginprivate.h
new file mode 100644
index 0000000..6beb468
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebpluginprivate.h
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef webkitwebpluginprivate_h
+#define webkitwebpluginprivate_h
+
+#include "webkitwebplugin.h"
+#include <glib-object.h>
+
+namespace WebCore {
+class PluginPackage;
+}
+
+namespace WebKit {
+WebKitWebPlugin* kitNew(WebCore::PluginPackage* package);
+}
+
+extern "C" {
+
+#define WEBKIT_WEB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPluginPrivate))
+typedef struct _WebKitWebPluginPrivate WebKitWebPluginPrivate;
+struct _WebKitWebPluginPrivate {
+    RefPtr<WebCore::PluginPackage> corePlugin;
+    CString name;
+    CString description;
+    GSList* mimeTypes;
+};
+
+}
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 93e53be..b067007 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -96,6 +96,7 @@
 #include "webkitwebinspectorprivate.h"
 #include "webkitwebpolicydecision.h"
 #include "webkitwebresource.h"
+#include "webkitwebplugindatabaseprivate.h"
 #include "webkitwebviewprivate.h"
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n-lib.h>
@@ -5154,6 +5155,28 @@ WebKitCacheModel webkit_get_cache_model()
     return cacheModel;
 }
 
+/**
+ * webkit_get_web_plugin_database:
+ *
+ * Returns the current #WebKitWebPluginDatabase with information about
+ * all the plugins WebKit knows about in this instance.
+ *
+ * Return value: (transfer none): the current #WebKitWebPluginDatabase
+ *
+ * Since: 1.3.8
+ */
+WebKitWebPluginDatabase* webkit_get_web_plugin_database()
+{
+    static WebKitWebPluginDatabase* database = 0;
+
+    webkit_init();
+
+    if (!database)
+        database = webkit_web_plugin_database_new();
+
+    return database;
+}
+
 GtkMenu* webkit_web_view_get_context_menu(WebKitWebView* webView)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index 34c4d5e..9abfef6 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -364,6 +364,9 @@ webkit_web_view_set_full_content_zoom           (WebKitWebView        *webView,
 WEBKIT_API SoupSession*
 webkit_get_default_session                      (void);
 
+WEBKIT_API WebKitWebPluginDatabase *
+webkit_get_web_plugin_database                  (void);
+
 WEBKIT_API const gchar*
 webkit_web_view_get_encoding                    (WebKitWebView        * webView);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list