Changeset 117305 in webkit
- Timestamp:
- May 16, 2012 10:29:31 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 added
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r117301 r117305 1 2012-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 1 61 2012-05-16 Brady Eidson <beidson@apple.com> 2 62 -
trunk/Source/WebKit2/GNUmakefile.list.am
r116956 r117305 97 97 $(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \ 98 98 $(WebKit2)/UIProcess/API/gtk/WebKitJavascriptResult.h \ 99 $(WebKit2)/UIProcess/API/gtk/WebKitMimeInfo.h \ 99 100 $(WebKit2)/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \ 101 $(WebKit2)/UIProcess/API/gtk/WebKitPlugin.h \ 100 102 $(WebKit2)/UIProcess/API/gtk/WebKitPolicyDecision.h \ 101 103 $(WebKit2)/UIProcess/API/gtk/WebKitPrintOperation.h \ … … 584 586 Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h \ 585 587 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 \ 586 591 Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h \ 587 592 Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp \ … … 589 594 Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \ 590 595 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 \ 591 599 Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp \ 592 600 Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h
r117304 r117305 1 1 /* 2 * Copyright (C) 201 1Igalia S.L.2 * Copyright (C) 2012 Igalia S.L. 3 3 * 4 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU L esserGeneral Public5 * modify it under the terms of the GNU Library General Public 6 6 * License as published by the Free Software Foundation; either 7 * version 2 ,1of the License, or (at your option) any later version.7 * version 2 of the License, or (at your option) any later version. 8 8 * 9 9 * This library is distributed in the hope that it will be useful, … … 18 18 */ 19 19 20 #include "config.h" 20 #ifndef WebKitMimeInfoPrivate_h 21 #define WebKitMimeInfoPrivate_h 21 22 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> 25 26 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 } 27 WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo&); 31 28 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 1 1 /* 2 * Copyright (C) 201 1Igalia S.L.2 * Copyright (C) 2012 Igalia S.L. 3 3 * 4 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU L esserGeneral Public5 * modify it under the terms of the GNU Library General Public 6 6 * License as published by the Free Software Foundation; either 7 * version 2 ,1of the License, or (at your option) any later version.7 * version 2 of the License, or (at your option) any later version. 8 8 * 9 9 * This library is distributed in the hope that it will be useful, … … 18 18 */ 19 19 20 #include "config.h" 20 #ifndef WebKitPluginPrivate_h 21 #define WebKitPluginPrivate_h 21 22 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" 25 26 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 } 27 WebKitPlugin* webkitPluginCreate(const WebKit::PluginModuleInfo&); 31 28 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 25 25 #include "WebKitDownloadClient.h" 26 26 #include "WebKitDownloadPrivate.h" 27 #include "WebKitPluginPrivate.h" 27 28 #include "WebKitPrivate.h" 28 29 #include "WebKitWebContextPrivate.h" 30 #include <WebCore/FileSystem.h> 29 31 #include <wtf/HashMap.h> 30 32 #include <wtf/gobject/GRefPtr.h> … … 237 239 } 238 240 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 */ 248 void 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 256 struct GetPluginsAsyncData { 257 Vector<PluginModuleInfo> plugins; 258 }; 259 260 static GetPluginsAsyncData* getPluginsAsyncDataCreate() 261 { 262 GetPluginsAsyncData* data = g_slice_new(GetPluginsAsyncData); 263 new (data) GetPluginsAsyncData(); 264 return data; 265 } 266 267 static void getPluginsAsyncDataDestroy(GetPluginsAsyncData* data) 268 { 269 data->~GetPluginsAsyncData(); 270 g_slice_free(GetPluginsAsyncData, data); 271 } 272 273 static 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 */ 291 void 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 */ 313 GList* 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 239 332 WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) 240 333 { -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
r113870 r117305 81 81 82 82 WEBKIT_API GType 83 webkit_web_context_get_type (void);83 webkit_web_context_get_type (void); 84 84 85 85 WEBKIT_API WebKitWebContext * 86 webkit_web_context_get_default (void);86 webkit_web_context_get_default (void); 87 87 88 88 WEBKIT_API void 89 webkit_web_context_set_cache_model (WebKitWebContext*context,90 WebKitCacheModelcache_model);89 webkit_web_context_set_cache_model (WebKitWebContext *context, 90 WebKitCacheModel cache_model); 91 91 WEBKIT_API WebKitCacheModel 92 webkit_web_context_get_cache_model (WebKitWebContext*context);92 webkit_web_context_get_cache_model (WebKitWebContext *context); 93 93 94 94 WEBKIT_API WebKitDownload * 95 webkit_web_context_download_uri (WebKitWebContext*context,96 const gchar*uri);95 webkit_web_context_download_uri (WebKitWebContext *context, 96 const gchar *uri); 97 97 98 98 WEBKIT_API WebKitCookieManager * 99 webkit_web_context_get_cookie_manager (WebKitWebContext *context); 99 webkit_web_context_get_cookie_manager (WebKitWebContext *context); 100 101 WEBKIT_API void 102 webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context, 103 const gchar *directory); 104 105 WEBKIT_API void 106 webkit_web_context_get_plugins (WebKitWebContext *context, 107 GCancellable *cancellable, 108 GAsyncReadyCallback callback, 109 gpointer user_data); 110 111 WEBKIT_API GList * 112 webkit_web_context_get_plugins_finish (WebKitWebContext *context, 113 GAsyncResult *result, 114 GError **error); 100 115 101 116 G_END_DECLS -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r115627 r117305 32 32 <xi:include href="xml/WebKitFindController.xml"/> 33 33 <xi:include href="xml/WebKitCookieManager.xml"/> 34 <xi:include href="xml/WebKitPlugin.xml"/> 34 35 </chapter> 35 36 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r116652 r117305 30 30 webkit_web_context_download_uri 31 31 webkit_web_context_get_cookie_manager 32 webkit_web_context_set_additional_plugins_directory 33 webkit_web_context_get_plugins 34 webkit_web_context_get_plugins_finish 32 35 33 36 <SUBSECTION Standard> … … 602 605 webkit_cookie_manager_get_type 603 606 </SECTION> 607 608 <SECTION> 609 <FILE>WebKitPlugin</FILE> 610 WebKitPlugin 611 webkit_plugin_get_name 612 webkit_plugin_get_description 613 webkit_plugin_get_path 614 webkit_plugin_get_mime_info_list 615 616 <SUBSECTION WebKitMimeInfo> 617 WebKitMimeInfo 618 webkit_mime_info_ref 619 webkit_mime_info_unref 620 webkit_mime_info_get_mime_type 621 webkit_mime_info_get_description 622 webkit_mime_info_get_extensions 623 624 <SUBSECTION Standard> 625 WebKitPluginClass 626 WEBKIT_TYPE_PLUGIN 627 WEBKIT_PLUGIN 628 WEBKIT_IS_PLUGIN 629 WEBKIT_PLUGIN_CLASS 630 WEBKIT_IS_PLUGIN_CLASS 631 WEBKIT_PLUGIN_GET_CLASS 632 WEBKIT_TYPE_MIME_INFO 633 634 <SUBSECTION Private> 635 webkit_plugin_get_type 636 webkit_mime_info_get_type 637 WebKitPluginPrivate 638 </SECTION> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
r115627 r117305 16 16 webkit_web_resource_get_type 17 17 webkit_cookie_manager_get_type 18 webkit_plugin_get_type 19 webkit_mime_info_get_type -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
r113870 r117305 66 66 Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \ 67 67 Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp 68 Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = $(webkit2_tests_cppflags) 68 Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = \ 69 -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \ 70 $(webkit2_tests_cppflags) 69 71 Programs_WebKit2APITests_TestWebKitWebContext_LDADD = $(webkit2_tests_ldadd) 70 72 Programs_WebKit2APITests_TestWebKitWebContext_LDFLAGS = $(webkit2_tests_ldflags) -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
r97226 r117305 23 23 #include <gtk/gtk.h> 24 24 #include <webkit2/webkit2.h> 25 #include <wtf/gobject/GRefPtr.h> 25 26 26 27 static void testWebContextDefault(Test* test, gconstpointer) … … 30 31 } 31 32 33 class PluginsTest: public Test { 34 public: 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 70 static 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 32 109 void beforeAll() 33 110 { 34 111 Test::add("WebKitWebContext", "default-context", testWebContextDefault); 112 PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins); 35 113 } 36 114 -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r115627 r117305 36 36 #include <webkit2/WebKitHitTestResult.h> 37 37 #include <webkit2/WebKitJavascriptResult.h> 38 #include <webkit2/WebKitMimeInfo.h> 39 #include <webkit2/WebKitPlugin.h> 38 40 #include <webkit2/WebKitPrintOperation.h> 39 41 #include <webkit2/WebKitScriptDialog.h>
Note: See TracChangeset
for help on using the changeset viewer.