summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp145
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h57
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h29
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp151
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h70
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h29
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp18
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp93
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h31
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt35
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am4
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp78
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h2
15 files changed, 727 insertions, 18 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp
new file mode 100644
index 000000000..2282ede37
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 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 "config.h"
+#include "WebKitMimeInfo.h"
+
+#include "WebKitMimeInfoPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+struct _WebKitMimeInfo {
+ _WebKitMimeInfo(const WebCore::MimeClassInfo& mimeInfo)
+ : mimeInfo(mimeInfo)
+ {
+ }
+
+ WebCore::MimeClassInfo mimeInfo;
+ CString mimeType;
+ CString description;
+ GRefPtr<GPtrArray> extensions;
+
+ int referenceCount;
+};
+
+G_DEFINE_BOXED_TYPE(WebKitMimeInfo, webkit_mime_info, webkit_mime_info_ref, webkit_mime_info_unref)
+
+WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo& mimeInfo)
+{
+ WebKitMimeInfo* info = g_slice_new(WebKitMimeInfo);
+ new (info) WebKitMimeInfo(mimeInfo);
+ return info;
+}
+
+/**
+ * webkit_mime_info_ref:
+ * @info: a #WebKitMimeInfo
+ *
+ * Atomically increments the reference count of @info by one. This
+ * function is MT-safe and may be called from any thread.
+ *
+ * Returns: The passed in #WebKitMimeInfo
+ */
+WebKitMimeInfo* webkit_mime_info_ref(WebKitMimeInfo* info)
+{
+ g_atomic_int_inc(&info->referenceCount);
+ return info;
+}
+
+/**
+ * webkit_mime_info_unref:
+ * @info: a #WebKitMimeInfo
+ *
+ * Atomically decrements the reference count of @info by one. If the
+ * reference count drops to 0, all memory allocated by the #WebKitMimeInfo is
+ * released. This function is MT-safe and may be called from any
+ * thread.
+ */
+void webkit_mime_info_unref(WebKitMimeInfo* info)
+{
+ if (g_atomic_int_dec_and_test(&info->referenceCount)) {
+ info->~WebKitMimeInfo();
+ g_slice_free(WebKitMimeInfo, info);
+ }
+}
+
+/**
+ * webkit_mime_info_get_mime_type:
+ * @info: a #WebKitMimeInfo
+ *
+ * Returns: the MIME type of @info
+ */
+const char* webkit_mime_info_get_mime_type(WebKitMimeInfo* info)
+{
+ if (!info->mimeType.isNull())
+ return info->mimeType.data();
+
+ if (info->mimeInfo.type.isEmpty())
+ return 0;
+
+ info->mimeType = info->mimeInfo.type.utf8();
+ return info->mimeType.data();
+}
+
+/**
+ * webkit_mime_info_get_description:
+ * @info: a #WebKitMimeInfo
+ *
+ * Returns: the description of the MIME type of @info
+ */
+const char* webkit_mime_info_get_description(WebKitMimeInfo* info)
+{
+ if (!info->description.isNull())
+ return info->description.data();
+
+ if (info->mimeInfo.desc.isEmpty())
+ return 0;
+
+ info->description = info->mimeInfo.desc.utf8();
+ return info->description.data();
+}
+
+/**
+ * webkit_mime_info_get_extensions:
+ * @info: a #WebKitMimeInfo
+ *
+ * Get the list of file extensions associated to the
+ * MIME type of @info
+ *
+ * Returns: (array zero-terminated=1) (transfer none): a
+ * %NULL-terminated array of strings
+ */
+const char* const* webkit_mime_info_get_extensions(WebKitMimeInfo* info)
+{
+ if (info->extensions)
+ return reinterpret_cast<gchar**>(info->extensions->pdata);
+
+ if (info->mimeInfo.extensions.isEmpty())
+ return 0;
+
+ info->extensions = adoptGRef(g_ptr_array_new_with_free_func(g_free));
+ for (size_t i = 0; i < info->mimeInfo.extensions.size(); ++i) {
+ if (info->mimeInfo.extensions[i].isEmpty())
+ continue;
+ g_ptr_array_add(info->extensions.get(), g_strdup(info->mimeInfo.extensions[i].utf8().data()));
+ }
+ g_ptr_array_add(info->extensions.get(), 0);
+
+ return reinterpret_cast<gchar**>(info->extensions->pdata);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h
new file mode 100644
index 000000000..7ec8e69c5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitMimeInfo_h
+#define WebKitMimeInfo_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_MIME_INFO (webkit_mime_info_get_type())
+
+typedef struct _WebKitMimeInfo WebKitMimeInfo;
+
+
+WEBKIT_API GType
+webkit_mime_info_get_type (void);
+
+WEBKIT_API WebKitMimeInfo *
+webkit_mime_info_ref (WebKitMimeInfo *info);
+
+WEBKIT_API void
+webkit_mime_info_unref (WebKitMimeInfo *info);
+
+WEBKIT_API const gchar *
+webkit_mime_info_get_mime_type (WebKitMimeInfo *info);
+
+WEBKIT_API const gchar *
+webkit_mime_info_get_description (WebKitMimeInfo *info);
+
+WEBKIT_API const gchar * const *
+webkit_mime_info_get_extensions (WebKitMimeInfo *info);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h
new file mode 100644
index 000000000..0ccc007b3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 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 WebKitMimeInfoPrivate_h
+#define WebKitMimeInfoPrivate_h
+
+#include "WebKitMimeInfo.h"
+#include "WebKitPrivate.h"
+#include <WebCore/PluginData.h>
+
+WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo&);
+
+#endif // WebKitMimeInfoPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp
new file mode 100644
index 000000000..aff651aed
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2012 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 "config.h"
+#include "WebKitPlugin.h"
+
+#include "WebKitMimeInfoPrivate.h"
+#include "WebKitPluginPrivate.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+struct _WebKitPluginPrivate {
+ PluginModuleInfo pluginInfo;
+ CString name;
+ CString description;
+ CString path;
+ GList* mimeInfoList;
+};
+
+G_DEFINE_TYPE(WebKitPlugin, webkit_plugin, G_TYPE_OBJECT)
+
+static void webkitPluginFinalize(GObject* object)
+{
+ WebKitPluginPrivate* priv = WEBKIT_PLUGIN(object)->priv;
+ g_list_free_full(priv->mimeInfoList, reinterpret_cast<GDestroyNotify>(webkit_mime_info_unref));
+ priv->~WebKitPluginPrivate();
+ G_OBJECT_CLASS(webkit_plugin_parent_class)->finalize(object);
+}
+
+static void webkit_plugin_init(WebKitPlugin* plugin)
+{
+ WebKitPluginPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(plugin, WEBKIT_TYPE_PLUGIN, WebKitPluginPrivate);
+ plugin->priv = priv;
+ new (priv) WebKitPluginPrivate();
+}
+
+static void webkit_plugin_class_init(WebKitPluginClass* pluginClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(pluginClass);
+ gObjectClass->finalize = webkitPluginFinalize;
+
+ g_type_class_add_private(pluginClass, sizeof(WebKitPluginPrivate));
+}
+
+WebKitPlugin* webkitPluginCreate(const PluginModuleInfo& pluginInfo)
+{
+ WebKitPlugin* plugin = WEBKIT_PLUGIN(g_object_new(WEBKIT_TYPE_PLUGIN, NULL));
+ plugin->priv->pluginInfo = pluginInfo;
+ return plugin;
+}
+
+/**
+ * webkit_plugin_get_name:
+ * @plugin: a #WebKitPlugin
+ *
+ * Returns: the name of the plugin.
+ */
+const char* webkit_plugin_get_name(WebKitPlugin* plugin)
+{
+ g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0);
+
+ if (!plugin->priv->name.isNull())
+ return plugin->priv->name.data();
+
+ if (plugin->priv->pluginInfo.info.name.isEmpty())
+ return 0;
+
+ plugin->priv->name = plugin->priv->pluginInfo.info.name.utf8();
+ return plugin->priv->name.data();
+}
+
+/**
+ * webkit_plugin_get_description:
+ * @plugin: a #WebKitPlugin
+ *
+ * Returns: the description of the plugin.
+ */
+const char* webkit_plugin_get_description(WebKitPlugin* plugin)
+{
+ g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0);
+
+ if (!plugin->priv->description.isNull())
+ plugin->priv->description.data();
+
+ if (plugin->priv->pluginInfo.info.desc.isEmpty())
+ return 0;
+
+ plugin->priv->description = plugin->priv->pluginInfo.info.desc.utf8();
+ return plugin->priv->description.data();
+}
+
+/**
+ * webkit_plugin_get_path:
+ * @plugin: a #WebKitPlugin
+ *
+ * Returns: the absolute path where the plugin is installed.
+ */
+const char* webkit_plugin_get_path(WebKitPlugin* plugin)
+{
+ g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0);
+
+ if (!plugin->priv->path.isNull())
+ return plugin->priv->path.data();
+
+ if (plugin->priv->pluginInfo.path.isEmpty())
+ return 0;
+
+ plugin->priv->path = plugin->priv->pluginInfo.path.utf8();
+ return plugin->priv->path.data();
+}
+
+/**
+ * webkit_plugin_get_mime_info_list:
+ * @plugin: a #WebKitPlugin
+ *
+ * Get information about MIME types handled by the plugin,
+ * as a list of #WebKitMimeInfo.
+ *
+ * Returns: (element-type WebKitMimeInfo) (transfer none): a #GList of #WebKitMimeInfo.
+ */
+GList* webkit_plugin_get_mime_info_list(WebKitPlugin* plugin)
+{
+ g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0);
+
+ if (plugin->priv->mimeInfoList)
+ return plugin->priv->mimeInfoList;
+
+ if (plugin->priv->pluginInfo.info.mimes.isEmpty())
+ return 0;
+
+ for (size_t i = 0; i < plugin->priv->pluginInfo.info.mimes.size(); ++i)
+ plugin->priv->mimeInfoList = g_list_prepend(plugin->priv->mimeInfoList, webkitMimeInfoCreate(plugin->priv->pluginInfo.info.mimes[i]));
+ return plugin->priv->mimeInfoList;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h
new file mode 100644
index 000000000..8928348cc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitPlugin_h
+#define WebKitPlugin_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_PLUGIN (webkit_plugin_get_type())
+#define WEBKIT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PLUGIN, WebKitPlugin))
+#define WEBKIT_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PLUGIN))
+#define WEBKIT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_PLUGIN, WebKitPluginClass))
+#define WEBKIT_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_PLUGIN))
+#define WEBKIT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_PLUGIN, WebKitPluginClass))
+
+typedef struct _WebKitPlugin WebKitPlugin;
+typedef struct _WebKitPluginClass WebKitPluginClass;
+typedef struct _WebKitPluginPrivate WebKitPluginPrivate;
+
+struct _WebKitPlugin {
+ GObject parent;
+
+ WebKitPluginPrivate *priv;
+};
+
+struct _WebKitPluginClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_plugin_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_plugin_get_name (WebKitPlugin *plugin);
+
+WEBKIT_API const gchar *
+webkit_plugin_get_description (WebKitPlugin *plugin);
+
+WEBKIT_API const gchar *
+webkit_plugin_get_path (WebKitPlugin *plugin);
+
+WEBKIT_API GList *
+webkit_plugin_get_mime_info_list (WebKitPlugin *plugin);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h
new file mode 100644
index 000000000..3fe2ac0bf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 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 WebKitPluginPrivate_h
+#define WebKitPluginPrivate_h
+
+#include "PluginModuleInfo.h"
+#include "WebKitPlugin.h"
+#include "WebKitPrivate.h"
+
+WebKitPlugin* webkitPluginCreate(const WebKit::PluginModuleInfo&);
+
+#endif // WebKitPluginPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
index 5c027044b..cd04eb12b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
@@ -919,28 +919,28 @@ static void webkit_settings_init(WebKitSettings* settings)
priv->preferences = adoptWK(WKPreferencesCreate());
- WKRetainPtr<WKStringRef> defaultFontFamilyRef = WKPreferencesCopyStandardFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> defaultFontFamilyRef = adoptWK(WKPreferencesCopyStandardFontFamily(priv->preferences.get()));
priv->defaultFontFamily = WebKit::toImpl(defaultFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> monospaceFontFamilyRef = WKPreferencesCopyFixedFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> monospaceFontFamilyRef = adoptWK(WKPreferencesCopyFixedFontFamily(priv->preferences.get()));
priv->monospaceFontFamily = WebKit::toImpl(monospaceFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> serifFontFamilyRef = WKPreferencesCopySerifFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> serifFontFamilyRef = adoptWK(WKPreferencesCopySerifFontFamily(priv->preferences.get()));
priv->serifFontFamily = WebKit::toImpl(serifFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> sansSerifFontFamilyRef = WKPreferencesCopySansSerifFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> sansSerifFontFamilyRef = adoptWK(WKPreferencesCopySansSerifFontFamily(priv->preferences.get()));
priv->sansSerifFontFamily = WebKit::toImpl(sansSerifFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> cursiveFontFamilyRef = WKPreferencesCopyCursiveFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> cursiveFontFamilyRef = adoptWK(WKPreferencesCopyCursiveFontFamily(priv->preferences.get()));
priv->cursiveFontFamily = WebKit::toImpl(cursiveFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> fantasyFontFamilyRef = WKPreferencesCopyFantasyFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> fantasyFontFamilyRef = adoptWK(WKPreferencesCopyFantasyFontFamily(priv->preferences.get()));
priv->fantasyFontFamily = WebKit::toImpl(fantasyFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> pictographFontFamilyRef = WKPreferencesCopyPictographFontFamily(priv->preferences.get());
+ WKRetainPtr<WKStringRef> pictographFontFamilyRef = adoptWK(WKPreferencesCopyPictographFontFamily(priv->preferences.get()));
priv->pictographFontFamily = WebKit::toImpl(pictographFontFamilyRef.get())->string().utf8();
- WKRetainPtr<WKStringRef> defaultCharsetRef = WKPreferencesCopyDefaultTextEncodingName(priv->preferences.get());
+ WKRetainPtr<WKStringRef> defaultCharsetRef = adoptWK(WKPreferencesCopyDefaultTextEncodingName(priv->preferences.get()));
priv->defaultCharset = WebKit::toImpl(defaultCharsetRef.get())->string().utf8();
}
@@ -1511,7 +1511,7 @@ void webkit_settings_set_serif_font_family(WebKitSettings* settings, const gchar
if (!g_strcmp0(priv->serifFontFamily.data(), serifFontFamily))
return;
- WKRetainPtr<WKStringRef> serifFontFamilyRef = WKStringCreateWithUTF8CString(serifFontFamily);
+ WKRetainPtr<WKStringRef> serifFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(serifFontFamily));
WKPreferencesSetSerifFontFamily(priv->preferences.get(), serifFontFamilyRef.get());
priv->serifFontFamily = WebKit::toImpl(serifFontFamilyRef.get())->string().utf8();
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
index 0b68c086d..5ec64d9d5 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -24,8 +24,10 @@
#include "WebKitCookieManagerPrivate.h"
#include "WebKitDownloadClient.h"
#include "WebKitDownloadPrivate.h"
+#include "WebKitPluginPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitWebContextPrivate.h"
+#include <WebCore/FileSystem.h>
#include <wtf/HashMap.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
@@ -236,6 +238,97 @@ WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* con
return priv->cookieManager.get();
}
+/**
+ * webkit_web_context_set_additional_plugins_directory:
+ * @context: a #WebKitWebContext
+ * @directory: the directory to add
+ *
+ * Set an additional directory where WebKit will look for plugins.
+ */
+void webkit_web_context_set_additional_plugins_directory(WebKitWebContext* context, const char* directory)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+ g_return_if_fail(directory);
+
+ toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory));
+}
+
+struct GetPluginsAsyncData {
+ Vector<PluginModuleInfo> plugins;
+};
+
+static GetPluginsAsyncData* getPluginsAsyncDataCreate()
+{
+ GetPluginsAsyncData* data = g_slice_new(GetPluginsAsyncData);
+ new (data) GetPluginsAsyncData();
+ return data;
+}
+
+static void getPluginsAsyncDataDestroy(GetPluginsAsyncData* data)
+{
+ data->~GetPluginsAsyncData();
+ g_slice_free(GetPluginsAsyncData, data);
+}
+
+static void webkitWebContextGetPluginThread(GSimpleAsyncResult* result, GObject* object, GCancellable*)
+{
+ GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(result));
+ data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins();
+}
+
+/**
+ * webkit_web_context_get_plugins:
+ * @context: a #WebKitWebContext
+ * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
+ *
+ * Asynchronously get the list of installed plugins.
+ *
+ * When the operation is finished, @callback will be called. You can then call
+ * webkit_web_context_get_plugins_finish() to get the result of the operation.
+ */
+void webkit_web_context_get_plugins(WebKitWebContext* context, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+ GRefPtr<GSimpleAsyncResult> result = adoptGRef(g_simple_async_result_new(G_OBJECT(context), callback, userData,
+ reinterpret_cast<gpointer>(webkit_web_context_get_plugins)));
+ g_simple_async_result_set_op_res_gpointer(result.get(), getPluginsAsyncDataCreate(),
+ reinterpret_cast<GDestroyNotify>(getPluginsAsyncDataDestroy));
+ g_simple_async_result_run_in_thread(result.get(), webkitWebContextGetPluginThread, G_PRIORITY_DEFAULT, cancellable);
+}
+
+/**
+ * webkit_web_context_get_plugins_finish:
+ * @context: a #WebKitWebContext
+ * @result: a #GAsyncResult
+ * @error: return location for error or %NULL to ignore
+ *
+ * Finish an asynchronous operation started with webkit_web_context_get_plugins.
+ *
+ * Returns: (element-type WebKitPlugin) (transfer full): a #GList of #WebKitPlugin. You must free the #GList with
+ * g_list_free() and unref the #WebKitPlugin<!-- -->s with g_object_unref() when you're done with them.
+ */
+GList* webkit_web_context_get_plugins_finish(WebKitWebContext* context, GAsyncResult* result, GError** error)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+ g_return_val_if_fail(G_IS_ASYNC_RESULT(result), 0);
+
+ GSimpleAsyncResult* simpleResult = G_SIMPLE_ASYNC_RESULT(result);
+ g_warn_if_fail(g_simple_async_result_get_source_tag(simpleResult) == webkit_web_context_get_plugins);
+
+ if (g_simple_async_result_propagate_error(simpleResult, error))
+ return 0;
+
+ GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(simpleResult));
+ GList* plugins = 0;
+ for (size_t i = 0; i < data->plugins.size(); ++i)
+ plugins = g_list_prepend(plugins, webkitPluginCreate(data->plugins[i]));
+
+ return plugins;
+}
+
WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload)
{
GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
index 45b6e6c1d..02ef73d43 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
@@ -80,23 +80,38 @@ struct _WebKitWebContextClass {
};
WEBKIT_API GType
-webkit_web_context_get_type (void);
+webkit_web_context_get_type (void);
WEBKIT_API WebKitWebContext *
-webkit_web_context_get_default (void);
+webkit_web_context_get_default (void);
WEBKIT_API void
-webkit_web_context_set_cache_model (WebKitWebContext *context,
- WebKitCacheModel cache_model);
+webkit_web_context_set_cache_model (WebKitWebContext *context,
+ WebKitCacheModel cache_model);
WEBKIT_API WebKitCacheModel
-webkit_web_context_get_cache_model (WebKitWebContext *context);
+webkit_web_context_get_cache_model (WebKitWebContext *context);
WEBKIT_API WebKitDownload *
-webkit_web_context_download_uri (WebKitWebContext *context,
- const gchar *uri);
+webkit_web_context_download_uri (WebKitWebContext *context,
+ const gchar *uri);
WEBKIT_API WebKitCookieManager *
-webkit_web_context_get_cookie_manager (WebKitWebContext *context);
+webkit_web_context_get_cookie_manager (WebKitWebContext *context);
+
+WEBKIT_API void
+webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,
+ const gchar *directory);
+
+WEBKIT_API void
+webkit_web_context_get_plugins (WebKitWebContext *context,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+WEBKIT_API GList *
+webkit_web_context_get_plugins_finish (WebKitWebContext *context,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index 821127f3d..63db05f77 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -31,6 +31,7 @@
<xi:include href="xml/WebKitFileChooserRequest.xml"/>
<xi:include href="xml/WebKitFindController.xml"/>
<xi:include href="xml/WebKitCookieManager.xml"/>
+ <xi:include href="xml/WebKitPlugin.xml"/>
</chapter>
<index id="index-all">
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index f5e15d9b2..884177b8b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -29,6 +29,9 @@ webkit_web_context_get_cache_model
webkit_web_context_set_cache_model
webkit_web_context_download_uri
webkit_web_context_get_cookie_manager
+webkit_web_context_set_additional_plugins_directory
+webkit_web_context_get_plugins
+webkit_web_context_get_plugins_finish
<SUBSECTION Standard>
WebKitWebContextClass
@@ -601,3 +604,35 @@ WEBKIT_COOKIE_MANAGER_GET_CLASS
WebKitCookieManagerPrivate
webkit_cookie_manager_get_type
</SECTION>
+
+<SECTION>
+<FILE>WebKitPlugin</FILE>
+WebKitPlugin
+webkit_plugin_get_name
+webkit_plugin_get_description
+webkit_plugin_get_path
+webkit_plugin_get_mime_info_list
+
+<SUBSECTION WebKitMimeInfo>
+WebKitMimeInfo
+webkit_mime_info_ref
+webkit_mime_info_unref
+webkit_mime_info_get_mime_type
+webkit_mime_info_get_description
+webkit_mime_info_get_extensions
+
+<SUBSECTION Standard>
+WebKitPluginClass
+WEBKIT_TYPE_PLUGIN
+WEBKIT_PLUGIN
+WEBKIT_IS_PLUGIN
+WEBKIT_PLUGIN_CLASS
+WEBKIT_IS_PLUGIN_CLASS
+WEBKIT_PLUGIN_GET_CLASS
+WEBKIT_TYPE_MIME_INFO
+
+<SUBSECTION Private>
+webkit_plugin_get_type
+webkit_mime_info_get_type
+WebKitPluginPrivate
+</SECTION>
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
index 1ca821b47..cdf9edd73 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
@@ -15,3 +15,5 @@ webkit_script_dialog_get_type
webkit_javascript_result_get_type
webkit_web_resource_get_type
webkit_cookie_manager_get_type
+webkit_plugin_get_type
+webkit_mime_info_get_type
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
index b389f4954..870d68a5b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
@@ -65,7 +65,9 @@ Libraries_libWebKit2APITestCore_la_CPPFLAGS = $(webkit2_tests_cppflags)
Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
-Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = \
+ -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
+ $(webkit2_tests_cppflags)
Programs_WebKit2APITests_TestWebKitWebContext_LDADD = $(webkit2_tests_ldadd)
Programs_WebKit2APITests_TestWebKitWebContext_LDFLAGS = $(webkit2_tests_ldflags)
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
index ad7ce5b8b..216a5c9f5 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -22,6 +22,7 @@
#include "TestMain.h"
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
static void testWebContextDefault(Test* test, gconstpointer)
{
@@ -29,9 +30,86 @@ static void testWebContextDefault(Test* test, gconstpointer)
g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
}
+class PluginsTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(PluginsTest);
+
+ PluginsTest()
+ : m_context(webkit_web_context_get_default())
+ , m_mainLoop(g_main_loop_new(0, TRUE))
+ , m_plugins(0)
+ {
+ webkit_web_context_set_additional_plugins_directory(m_context, WEBKIT_TEST_PLUGIN_DIR);
+ }
+
+ ~PluginsTest()
+ {
+ g_main_loop_unref(m_mainLoop);
+ g_list_free_full(m_plugins, g_object_unref);
+ }
+
+ static void getPluginsAsyncReadyCallback(GObject*, GAsyncResult* result, PluginsTest* test)
+ {
+ test->m_plugins = webkit_web_context_get_plugins_finish(test->m_context, result, 0);
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ GList* getPlugins()
+ {
+ g_list_free_full(m_plugins, g_object_unref);
+ webkit_web_context_get_plugins(m_context, 0, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this);
+ g_main_loop_run(m_mainLoop);
+ return m_plugins;
+ }
+
+ WebKitWebContext* m_context;
+ GMainLoop* m_mainLoop;
+ GList* m_plugins;
+};
+
+static void testWebContextGetPlugins(PluginsTest* test, gconstpointer)
+{
+ GList* plugins = test->getPlugins();
+ g_assert(plugins);
+
+ GRefPtr<WebKitPlugin> testPlugin;
+ for (GList* item = plugins; item; item = g_list_next(item)) {
+ WebKitPlugin* plugin = WEBKIT_PLUGIN(item->data);
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(plugin));
+ if (!g_strcmp0(webkit_plugin_get_name(plugin), "WebKit Test PlugIn")) {
+ testPlugin = plugin;
+ break;
+ }
+ }
+ g_assert(WEBKIT_IS_PLUGIN(testPlugin.get()));
+
+ GOwnPtr<char> pluginPath(g_build_filename(WEBKIT_TEST_PLUGIN_DIR, "libtestnetscapeplugin.so", NULL));
+ g_assert_cmpstr(webkit_plugin_get_path(testPlugin.get()), ==, pluginPath.get());
+ g_assert_cmpstr(webkit_plugin_get_description(testPlugin.get()), ==, "Simple Netscape® plug-in that handles test content for WebKit");
+ GList* mimeInfoList = webkit_plugin_get_mime_info_list(testPlugin.get());
+ g_assert(mimeInfoList);
+ g_assert_cmpuint(g_list_length(mimeInfoList), ==, 2);
+
+ WebKitMimeInfo* mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
+ g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "image/png");
+ g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "png image");
+ const gchar* const* extensions = webkit_mime_info_get_extensions(mimeInfo);
+ g_assert(extensions);
+ g_assert_cmpstr(extensions[0], ==, "png");
+
+ mimeInfoList = g_list_next(mimeInfoList);
+ mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
+ g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "application/x-webkit-test-netscape");
+ g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "test netscape content");
+ extensions = webkit_mime_info_get_extensions(mimeInfo);
+ g_assert(extensions);
+ g_assert_cmpstr(extensions[0], ==, "testnetscape");
+}
+
void beforeAll()
{
Test::add("WebKitWebContext", "default-context", testWebContextDefault);
+ PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index c5460f333..7699c4966 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -35,6 +35,8 @@
#include <webkit2/WebKitFindController.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
+#include <webkit2/WebKitMimeInfo.h>
+#include <webkit2/WebKitPlugin.h>
#include <webkit2/WebKitPrintOperation.h>
#include <webkit2/WebKitScriptDialog.h>
#include <webkit2/WebKitSettings.h>