Changeset 117305 in webkit


Ignore:
Timestamp:
May 16, 2012 10:29:31 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Add API to get plugins to WebKit2 GTK+
https://bugs.webkit.org/show_bug.cgi?id=86356

Reviewed by Martin Robinson.

  • GNUmakefile.list.am: Add new files to compilation.
  • UIProcess/API/gtk/WebKitMimeInfo.cpp: Added.

(_WebKitMimeInfo): Boxed type to represent MIME type information.
(webkitMimeInfoCreate): Ceate a new WebKitMimeInfo.
(webkit_mime_info_ref):
(webkit_mime_info_unref):
(webkit_mime_info_get_mime_type): Return the mime type.
(webkit_mime_info_get_description): Return the mime type
description.
(webkit_mime_info_get_extensions): Return the list of extensions
associated to the mime type.

  • UIProcess/API/gtk/WebKitMimeInfo.h: Added.
  • UIProcess/API/gtk/WebKitMimeInfoPrivate.h: Added.
  • UIProcess/API/gtk/WebKitPlugin.cpp: Added.

(webkitPluginFinalize):
(webkit_plugin_init):
(webkit_plugin_class_init):
(webkitPluginCreate): Create a new WebKitPlugin for the given
PluginModuleInfo.
(webkit_plugin_get_name): Return the plugin name.
(webkit_plugin_get_description): Return the plugin description.
(webkit_plugin_get_path): Return the path where the plugin is
installed.
(webkit_plugin_get_mime_info_list): Return the list of mime types
handled by the plugin.

  • UIProcess/API/gtk/WebKitPlugin.h: Added.
  • UIProcess/API/gtk/WebKitPluginPrivate.h: Added.
  • UIProcess/API/gtk/WebKitWebContext.cpp:

(webkit_web_context_set_additional_plugins_directory): Set an
additional directory to be scanned for plugins.
(GetPluginsAsyncData): Helper struct used to asynchronously get
the list of plugins.
(getPluginsAsyncDataCreate): Create a GetPluginsAsyncData struct.
(getPluginsAsyncDataDestroy): Destroy a GetPluginsAsyncData
struct.
(webkitWebContextGetPluginThread): Thread body to get the list of
plugins installed.
(webkit_web_context_get_plugins): Asynchronously get the list of
plugins installed.
(webkit_web_context_get_plugins_finish): Finish async operation
started by webkit_web_context_get_plugins() returning a list of
WebKitPlugin.

  • UIProcess/API/gtk/WebKitWebContext.h:
  • UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for

WebKitPlugin.

  • UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
  • UIProcess/API/gtk/docs/webkit2gtk.types: Add new types.
  • UIProcess/API/gtk/tests/GNUmakefile.am:
  • UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:

(testWebContextGetPlugins):
(beforeAll):

  • UIProcess/API/gtk/webkit2.h:
Location:
trunk/Source/WebKit2
Files:
4 added
10 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r117301 r117305  
     12012-05-16  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add API to get plugins to WebKit2 GTK+
     4        https://bugs.webkit.org/show_bug.cgi?id=86356
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.list.am: Add new files to compilation.
     9        * UIProcess/API/gtk/WebKitMimeInfo.cpp: Added.
     10        (_WebKitMimeInfo): Boxed type to represent MIME type information.
     11        (webkitMimeInfoCreate): Ceate a new WebKitMimeInfo.
     12        (webkit_mime_info_ref):
     13        (webkit_mime_info_unref):
     14        (webkit_mime_info_get_mime_type): Return the mime type.
     15        (webkit_mime_info_get_description): Return the mime type
     16        description.
     17        (webkit_mime_info_get_extensions): Return the list of extensions
     18        associated to the mime type.
     19        * UIProcess/API/gtk/WebKitMimeInfo.h: Added.
     20        * UIProcess/API/gtk/WebKitMimeInfoPrivate.h: Added.
     21        * UIProcess/API/gtk/WebKitPlugin.cpp: Added.
     22        (webkitPluginFinalize):
     23        (webkit_plugin_init):
     24        (webkit_plugin_class_init):
     25        (webkitPluginCreate): Create a new WebKitPlugin for the given
     26        PluginModuleInfo.
     27        (webkit_plugin_get_name): Return the plugin name.
     28        (webkit_plugin_get_description): Return the plugin description.
     29        (webkit_plugin_get_path): Return the path where the plugin is
     30        installed.
     31        (webkit_plugin_get_mime_info_list): Return the list of mime types
     32        handled by the plugin.
     33        * UIProcess/API/gtk/WebKitPlugin.h: Added.
     34        * UIProcess/API/gtk/WebKitPluginPrivate.h: Added.
     35        * UIProcess/API/gtk/WebKitWebContext.cpp:
     36        (webkit_web_context_set_additional_plugins_directory): Set an
     37        additional directory to be scanned for plugins.
     38        (GetPluginsAsyncData): Helper struct used to asynchronously get
     39        the list of plugins.
     40        (getPluginsAsyncDataCreate): Create a GetPluginsAsyncData struct.
     41        (getPluginsAsyncDataDestroy): Destroy a GetPluginsAsyncData
     42        struct.
     43        (webkitWebContextGetPluginThread): Thread body to get the list of
     44        plugins installed.
     45        (webkit_web_context_get_plugins): Asynchronously get the list of
     46        plugins installed.
     47        (webkit_web_context_get_plugins_finish): Finish async operation
     48        started by webkit_web_context_get_plugins() returning a list of
     49        WebKitPlugin.
     50        * UIProcess/API/gtk/WebKitWebContext.h:
     51        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for
     52        WebKitPlugin.
     53        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
     54        * UIProcess/API/gtk/docs/webkit2gtk.types: Add new types.
     55        * UIProcess/API/gtk/tests/GNUmakefile.am:
     56        * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
     57        (testWebContextGetPlugins):
     58        (beforeAll):
     59        * UIProcess/API/gtk/webkit2.h:
     60
    1612012-05-16  Brady Eidson  <beidson@apple.com>
    262
  • trunk/Source/WebKit2/GNUmakefile.list.am

    r116956 r117305  
    9797        $(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \
    9898        $(WebKit2)/UIProcess/API/gtk/WebKitJavascriptResult.h \
     99        $(WebKit2)/UIProcess/API/gtk/WebKitMimeInfo.h \
    99100        $(WebKit2)/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
     101        $(WebKit2)/UIProcess/API/gtk/WebKitPlugin.h \
    100102        $(WebKit2)/UIProcess/API/gtk/WebKitPolicyDecision.h \
    101103        $(WebKit2)/UIProcess/API/gtk/WebKitPrintOperation.h \
     
    584586        Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h \
    585587        Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp \
     588        Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp \
     589        Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h \
     590        Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h \
    586591        Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h \
    587592        Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp \
     
    589594        Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
    590595        Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h \
     596        Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp \
     597        Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h \
     598        Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h \
    591599        Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp \
    592600        Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h \
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h

    r117304 r117305  
    11/*
    2  * Copyright (C) 2011 Igalia S.L.
     2 * Copyright (C) 2012 Igalia S.L.
    33 *
    44 * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Lesser General Public
     5 * modify it under the terms of the GNU Library General Public
    66 * License as published by the Free Software Foundation; either
    7  * version 2,1 of the License, or (at your option) any later version.
     7 * version 2 of the License, or (at your option) any later version.
    88 *
    99 * This library is distributed in the hope that it will be useful,
     
    1818 */
    1919
    20 #include "config.h"
     20#ifndef WebKitMimeInfoPrivate_h
     21#define WebKitMimeInfoPrivate_h
    2122
    22 #include "TestMain.h"
    23 #include <gtk/gtk.h>
    24 #include <webkit2/webkit2.h>
     23#include "WebKitMimeInfo.h"
     24#include "WebKitPrivate.h"
     25#include <WebCore/PluginData.h>
    2526
    26 static void testWebContextDefault(Test* test, gconstpointer)
    27 {
    28     // Check there's a single instance of the default web context.
    29     g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
    30 }
     27WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo&);
    3128
    32 void beforeAll()
    33 {
    34     Test::add("WebKitWebContext", "default-context", testWebContextDefault);
    35 }
    36 
    37 void afterAll()
    38 {
    39 }
     29#endif // WebKitMimeInfoPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h

    r117304 r117305  
    11/*
    2  * Copyright (C) 2011 Igalia S.L.
     2 * Copyright (C) 2012 Igalia S.L.
    33 *
    44 * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Lesser General Public
     5 * modify it under the terms of the GNU Library General Public
    66 * License as published by the Free Software Foundation; either
    7  * version 2,1 of the License, or (at your option) any later version.
     7 * version 2 of the License, or (at your option) any later version.
    88 *
    99 * This library is distributed in the hope that it will be useful,
     
    1818 */
    1919
    20 #include "config.h"
     20#ifndef WebKitPluginPrivate_h
     21#define WebKitPluginPrivate_h
    2122
    22 #include "TestMain.h"
    23 #include <gtk/gtk.h>
    24 #include <webkit2/webkit2.h>
     23#include "PluginModuleInfo.h"
     24#include "WebKitPlugin.h"
     25#include "WebKitPrivate.h"
    2526
    26 static void testWebContextDefault(Test* test, gconstpointer)
    27 {
    28     // Check there's a single instance of the default web context.
    29     g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
    30 }
     27WebKitPlugin* webkitPluginCreate(const WebKit::PluginModuleInfo&);
    3128
    32 void beforeAll()
    33 {
    34     Test::add("WebKitWebContext", "default-context", testWebContextDefault);
    35 }
    36 
    37 void afterAll()
    38 {
    39 }
     29#endif // WebKitPluginPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r114226 r117305  
    2525#include "WebKitDownloadClient.h"
    2626#include "WebKitDownloadPrivate.h"
     27#include "WebKitPluginPrivate.h"
    2728#include "WebKitPrivate.h"
    2829#include "WebKitWebContextPrivate.h"
     30#include <WebCore/FileSystem.h>
    2931#include <wtf/HashMap.h>
    3032#include <wtf/gobject/GRefPtr.h>
     
    237239}
    238240
     241/**
     242 * webkit_web_context_set_additional_plugins_directory:
     243 * @context: a #WebKitWebContext
     244 * @directory: the directory to add
     245 *
     246 * Set an additional directory where WebKit will look for plugins.
     247 */
     248void webkit_web_context_set_additional_plugins_directory(WebKitWebContext* context, const char* directory)
     249{
     250    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     251    g_return_if_fail(directory);
     252
     253    toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory));
     254}
     255
     256struct GetPluginsAsyncData {
     257    Vector<PluginModuleInfo> plugins;
     258};
     259
     260static GetPluginsAsyncData* getPluginsAsyncDataCreate()
     261{
     262    GetPluginsAsyncData* data = g_slice_new(GetPluginsAsyncData);
     263    new (data) GetPluginsAsyncData();
     264    return data;
     265}
     266
     267static void getPluginsAsyncDataDestroy(GetPluginsAsyncData* data)
     268{
     269    data->~GetPluginsAsyncData();
     270    g_slice_free(GetPluginsAsyncData, data);
     271}
     272
     273static void webkitWebContextGetPluginThread(GSimpleAsyncResult* result, GObject* object, GCancellable*)
     274{
     275    GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(result));
     276    data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins();
     277}
     278
     279/**
     280 * webkit_web_context_get_plugins:
     281 * @context: a #WebKitWebContext
     282 * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
     283 * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
     284 * @user_data: (closure): the data to pass to callback function
     285 *
     286 * Asynchronously get the list of installed plugins.
     287 *
     288 * When the operation is finished, @callback will be called. You can then call
     289 * webkit_web_context_get_plugins_finish() to get the result of the operation.
     290 */
     291void webkit_web_context_get_plugins(WebKitWebContext* context, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
     292{
     293    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     294
     295    GRefPtr<GSimpleAsyncResult> result = adoptGRef(g_simple_async_result_new(G_OBJECT(context), callback, userData,
     296                                                                             reinterpret_cast<gpointer>(webkit_web_context_get_plugins)));
     297    g_simple_async_result_set_op_res_gpointer(result.get(), getPluginsAsyncDataCreate(),
     298                                              reinterpret_cast<GDestroyNotify>(getPluginsAsyncDataDestroy));
     299    g_simple_async_result_run_in_thread(result.get(), webkitWebContextGetPluginThread, G_PRIORITY_DEFAULT, cancellable);
     300}
     301
     302/**
     303 * webkit_web_context_get_plugins_finish:
     304 * @context: a #WebKitWebContext
     305 * @result: a #GAsyncResult
     306 * @error: return location for error or %NULL to ignore
     307 *
     308 * Finish an asynchronous operation started with webkit_web_context_get_plugins.
     309 *
     310 * Returns: (element-type WebKitPlugin) (transfer full): a #GList of #WebKitPlugin. You must free the #GList with
     311 *    g_list_free() and unref the #WebKitPlugin<!-- -->s with g_object_unref() when you're done with them.
     312 */
     313GList* webkit_web_context_get_plugins_finish(WebKitWebContext* context, GAsyncResult* result, GError** error)
     314{
     315    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
     316    g_return_val_if_fail(G_IS_ASYNC_RESULT(result), 0);
     317
     318    GSimpleAsyncResult* simpleResult = G_SIMPLE_ASYNC_RESULT(result);
     319    g_warn_if_fail(g_simple_async_result_get_source_tag(simpleResult) == webkit_web_context_get_plugins);
     320
     321    if (g_simple_async_result_propagate_error(simpleResult, error))
     322        return 0;
     323
     324    GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(simpleResult));
     325    GList* plugins = 0;
     326    for (size_t i = 0; i < data->plugins.size(); ++i)
     327        plugins = g_list_prepend(plugins, webkitPluginCreate(data->plugins[i]));
     328
     329    return plugins;
     330}
     331
    239332WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload)
    240333{
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h

    r113870 r117305  
    8181
    8282WEBKIT_API GType
    83 webkit_web_context_get_type           (void);
     83webkit_web_context_get_type                         (void);
    8484
    8585WEBKIT_API WebKitWebContext *
    86 webkit_web_context_get_default        (void);
     86webkit_web_context_get_default                      (void);
    8787
    8888WEBKIT_API void
    89 webkit_web_context_set_cache_model    (WebKitWebContext *context,
    90                                        WebKitCacheModel  cache_model);
     89webkit_web_context_set_cache_model                  (WebKitWebContext  *context,
     90                                                     WebKitCacheModel    cache_model);
    9191WEBKIT_API WebKitCacheModel
    92 webkit_web_context_get_cache_model    (WebKitWebContext *context);
     92webkit_web_context_get_cache_model                  (WebKitWebContext  *context);
    9393
    9494WEBKIT_API WebKitDownload *
    95 webkit_web_context_download_uri       (WebKitWebContext *context,
    96                                        const gchar      *uri);
     95webkit_web_context_download_uri                     (WebKitWebContext  *context,
     96                                                     const gchar        *uri);
    9797
    9898WEBKIT_API WebKitCookieManager *
    99 webkit_web_context_get_cookie_manager (WebKitWebContext *context);
     99webkit_web_context_get_cookie_manager               (WebKitWebContext   *context);
     100
     101WEBKIT_API void
     102webkit_web_context_set_additional_plugins_directory (WebKitWebContext   *context,
     103                                                     const gchar        *directory);
     104
     105WEBKIT_API void
     106webkit_web_context_get_plugins                      (WebKitWebContext   *context,
     107                                                     GCancellable       *cancellable,
     108                                                     GAsyncReadyCallback callback,
     109                                                     gpointer            user_data);
     110
     111WEBKIT_API GList *
     112webkit_web_context_get_plugins_finish               (WebKitWebContext   *context,
     113                                                     GAsyncResult       *result,
     114                                                     GError            **error);
    100115
    101116G_END_DECLS
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml

    r115627 r117305  
    3232    <xi:include href="xml/WebKitFindController.xml"/>
    3333    <xi:include href="xml/WebKitCookieManager.xml"/>
     34    <xi:include href="xml/WebKitPlugin.xml"/>
    3435  </chapter>
    3536
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r116652 r117305  
    3030webkit_web_context_download_uri
    3131webkit_web_context_get_cookie_manager
     32webkit_web_context_set_additional_plugins_directory
     33webkit_web_context_get_plugins
     34webkit_web_context_get_plugins_finish
    3235
    3336<SUBSECTION Standard>
     
    602605webkit_cookie_manager_get_type
    603606</SECTION>
     607
     608<SECTION>
     609<FILE>WebKitPlugin</FILE>
     610WebKitPlugin
     611webkit_plugin_get_name
     612webkit_plugin_get_description
     613webkit_plugin_get_path
     614webkit_plugin_get_mime_info_list
     615
     616<SUBSECTION WebKitMimeInfo>
     617WebKitMimeInfo
     618webkit_mime_info_ref
     619webkit_mime_info_unref
     620webkit_mime_info_get_mime_type
     621webkit_mime_info_get_description
     622webkit_mime_info_get_extensions
     623
     624<SUBSECTION Standard>
     625WebKitPluginClass
     626WEBKIT_TYPE_PLUGIN
     627WEBKIT_PLUGIN
     628WEBKIT_IS_PLUGIN
     629WEBKIT_PLUGIN_CLASS
     630WEBKIT_IS_PLUGIN_CLASS
     631WEBKIT_PLUGIN_GET_CLASS
     632WEBKIT_TYPE_MIME_INFO
     633
     634<SUBSECTION Private>
     635webkit_plugin_get_type
     636webkit_mime_info_get_type
     637WebKitPluginPrivate
     638</SECTION>
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types

    r115627 r117305  
    1616webkit_web_resource_get_type
    1717webkit_cookie_manager_get_type
     18webkit_plugin_get_type
     19webkit_mime_info_get_type
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am

    r113870 r117305  
    6666Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \
    6767        Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
    68 Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = $(webkit2_tests_cppflags)
     68Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = \
     69        -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
     70        $(webkit2_tests_cppflags)
    6971Programs_WebKit2APITests_TestWebKitWebContext_LDADD = $(webkit2_tests_ldadd)
    7072Programs_WebKit2APITests_TestWebKitWebContext_LDFLAGS = $(webkit2_tests_ldflags)
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp

    r97226 r117305  
    2323#include <gtk/gtk.h>
    2424#include <webkit2/webkit2.h>
     25#include <wtf/gobject/GRefPtr.h>
    2526
    2627static void testWebContextDefault(Test* test, gconstpointer)
     
    3031}
    3132
     33class PluginsTest: public Test {
     34public:
     35    MAKE_GLIB_TEST_FIXTURE(PluginsTest);
     36
     37    PluginsTest()
     38        : m_context(webkit_web_context_get_default())
     39        , m_mainLoop(g_main_loop_new(0, TRUE))
     40        , m_plugins(0)
     41    {
     42        webkit_web_context_set_additional_plugins_directory(m_context, WEBKIT_TEST_PLUGIN_DIR);
     43    }
     44
     45    ~PluginsTest()
     46    {
     47        g_main_loop_unref(m_mainLoop);
     48        g_list_free_full(m_plugins, g_object_unref);
     49    }
     50
     51    static void getPluginsAsyncReadyCallback(GObject*, GAsyncResult* result, PluginsTest* test)
     52    {
     53        test->m_plugins = webkit_web_context_get_plugins_finish(test->m_context, result, 0);
     54        g_main_loop_quit(test->m_mainLoop);
     55    }
     56
     57    GList* getPlugins()
     58    {
     59        g_list_free_full(m_plugins, g_object_unref);
     60        webkit_web_context_get_plugins(m_context, 0, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this);
     61        g_main_loop_run(m_mainLoop);
     62        return m_plugins;
     63    }
     64
     65    WebKitWebContext* m_context;
     66    GMainLoop* m_mainLoop;
     67    GList* m_plugins;
     68};
     69
     70static void testWebContextGetPlugins(PluginsTest* test, gconstpointer)
     71{
     72    GList* plugins = test->getPlugins();
     73    g_assert(plugins);
     74
     75    GRefPtr<WebKitPlugin> testPlugin;
     76    for (GList* item = plugins; item; item = g_list_next(item)) {
     77        WebKitPlugin* plugin = WEBKIT_PLUGIN(item->data);
     78        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(plugin));
     79        if (!g_strcmp0(webkit_plugin_get_name(plugin), "WebKit Test PlugIn")) {
     80            testPlugin = plugin;
     81            break;
     82        }
     83    }
     84    g_assert(WEBKIT_IS_PLUGIN(testPlugin.get()));
     85
     86    GOwnPtr<char> pluginPath(g_build_filename(WEBKIT_TEST_PLUGIN_DIR, "libtestnetscapeplugin.so", NULL));
     87    g_assert_cmpstr(webkit_plugin_get_path(testPlugin.get()), ==, pluginPath.get());
     88    g_assert_cmpstr(webkit_plugin_get_description(testPlugin.get()), ==, "Simple Netscape® plug-in that handles test content for WebKit");
     89    GList* mimeInfoList = webkit_plugin_get_mime_info_list(testPlugin.get());
     90    g_assert(mimeInfoList);
     91    g_assert_cmpuint(g_list_length(mimeInfoList), ==, 2);
     92
     93    WebKitMimeInfo* mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
     94    g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "image/png");
     95    g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "png image");
     96    const gchar* const* extensions = webkit_mime_info_get_extensions(mimeInfo);
     97    g_assert(extensions);
     98    g_assert_cmpstr(extensions[0], ==, "png");
     99
     100    mimeInfoList = g_list_next(mimeInfoList);
     101    mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
     102    g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "application/x-webkit-test-netscape");
     103    g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "test netscape content");
     104    extensions = webkit_mime_info_get_extensions(mimeInfo);
     105    g_assert(extensions);
     106    g_assert_cmpstr(extensions[0], ==, "testnetscape");
     107}
     108
    32109void beforeAll()
    33110{
    34111    Test::add("WebKitWebContext", "default-context", testWebContextDefault);
     112    PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
    35113}
    36114
  • trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h

    r115627 r117305  
    3636#include <webkit2/WebKitHitTestResult.h>
    3737#include <webkit2/WebKitJavascriptResult.h>
     38#include <webkit2/WebKitMimeInfo.h>
     39#include <webkit2/WebKitPlugin.h>
    3840#include <webkit2/WebKitPrintOperation.h>
    3941#include <webkit2/WebKitScriptDialog.h>
Note: See TracChangeset for help on using the changeset viewer.