1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/*
* 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 "webkitglobalsprivate.h"
#include "webkitwebplugindatabaseprivate.h"
#include "webkitwebpluginprivate.h"
/**
* SECTION:webkitwebplugindatabase
* @short_description: Provides information about the plugins the engine knows about
* @see_also: #WebKitWebPlugin
*
* This object allows you to query information about the plugins found
* by the engine while scanning the usual directories. You can then
* use the #WebKitWebPlugin objects to get more information or
* enable/disable individual plugins.
*/
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)
{
webkitInit();
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 = G_TYPE_INSTANCE_GET_PRIVATE(database, WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabasePrivate);
database->priv = priv;
priv->coreDatabase = PluginDatabase::installedPlugins();
}
/**
* webkit_web_plugin_database_plugins_list_free:
* @list: (element-type WebKitWebPlugin): a #GSList of #WebKitWebPlugin
*
* Frees @list.
*
* Since: 1.3.8
*/
void webkit_web_plugin_database_plugins_list_free(GSList* list)
{
if (!list)
return;
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.
* The returned list must be freed with webkit_web_plugin_database_plugins_list_free()
*
* 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
* @mime_type: 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));
}
|