Changeset 149642 in webkit
- Timestamp:
- May 6, 2013 2:20:41 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149641 r149642 1 2013-05-06 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [GTK] Add webkit_uri_scheme_request_finish_error 4 https://bugs.webkit.org/show_bug.cgi?id=94316 5 6 Reviewed by Anders Carlsson. 7 8 No behaviour change, covered by existing tests. 9 10 * platform/network/soup/ResourceError.h: 11 (ResourceError): Rename genericIOError() to genericGError(). 12 * platform/network/soup/ResourceErrorSoup.cpp: 13 (WebCore::ResourceError::httpError): Use genercicGError() instead of 14 genericIOError(). 15 (WebCore::ResourceError::genericGError): Use error domain instead of 16 always return a G_IO_ERROR. 17 * platform/network/soup/ResourceHandleSoup.cpp: Use genericGError() 18 instead of genericIOError(). 19 (WebCore::redirectSkipCallback): 20 (WebCore::readCallback): 21 1 22 2013-05-06 Bem Jones-Bey <bjonesbe@adobe.com> 2 23 -
trunk/Source/WebCore/platform/network/soup/ResourceError.h
r139239 r149642 52 52 static ResourceError httpError(SoupMessage*, GError*, SoupRequest*); 53 53 static ResourceError transportError(SoupRequest*, int statusCode, const String& reasonPhrase); 54 static ResourceError generic IOError(GError*, SoupRequest*);54 static ResourceError genericGError(GError*, SoupRequest*); 55 55 static ResourceError tlsError(SoupRequest*, unsigned tlsErrors, GTlsCertificate*); 56 56 static ResourceError timeoutError(const String& failingURL); -
trunk/Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp
r148507 r149642 59 59 String::fromUTF8(message->reason_phrase)); 60 60 else 61 return generic IOError(error, request);61 return genericGError(error, request); 62 62 } 63 63 … … 69 69 } 70 70 71 ResourceError ResourceError::generic IOError(GError* error, SoupRequest* request)71 ResourceError ResourceError::genericGError(GError* error, SoupRequest* request) 72 72 { 73 return ResourceError(g_quark_to_string( G_IO_ERROR), error->code,73 return ResourceError(g_quark_to_string(error->domain), error->code, 74 74 failingURI(request), String::fromUTF8(error->message)); 75 75 } -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r149383 r149642 527 527 gssize bytesSkipped = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr()); 528 528 if (error) { 529 handle->client()->didFail(handle.get(), ResourceError::generic IOError(error.get(), d->m_soupRequest.get()));529 handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get())); 530 530 cleanupSoupRequestOperation(handle.get()); 531 531 return; … … 1318 1318 1319 1319 if (error) { 1320 handle->client()->didFail(handle.get(), ResourceError::generic IOError(error.get(), d->m_soupRequest.get()));1320 handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get())); 1321 1321 cleanupSoupRequestOperation(handle.get()); 1322 1322 return; -
trunk/Source/WebKit2/ChangeLog
r149639 r149642 1 2013-05-06 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [GTK] Add webkit_uri_scheme_request_finish_error 4 https://bugs.webkit.org/show_bug.cgi?id=94316 5 6 Reviewed by Anders Carlsson. 7 8 This new method will allow to finish WebKitURISchemeRequest with a 9 GError that will be passed to the WebKitWebView through the 10 "load-failed" signal. 11 12 * UIProcess/API/gtk/WebKitURISchemeRequest.cpp: 13 (webkit_uri_scheme_request_finish_error): Implement new method using 14 WebSoupRequestManagerProxy::didFailURIRequest(). 15 * UIProcess/API/gtk/WebKitURISchemeRequest.h: Add new method header. 16 * UIProcess/API/gtk/WebKitWebContext.cpp: Include the usage of the new 17 method in the code example at webkit_web_context_register_uri_scheme() 18 documentation. 19 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Include the new 20 method. 21 * UIProcess/API/gtk/tests/LoadTrackingTest.cpp: 22 (loadFailedCallback): Set m_error to monitor it from the tests. 23 (LoadTrackingTest::loadURI): Clear m_error before each load. 24 (LoadTrackingTest::loadHtml): Ditto. 25 (LoadTrackingTest::loadPlainText): Ditto. 26 (LoadTrackingTest::loadRequest): Ditto. 27 (LoadTrackingTest::reload): Ditto. 28 (LoadTrackingTest::goBack): Ditto. 29 (LoadTrackingTest::goForward): Ditto. 30 * UIProcess/API/gtk/tests/LoadTrackingTest.h: Add new member m_error. 31 * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp: 32 (testWebContextURIScheme): Modify test to check the behavior of the new 33 method. 34 * UIProcess/soup/WebSoupRequestManagerProxy.cpp: 35 (WebKit::WebSoupRequestManagerProxy::didFailURIRequest): 36 (WebKit): Implement new method using 37 WebSoupRequestManager::DidFailURIRequest(). 38 * UIProcess/soup/WebSoupRequestManagerProxy.h: 39 (WebSoupRequestManagerProxy): Add new method header. 40 * WebProcess/soup/WebSoupRequestManager.cpp: 41 (WebKit): 42 (WebKit::WebSoupRequestManager::didFailURIRequest): Implement new method 43 setting the error and completing the request. 44 * WebProcess/soup/WebSoupRequestManager.h: 45 (WebSoupRequestManager): Add new method header. 46 * WebProcess/soup/WebSoupRequestManager.messages.in: Add new method 47 signature. 48 1 49 2013-05-06 Anders Carlsson <andersca@apple.com> 2 50 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
r137469 r149642 28 28 #include "WebSoupRequestManagerProxy.h" 29 29 #include <WebCore/GOwnPtrSoup.h> 30 #include <WebCore/ResourceError.h> 30 31 #include <libsoup/soup.h> 31 32 #include <wtf/gobject/GRefPtr.h> … … 214 215 reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request)); 215 216 } 217 218 /** 219 * webkit_uri_scheme_request_finish_error: 220 * @request: a #WebKitURISchemeRequest 221 * @error: a #GError that will be passed to the #WebKitWebView 222 * 223 * Finish a #WebKitURISchemeRequest with a #GError. 224 * 225 * Since: 2.2 226 */ 227 void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GError* error) 228 { 229 g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request)); 230 g_return_if_fail(error); 231 232 WebKitURISchemeRequestPrivate* priv = request->priv; 233 234 WebCore::ResourceError resourceError(g_quark_to_string(error->domain), error->code, priv->uri.data(), String::fromUTF8(error->message)); 235 priv->webRequestManager->didFailURIRequest(resourceError, priv->requestID); 236 237 webkitWebContextDidFinishURIRequest(priv->webContext, priv->requestID); 238 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h
r148679 r149642 73 73 const gchar *mime_type); 74 74 75 WEBKIT_API void 76 webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request, 77 GError *error); 78 75 79 G_END_DECLS 76 80 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r149117 r149642 569 569 * #WebKitURISchemeRequest. 570 570 * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the 571 * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of 572 * the request is available. 571 * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later 572 * when the data of the request is available or 573 * webkit_uri_scheme_request_finish_error() in case of error. 573 574 * 574 575 * <informalexample><programlisting> … … 588 589 * } else if (!g_strcmp0 (path, "applications")) { 589 590 * /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/ 590 * } else {591 * } else if (!g_strcmp0 (path, "example")) { 591 592 * gchar *contents; 592 593 * 593 * contents = g_strdup_printf ("<html><body><p> Invalid about:%s page</p></body></html>", path);594 * contents = g_strdup_printf ("<html><body><p>Example about page</p></body></html>"); 594 595 * stream_length = strlen (contents); 595 596 * stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free); 597 * } else { 598 * GError *error; 599 * 600 * error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path); 601 * webkit_uri_scheme_request_finish_error (request, error); 602 * g_error_free (error); 603 * return; 596 604 * } 597 605 * webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html"); -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r149440 r149642 807 807 webkit_uri_scheme_request_get_web_view 808 808 webkit_uri_scheme_request_finish 809 webkit_uri_scheme_request_finish_error 809 810 810 811 <SUBSECTION Standard> -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
r129223 r149642 64 64 { 65 65 test->m_loadFailed = true; 66 test->m_error.set(g_error_copy(error)); 66 67 67 68 switch (loadEvent) { … … 154 155 m_loadEvents.clear(); 155 156 m_estimatedProgress = 0; 157 m_error.clear(); 156 158 WebViewTest::loadURI(uri); 157 159 } … … 161 163 m_loadEvents.clear(); 162 164 m_estimatedProgress = 0; 165 m_error.clear(); 163 166 WebViewTest::loadHtml(html, baseURI); 164 167 } … … 168 171 m_loadEvents.clear(); 169 172 m_estimatedProgress = 0; 173 m_error.clear(); 170 174 WebViewTest::loadPlainText(plainText); 171 175 } … … 175 179 m_loadEvents.clear(); 176 180 m_estimatedProgress = 0; 181 m_error.clear(); 177 182 WebViewTest::loadRequest(request); 178 183 } … … 182 187 m_loadEvents.clear(); 183 188 m_estimatedProgress = 0; 189 m_error.clear(); 184 190 webkit_web_view_reload(m_webView); 185 191 } … … 189 195 m_loadEvents.clear(); 190 196 m_estimatedProgress = 0; 197 m_error.clear(); 191 198 WebViewTest::goBack(); 192 199 } … … 196 203 m_loadEvents.clear(); 197 204 m_estimatedProgress = 0; 205 m_error.clear(); 198 206 WebViewTest::goForward(); 199 207 } -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
r124456 r149642 60 60 bool m_runLoadUntilCompletion; 61 61 bool m_loadFailed; 62 GOwnPtr<GError> m_error; 62 63 Vector<LoadEvents> m_loadEvents; 63 64 float m_estimatedProgress; -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
r130507 r149642 115 115 static const char* kBarHTML = "<html><body>Bar</body></html>"; 116 116 static const char* kEchoHTMLFormat = "<html><body>%s</body></html>"; 117 static const char* errorDomain = "test"; 118 static const int errorCode = 10; 119 static const char* errorMessage = "Error message."; 117 120 118 121 class URISchemeTest: public LoadTrackingTest { … … 123 126 URISchemeHandler() 124 127 : replyLength(0) 125 , replyWithPath(false)126 128 { 127 129 } 128 130 129 URISchemeHandler(const char* reply, int replyLength, const char* mimeType , bool replyWithPath = false)131 URISchemeHandler(const char* reply, int replyLength, const char* mimeType) 130 132 : reply(reply) 131 133 , replyLength(replyLength) 132 134 , mimeType(mimeType) 133 , replyWithPath(replyWithPath)134 135 { 135 136 } … … 138 139 int replyLength; 139 140 CString mimeType; 140 bool replyWithPath;141 141 }; 142 142 … … 152 152 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get())); 153 153 154 String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request))); 155 g_assert(!scheme.isEmpty()); 156 g_assert(test->m_handlersMap.contains(scheme)); 157 const URISchemeHandler& handler = test->m_handlersMap.get(scheme); 158 159 if (handler.replyWithPath) { 154 const char* scheme = webkit_uri_scheme_request_get_scheme(request); 155 g_assert(scheme); 156 g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme))); 157 158 if (!g_strcmp0(scheme, "error")) { 159 GOwnPtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage)); 160 webkit_uri_scheme_request_finish_error(request, error.get()); 161 return; 162 } 163 164 const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme)); 165 166 if (!g_strcmp0(scheme, "echo")) { 160 167 char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request)); 161 168 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free); 162 169 } else if (!handler.reply.isNull()) 163 170 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0); 171 164 172 webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data()); 165 173 } 166 174 167 void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType , bool replyWithPath = false)168 { 169 m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType , replyWithPath));175 void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType) 176 { 177 m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType)); 170 178 webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); 171 179 } … … 185 193 g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize)); 186 194 187 test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html" , true);195 test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html"); 188 196 test->loadURI("echo:hello world"); 189 197 test->waitUntilLoadFinished(); … … 206 214 g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); 207 215 g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed)); 216 217 test->registerURISchemeHandler("error", 0, 0, 0); 218 test->m_loadEvents.clear(); 219 test->loadURI("error:error"); 220 test->waitUntilLoadFinished(); 221 g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); 222 g_assert(test->m_loadFailed); 223 g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode); 224 g_assert_cmpstr(test->m_error->message, ==, errorMessage); 208 225 } 209 226 -
trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp
r141658 r149642 117 117 } 118 118 119 void WebSoupRequestManagerProxy::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID) 120 { 121 if (!context()) 122 return; 123 124 m_loadFailed = true; 125 context()->sendToAllProcesses(Messages::WebSoupRequestManager::DidFailURIRequest(error, requestID)); 126 } 127 119 128 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h
r147403 r149642 48 48 void didReceiveURIRequestData(const WebData*, uint64_t requestID); 49 49 void didReceiveURIRequest(const String& uriString, WebPageProxy*, uint64_t requestID); 50 void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID); 50 51 51 52 const Vector<String>& registeredURISchemes() const { return m_registeredURISchemes; } -
trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp
r148507 r149642 156 156 } 157 157 158 void WebSoupRequestManager::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID) 159 { 160 WebSoupRequestAsyncData* data = m_requestMap.get(requestID); 161 ASSERT(data); 162 GRefPtr<GSimpleAsyncResult> result = data->releaseResult(); 163 ASSERT(result.get()); 164 165 g_simple_async_result_take_error(result.get(), 166 g_error_new_literal(g_quark_from_string(error.domain().utf8().data()), 167 error.errorCode(), 168 error.localizedDescription().utf8().data())); 169 g_simple_async_result_complete(result.get()); 170 171 m_requestMap.remove(requestID); 172 } 173 158 174 void WebSoupRequestManager::send(GSimpleAsyncResult* result, GCancellable* cancellable) 159 175 { -
trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h
r141366 r149642 23 23 #include "DataReference.h" 24 24 #include "MessageReceiver.h" 25 #include <WebCore/ResourceError.h> 25 26 #include <wtf/HashMap.h> 26 27 #include <wtf/Noncopyable.h> … … 54 55 void didHandleURIRequest(const CoreIPC::DataReference&, uint64_t contentLength, const String& mimeType, uint64_t requestID); 55 56 void didReceiveURIRequestData(const CoreIPC::DataReference&, uint64_t requestID); 57 void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID); 56 58 57 59 WebProcess* m_process; -
trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in
r116738 r149642 25 25 DidHandleURIRequest(CoreIPC::DataReference requestData, uint64_t contentLength, WTF::String mimeType, uint64_t requestID); 26 26 DidReceiveURIRequestData(CoreIPC::DataReference requestData, uint64_t requestID); 27 DidFailURIRequest(WebCore::ResourceError error, uint64_t requestID); 27 28 } -
trunk/Tools/ChangeLog
r149638 r149642 1 2013-05-06 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [GTK] Add webkit_uri_scheme_request_finish_error 4 https://bugs.webkit.org/show_bug.cgi?id=94316 5 6 Reviewed by Anders Carlsson. 7 8 * MiniBrowser/gtk/main.c: 9 (miniBrowserErrorQuark): Add function to create a global quark for 10 MiniBrowser. 11 (aboutURISchemeRequestCallback): Update MiniBrowser to use the new 12 function webkit_uri_scheme_request_finish_error(). 13 1 14 2013-05-06 Mike Lattanzio <mlattanzio@blackberry.com> 2 15 -
trunk/Tools/MiniBrowser/gtk/main.c
r147624 r149642 32 32 #include <webkit2/webkit2.h> 33 33 34 #define MINI_BROWSER_ERROR (miniBrowserErrorQuark()) 35 34 36 static const gchar **uriArguments = NULL; 35 37 static const char *miniBrowserAboutScheme = "minibrowser-about"; 38 39 typedef enum { 40 MINI_BROWSER_ERROR_INVALID_ABOUT_PATH 41 } MiniBrowserError; 42 43 static GQuark miniBrowserErrorQuark() 44 { 45 return g_quark_from_string("minibrowser-quark"); 46 } 36 47 37 48 static gchar *argumentToURL(const char *filename) … … 207 218 const gchar *path; 208 219 gchar *contents; 220 GError *error; 209 221 210 222 path = webkit_uri_scheme_request_get_path(request); 211 if (!g_strcmp0(path, "minibrowser")) 223 if (!g_strcmp0(path, "minibrowser")) { 212 224 contents = g_strdup_printf("<html><body><h1>WebKitGTK+ MiniBrowser</h1><p>The WebKit2 test browser of the GTK+ port.</p><p>WebKit version: %d.%d.%d</p></body></html>", 213 225 webkit_get_major_version(), 214 226 webkit_get_minor_version(), 215 227 webkit_get_micro_version()); 216 else 217 contents = g_strdup_printf("<html><body><p>Invalid about:%s page.</p></body></html>", path); 218 219 streamLength = strlen(contents); 220 stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free); 221 222 webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html"); 223 g_object_unref(stream); 228 streamLength = strlen(contents); 229 stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free); 230 231 webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html"); 232 g_object_unref(stream); 233 } else { 234 error = g_error_new(MINI_BROWSER_ERROR, MINI_BROWSER_ERROR_INVALID_ABOUT_PATH, "Invalid about:%s page.", path); 235 webkit_uri_scheme_request_finish_error(request, error); 236 g_error_free(error); 237 } 224 238 } 225 239
Note: See TracChangeset
for help on using the changeset viewer.