Changeset 119700 in webkit
- Timestamp:
- Jun 7, 2012 3:16:03 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r119697 r119700 1 2012-06-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add API to register custom URI schemes to WebKit2 GTK+ API 4 https://bugs.webkit.org/show_bug.cgi?id=84133 5 6 Reviewed by Martin Robinson. 7 8 * GNUmakefile.list.am: Add new files to compilation. 9 * UIProcess/API/gtk/WebKitPrivate.h: 10 * UIProcess/API/gtk/WebKitRequestManagerClient.cpp: Added. 11 (didReceiveURIRequest): Callback emitted by the C API when a 12 request for a custom URI scheme has been received. Call 13 webkitWebContextReceivedURIRequest() to handle the request. 14 (didFailToLoadURIRequest): Callback emitted by the C API when a 15 request for a custom URI scheme failed to load. Call 16 webkitWebContextDidFailToLoadURIRequest() to noitfy the web 17 context. 18 (attachRequestManagerClientToContext): Initialize the 19 WKSoupRequestManagerClient. 20 * UIProcess/API/gtk/WebKitRequestManagerClient.h: Added. 21 * UIProcess/API/gtk/WebKitURISchemeRequest.cpp: Added. 22 (webkit_uri_scheme_request_init): 23 (webkitURISchemeRequestFinalize): 24 (webkit_uri_scheme_request_class_init): 25 (webkitURISchemeRequestCreate): Create a new 26 WebKitURISchemeRequest for the given URI and request identifier. 27 (webkitURISchemeRequestGetID): Return the request identifier. 28 (webkitURISchemeRequestCancel): Cancel the request operation. 29 (webkit_uri_scheme_request_get_scheme): Return the scheme of the 30 request. 31 (webkit_uri_scheme_request_get_uri): Return the full URI of the 32 request. 33 (webkit_uri_scheme_request_get_path): Return the path of the URI. 34 (webkitURISchemeRequestReadCallback): Read callback emitted when 35 reading the contents of the input stream. 36 (webkit_uri_scheme_request_finish): Finish the request by reading 37 the contents of the input stream and sending the data to the 38 WebProcess. 39 * UIProcess/API/gtk/WebKitURISchemeRequest.h: Added. 40 * UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h: Added. 41 * UIProcess/API/gtk/WebKitWebContext.cpp: 42 (WebKitURISchemeHandler::WebKitURISchemeHandler): Helper struct to 43 save callback and user data of registered URI schemes. 44 (createDefaultWebContext): Initialize the SoupRequestManager. 45 (webkit_web_context_register_uri_scheme): Public API to register a 46 custom URI scheme providing a callback that will be called to 47 handle requests for that URI scheme. 48 (webkitWebContextGetRequestManager): Helper private method to 49 return the SoupRequestManager. 50 (webkitWebContextReceivedURIRequest): Get the 51 WebKitURISchemeHandler for the given request identifier and call 52 the callback. Save the request in the request map. 53 (webkitWebContextDidFailToLoadURIRequest): Cancel the ongoing 54 request. 55 (webkitWebContextDidFinishURIRequest): Remove the request from the 56 map. 57 * UIProcess/API/gtk/WebKitWebContext.h: 58 * UIProcess/API/gtk/WebKitWebContextPrivate.h: 59 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add 60 WebKitURISchemeRequest section. 61 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols. 62 * UIProcess/API/gtk/docs/webkit2gtk.types: Add 63 webkit_uri_scheme_request_get_type. 64 * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp: 65 (testWebContextURIScheme): 66 (beforeAll): 67 * UIProcess/API/gtk/webkit2.h: Include WebKitURISchemeRequest.h. 68 1 69 2012-06-07 Andras Becsi <andras.becsi@nokia.com> 2 70 -
trunk/Source/WebKit2/GNUmakefile.list.am
r119475 r119700 110 110 $(WebKit2)/UIProcess/API/gtk/WebKitURIRequest.h \ 111 111 $(WebKit2)/UIProcess/API/gtk/WebKitURIResponse.h \ 112 $(WebKit2)/UIProcess/API/gtk/WebKitURISchemeRequest.h \ 112 113 $(WebKit2)/UIProcess/API/gtk/WebKitWebContext.h \ 113 114 $(WebKit2)/UIProcess/API/gtk/WebKitWebInspector.h \ … … 623 624 Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h \ 624 625 Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp \ 626 Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp \ 627 Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h \ 625 628 Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.cpp \ 626 629 Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.h \ … … 642 645 Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h \ 643 646 Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h \ 647 Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp \ 648 Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h \ 649 Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h \ 644 650 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h \ 645 651 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
r119475 r119700 28 28 29 29 #include <WebKit2/WKAPICast.h> 30 #include <WebKit2/WKContextSoup.h> 30 31 #include <WebKit2/WKDownload.h> 31 32 #include <WebKit2/WKFindOptions.h> … … 38 39 #include <WebKit2/WKRetainPtr.h> 39 40 #include <WebKit2/WKSerializedScriptValue.h> 41 #include <WebKit2/WKSoupRequestManager.h> 40 42 #include <WebKit2/WKString.h> 41 43 #include <WebKit2/WebKit2.h> -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r119404 r119700 28 28 #include "WebKitPluginPrivate.h" 29 29 #include "WebKitPrivate.h" 30 #include "WebKitRequestManagerClient.h" 31 #include "WebKitURISchemeRequestPrivate.h" 30 32 #include "WebKitWebContextPrivate.h" 31 33 #include <WebCore/FileSystem.h> … … 42 44 }; 43 45 46 struct WebKitURISchemeHandler { 47 WebKitURISchemeHandler() 48 : callback(0) 49 , userData(0) 50 { 51 } 52 WebKitURISchemeHandler(WebKitURISchemeRequestCallback callback, void* userData) 53 : callback(callback) 54 , userData(userData) 55 { 56 } 57 58 WebKitURISchemeRequestCallback callback; 59 void* userData; 60 }; 61 62 typedef HashMap<String, WebKitURISchemeHandler> URISchemeHandlerMap; 63 typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap; 64 44 65 struct _WebKitWebContextPrivate { 45 66 WKRetainPtr<WKContextRef> context; 46 67 47 68 GRefPtr<WebKitCookieManager> cookieManager; 69 WKRetainPtr<WKSoupRequestManagerRef> requestManager; 70 URISchemeHandlerMap uriSchemeHandlers; 71 URISchemeRequestMap uriSchemeRequests; 48 72 #if ENABLE(GEOLOCATION) 49 73 RefPtr<WebKitGeolocationProvider> geolocationProvider; … … 96 120 static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL))); 97 121 webContext->priv->context = WKContextGetSharedProcessContext(); 122 webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get()); 98 123 WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser); 99 124 attachDownloadClientToContext(webContext.get()); 125 attachRequestManagerClientToContext(webContext.get()); 100 126 #if ENABLE(GEOLOCATION) 101 127 WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); … … 326 352 } 327 353 354 /** 355 * webkit_web_context_register_uri_scheme: 356 * @context: a #WebKitWebContext 357 * @scheme: the network scheme to register 358 * @callback: a #WebKitURISchemeRequestCallback 359 * @user_data: data to pass to callback function 360 * 361 * Register @scheme in @context, so that when an URI request with @scheme is made in the 362 * #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a 363 * #WebKitURISchemeRequest. 364 * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the 365 * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of 366 * the request is available. 367 * 368 * <informalexample><programlisting> 369 * static void 370 * about_uri_scheme_request_cb (WebKitURISchemeRequest *request, 371 * gpointer user_data) 372 * { 373 * GInputStream *stream; 374 * gsize stream_length; 375 * const gchar *path; 376 * 377 * path = webkit_uri_scheme_request_get_path (request); 378 * if (!g_strcmp0 (path, "plugins")) { 379 * /<!-- -->* Create a GInputStream with the contents of plugins about page, and set its length to stream_length *<!-- -->/ 380 * } else if (!g_strcmp0 (path, "memory")) { 381 * /<!-- -->* Create a GInputStream with the contents of memory about page, and set its length to stream_length *<!-- -->/ 382 * } else if (!g_strcmp0 (path, "applications")) { 383 * /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/ 384 * } else { 385 * gchar *contents; 386 * 387 * contents = g_strdup_printf ("<html><body><p>Invalid about:%s page</p></body></html>", path); 388 * stream_length = strlen (contents); 389 * stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free); 390 * } 391 * webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html"); 392 * g_object_unref (stream); 393 * } 394 * </programlisting></informalexample> 395 */ 396 void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const char* scheme, WebKitURISchemeRequestCallback callback, gpointer userData) 397 { 398 g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); 399 g_return_if_fail(scheme); 400 g_return_if_fail(callback); 401 402 context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), WebKitURISchemeHandler(callback, userData)); 403 WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme)); 404 WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get()); 405 } 406 328 407 WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) 329 408 { … … 354 433 } 355 434 435 WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext* context) 436 { 437 return context->priv->requestManager.get(); 438 } 439 440 void webkitWebContextReceivedURIRequest(WebKitWebContext* context, WebKitURISchemeRequest* request) 441 { 442 WebKitURISchemeHandler handler = context->priv->uriSchemeHandlers.get(webkit_uri_scheme_request_get_scheme(request)); 443 if (!handler.callback) 444 return; 445 446 context->priv->uriSchemeRequests.set(webkitURISchemeRequestGetID(request), request); 447 handler.callback(request, handler.userData); 448 } 449 450 void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext* context, uint64_t requestID) 451 { 452 GRefPtr<WebKitURISchemeRequest> request = context->priv->uriSchemeRequests.get(requestID); 453 if (!request.get()) 454 return; 455 webkitURISchemeRequestCancel(request.get()); 456 } 457 458 void webkitWebContextDidFinishURIRequest(WebKitWebContext* context, uint64_t requestID) 459 { 460 context->priv->uriSchemeRequests.remove(requestID); 461 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
r117305 r119700 29 29 #include <webkit2/WebKitDefines.h> 30 30 #include <webkit2/WebKitDownload.h> 31 #include <webkit2/WebKitURISchemeRequest.h> 31 32 32 33 G_BEGIN_DECLS … … 59 60 } WebKitCacheModel; 60 61 62 /** 63 * WebKitURISchemeRequestCallback: 64 * @request: the #WebKitURISchemeRequest 65 * @user_data: user data passed to the callback 66 * 67 * Type definition for a function that will be called back when an URI request is 68 * made for a user registered URI scheme. 69 */ 70 typedef void (* WebKitURISchemeRequestCallback) (WebKitURISchemeRequest *request, 71 gpointer user_data); 72 61 73 typedef struct _WebKitWebContext WebKitWebContext; 62 74 typedef struct _WebKitWebContextClass WebKitWebContextClass; … … 87 99 88 100 WEBKIT_API void 89 webkit_web_context_set_cache_model (WebKitWebContext *context,90 WebKitCacheModel cache_model);101 webkit_web_context_set_cache_model (WebKitWebContext *context, 102 WebKitCacheModel cache_model); 91 103 WEBKIT_API WebKitCacheModel 92 webkit_web_context_get_cache_model (WebKitWebContext *context);104 webkit_web_context_get_cache_model (WebKitWebContext *context); 93 105 94 106 WEBKIT_API WebKitDownload * 95 webkit_web_context_download_uri (WebKitWebContext *context,96 const gchar *uri);107 webkit_web_context_download_uri (WebKitWebContext *context, 108 const gchar *uri); 97 109 98 110 WEBKIT_API WebKitCookieManager * 99 webkit_web_context_get_cookie_manager (WebKitWebContext *context);111 webkit_web_context_get_cookie_manager (WebKitWebContext *context); 100 112 101 113 WEBKIT_API void 102 webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,103 const gchar *directory);114 webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context, 115 const gchar *directory); 104 116 105 117 WEBKIT_API void 106 webkit_web_context_get_plugins (WebKitWebContext *context,107 GCancellable *cancellable,108 GAsyncReadyCallback callback,109 gpointer user_data);118 webkit_web_context_get_plugins (WebKitWebContext *context, 119 GCancellable *cancellable, 120 GAsyncReadyCallback callback, 121 gpointer user_data); 110 122 111 123 WEBKIT_API GList * 112 webkit_web_context_get_plugins_finish (WebKitWebContext *context, 113 GAsyncResult *result, 114 GError **error); 115 124 webkit_web_context_get_plugins_finish (WebKitWebContext *context, 125 GAsyncResult *result, 126 GError **error); 127 WEBKIT_API void 128 webkit_web_context_register_uri_scheme (WebKitWebContext *context, 129 const gchar *scheme, 130 WebKitURISchemeRequestCallback callback, 131 gpointer user_data); 116 132 G_END_DECLS 117 133 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
r105708 r119700 27 27 #define WebKitWebContextPrivate_h 28 28 29 #include "WebKitPrivate.h" 30 #include "WebKitURISchemeRequest.h" 29 31 #include "WebKitWebContext.h" 30 #include <WebKit2/WebKit2.h>31 32 G_BEGIN_DECLS33 32 34 33 WKContextRef webkitWebContextGetWKContext(WebKitWebContext*); … … 36 35 void webkitWebContextRemoveDownload(WKDownloadRef); 37 36 void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*); 38 39 G_END_DECLS 37 WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext*); 38 void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*); 39 void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID); 40 void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID); 40 41 41 42 #endif // WebKitWebContextPrivate_h -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r119475 r119700 36 36 <xi:include href="xml/WebKitPlugin.xml"/> 37 37 <xi:include href="xml/WebKitWebInspector.xml"/> 38 <xi:include href="xml/WebKitURISchemeRequest.xml"/> 38 39 </chapter> 39 40 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r119493 r119700 33 33 webkit_web_context_get_plugins 34 34 webkit_web_context_get_plugins_finish 35 36 <SUBSECTION URI Scheme> 37 WebKitURISchemeRequestCallback 38 webkit_web_context_register_uri_scheme 35 39 36 40 <SUBSECTION Standard> … … 705 709 WebKitWebInspectorPrivate 706 710 </SECTION> 711 712 <FILE>WebKitURISchemeRequest</FILE> 713 WebKitURISchemeRequest 714 webkit_uri_scheme_request_get_scheme 715 webkit_uri_scheme_request_get_uri 716 webkit_uri_scheme_request_get_path 717 webkit_uri_scheme_request_finish 718 719 <SUBSECTION Standard> 720 WebKitURISchemeRequestClass 721 WEBKIT_TYPE_URI_SCHEME_REQUEST 722 WEBKIT_URI_SCHEME_REQUEST 723 WEBKIT_IS_URI_SCHEME_REQUEST 724 WEBKIT_URI_SCHEME_REQUEST_CLASS 725 WEBKIT_IS_URI_SCHEME_REQUEST_CLASS 726 WEBKIT_URI_SCHEME_REQUEST_GET_CLASS 727 728 <SUBSECTION Private> 729 WebKitURISchemeRequestPrivate 730 webkit_uri_scheme_request_get_type 731 </SECTION> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
r118146 r119700 19 19 webkit_mime_info_get_type 20 20 webkit_web_inspector_get_type 21 webkit_uri_scheme_request_get_type -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
r117305 r119700 20 20 #include "config.h" 21 21 22 #include " TestMain.h"22 #include "LoadTrackingTest.h" 23 23 #include <gtk/gtk.h> 24 24 #include <webkit2/webkit2.h> 25 #include <wtf/HashMap.h> 26 #include <wtf/gobject/GOwnPtr.h> 25 27 #include <wtf/gobject/GRefPtr.h> 28 #include <wtf/text/StringHash.h> 26 29 27 30 static void testWebContextDefault(Test* test, gconstpointer) … … 107 110 } 108 111 112 static const char* kBarHTML = "<html><body>Bar</body></html>"; 113 static const char* kEchoHTMLFormat = "<html><body>%s</body></html>"; 114 115 class URISchemeTest: public LoadTrackingTest { 116 public: 117 MAKE_GLIB_TEST_FIXTURE(URISchemeTest); 118 119 struct URISchemeHandler { 120 URISchemeHandler() 121 : replyLength(0) 122 , replyWithPath(false) 123 { 124 } 125 126 URISchemeHandler(const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false) 127 : reply(reply) 128 , replyLength(replyLength) 129 , mimeType(mimeType) 130 , replyWithPath(replyWithPath) 131 { 132 } 133 134 CString reply; 135 int replyLength; 136 CString mimeType; 137 bool replyWithPath; 138 }; 139 140 static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData) 141 { 142 URISchemeTest* test = static_cast<URISchemeTest*>(userData); 143 test->m_uriSchemeRequest = request; 144 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); 145 146 GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new()); 147 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get())); 148 149 String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request))); 150 g_assert(!scheme.isEmpty()); 151 g_assert(test->m_handlersMap.contains(scheme)); 152 const URISchemeHandler& handler = test->m_handlersMap.get(scheme); 153 154 if (handler.replyWithPath) { 155 char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request)); 156 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free); 157 } else if (!handler.reply.isNull()) 158 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0); 159 webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data()); 160 } 161 162 void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false) 163 { 164 m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType, replyWithPath)); 165 webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this); 166 } 167 168 static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData) 169 { 170 size_t dataSize; 171 GOwnPtr<GError> error; 172 unsigned char* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(object), result, &dataSize, &error.outPtr()); 173 g_assert(data); 174 175 URISchemeTest* test = static_cast<URISchemeTest*>(userData); 176 test->m_resourceData.set(reinterpret_cast<char*>(data)); 177 test->m_resourceDataSize = dataSize; 178 g_main_loop_quit(test->m_mainLoop); 179 } 180 181 const char* mainResourceData(size_t& mainResourceDataSize) 182 { 183 m_resourceDataSize = 0; 184 m_resourceData.clear(); 185 WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView); 186 g_assert(resource); 187 188 webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this); 189 g_main_loop_run(m_mainLoop); 190 191 mainResourceDataSize = m_resourceDataSize; 192 return m_resourceData.get(); 193 } 194 195 GOwnPtr<char> m_resourceData; 196 size_t m_resourceDataSize; 197 GRefPtr<WebKitURISchemeRequest> m_uriSchemeRequest; 198 HashMap<String, URISchemeHandler> m_handlersMap; 199 }; 200 201 static void testWebContextURIScheme(URISchemeTest* test, gconstpointer) 202 { 203 test->registerURISchemeHandler("foo", kBarHTML, strlen(kBarHTML), "text/html"); 204 test->loadURI("foo:blank"); 205 test->waitUntilLoadFinished(); 206 size_t mainResourceDataSize = 0; 207 const char* mainResourceData = test->mainResourceData(mainResourceDataSize); 208 g_assert_cmpint(mainResourceDataSize, ==, strlen(kBarHTML)); 209 g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize)); 210 211 test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html", true); 212 test->loadURI("echo:hello world"); 213 test->waitUntilLoadFinished(); 214 GOwnPtr<char> echoHTML(g_strdup_printf(kEchoHTMLFormat, webkit_uri_scheme_request_get_path(test->m_uriSchemeRequest.get()))); 215 mainResourceDataSize = 0; 216 mainResourceData = test->mainResourceData(mainResourceDataSize); 217 g_assert_cmpint(mainResourceDataSize, ==, strlen(echoHTML.get())); 218 g_assert(!strncmp(mainResourceData, echoHTML.get(), mainResourceDataSize)); 219 220 test->registerURISchemeHandler("nomime", kBarHTML, -1, 0); 221 test->m_loadEvents.clear(); 222 test->loadURI("nomime:foo bar"); 223 test->waitUntilLoadFinished(); 224 g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); 225 226 test->registerURISchemeHandler("empty", 0, 0, "text/html"); 227 test->m_loadEvents.clear(); 228 test->loadURI("empty:nothing"); 229 test->waitUntilLoadFinished(); 230 g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); 231 g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed)); 232 } 233 109 234 void beforeAll() 110 235 { 111 236 Test::add("WebKitWebContext", "default-context", testWebContextDefault); 112 237 PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins); 238 URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme); 113 239 } 114 240 -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r119475 r119700 47 47 #include <webkit2/WebKitURIRequest.h> 48 48 #include <webkit2/WebKitURIResponse.h> 49 #include <webkit2/WebKitURISchemeRequest.h> 49 50 #include <webkit2/WebKitWebContext.h> 50 51 #include <webkit2/WebKitWebInspector.h>
Note: See TracChangeset
for help on using the changeset viewer.