[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
kov at webkit.org
kov at webkit.org
Tue Jan 5 23:44:22 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 1971b596008fecfc514a899bc36135b0e045c143
Author: kov at webkit.org <kov at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 8 02:44:05 2009 +0000
WebCore
Reviewed by Xan Lopez.
[GTK] Doesn't respect Content-Disposition for downloads, and provides no way for apps to do that
https://bugs.webkit.org/show_bug.cgi?id=32247
Allow creating a ResourceResponse from a SoupMessage.
Covered by API test.
* platform/network/soup/ResourceResponse.h:
(WebCore::ResourceResponse::ResourceResponse):
* platform/network/soup/ResourceResponseSoup.cpp:
(WebCore::ResourceResponse::updateFromSoupMessage):
WebKit/gtk
Reviewed by Xan Lopez.
[GTK] Doesn't respect Content-Disposition for downloads, and provides no way for apps to do that
https://bugs.webkit.org/show_bug.cgi?id=32247
Provide a way for applications to respect Content-Disposition, by
fetching the WebKitNetworkResponse from the frame during
mime-type-policy-decision-requested.
* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): Download
content when Content-Disposition is attachment.
* tests/testmimehandling.c:
(server_callback):
(mime_type_policy_decision_requested_cb):
* tests/testwebframe.c:
(test_webkit_web_frame_response):
(main):
* webkit/webkitprivate.cpp:
(WebKit::core):
* webkit/webkitwebframe.cpp:
(webkit_web_frame_get_network_response):
* webkit/webkitwebframe.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index cd9f55a..bc87b4e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2009-12-08 Gustavo Noronha Silva <gustavo.noronha at collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Doesn't respect Content-Disposition for downloads, and provides no way for apps to do that
+ https://bugs.webkit.org/show_bug.cgi?id=32247
+
+ Allow creating a ResourceResponse from a SoupMessage.
+
+ Covered by API test.
+
+ * platform/network/soup/ResourceResponse.h:
+ (WebCore::ResourceResponse::ResourceResponse):
+ * platform/network/soup/ResourceResponseSoup.cpp:
+ (WebCore::ResourceResponse::updateFromSoupMessage):
+
2009-12-07 Nikolas Zimmermann <nzimmermann at rim.com>
Not reviewed. Reverting problematic patch, causing errors.
diff --git a/WebCore/platform/network/soup/ResourceResponse.h b/WebCore/platform/network/soup/ResourceResponse.h
index 5fa31a0..ecd9f21 100644
--- a/WebCore/platform/network/soup/ResourceResponse.h
+++ b/WebCore/platform/network/soup/ResourceResponse.h
@@ -44,7 +44,14 @@ public:
{
}
+ ResourceResponse(SoupMessage* soupMessage)
+ : ResourceResponseBase()
+ {
+ updateFromSoupMessage(soupMessage);
+ }
+
SoupMessage* toSoupMessage() const;
+ void updateFromSoupMessage(SoupMessage* soupMessage);
private:
friend class ResourceResponseBase;
diff --git a/WebCore/platform/network/soup/ResourceResponseSoup.cpp b/WebCore/platform/network/soup/ResourceResponseSoup.cpp
index 293577f..caf0b31 100644
--- a/WebCore/platform/network/soup/ResourceResponseSoup.cpp
+++ b/WebCore/platform/network/soup/ResourceResponseSoup.cpp
@@ -22,6 +22,7 @@
#include "ResourceResponse.h"
#include "CString.h"
+#include "GOwnPtr.h"
#include "PlatformString.h"
using namespace std;
@@ -49,4 +50,21 @@ SoupMessage* ResourceResponse::toSoupMessage() const
return soupMessage;
}
+void ResourceResponse::updateFromSoupMessage(SoupMessage* soupMessage)
+{
+ SoupURI* soupURI = soup_message_get_uri(soupMessage);
+ GOwnPtr<gchar> uri(soup_uri_to_string(soupURI, FALSE));
+ m_url = KURL(KURL(), String::fromUTF8(uri.get()));
+
+ m_httpStatusCode = soupMessage->status_code;
+
+ SoupMessageHeadersIter headersIter;
+ const char* headerName;
+ const char* headerValue;
+
+ soup_message_headers_iter_init(&headersIter, soupMessage->response_headers);
+ while (soup_message_headers_iter_next(&headersIter, &headerName, &headerValue))
+ m_httpHeaderFields.set(String::fromUTF8(headerName), String::fromUTF8(headerValue));
+}
+
}
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 5a142b5..b64949a 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,29 @@
+2009-12-07 Gustavo Noronha Silva <gustavo.noronha at collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Doesn't respect Content-Disposition for downloads, and provides no way for apps to do that
+ https://bugs.webkit.org/show_bug.cgi?id=32247
+
+ Provide a way for applications to respect Content-Disposition, by
+ fetching the WebKitNetworkResponse from the frame during
+ mime-type-policy-decision-requested.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): Download
+ content when Content-Disposition is attachment.
+ * tests/testmimehandling.c:
+ (server_callback):
+ (mime_type_policy_decision_requested_cb):
+ * tests/testwebframe.c:
+ (test_webkit_web_frame_response):
+ (main):
+ * webkit/webkitprivate.cpp:
+ (WebKit::core):
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_get_network_response):
+ * webkit/webkitwebframe.h:
+
2009-12-07 Gyuyoung Kim <gyuyoung at gmail.com>
Reviewed by Eric Seidel.
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index 1b6bfa7..fd135e4 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -305,10 +305,19 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli
if (isHandled)
return;
+ GOwnPtr<WebKitNetworkResponse> networkResponse(webkit_web_frame_get_network_response(m_frame));
+ if (networkResponse) {
+ ResourceResponse response = core(networkResponse.get());
+ if (response.isAttachment()) {
+ webkit_web_policy_decision_download(policyDecision);
+ return;
+ }
+ }
+
if (canShowMIMEType(mimeType))
- webkit_web_policy_decision_use (policyDecision);
+ webkit_web_policy_decision_use(policyDecision);
else
- webkit_web_policy_decision_ignore (policyDecision);
+ webkit_web_policy_decision_ignore(policyDecision);
}
static WebKitWebNavigationAction* getNavigationAction(const NavigationAction& action, const char* targetFrame)
diff --git a/WebKit/gtk/tests/testmimehandling.c b/WebKit/gtk/tests/testmimehandling.c
index 3613162..e68dcdf 100644
--- a/WebKit/gtk/tests/testmimehandling.c
+++ b/WebKit/gtk/tests/testmimehandling.c
@@ -67,6 +67,8 @@ server_callback(SoupServer *server, SoupMessage *msg,
gsize length;
GError* error = NULL;
+ soup_message_headers_append(msg->response_headers, "Content-Disposition", "attachment; filename=test.txt");
+
g_file_get_contents("test.txt", &contents, &length, &error);
g_assert(!error);
@@ -104,6 +106,18 @@ static gboolean mime_type_policy_decision_requested_cb(WebKitWebView* view, WebK
g_assert_cmpstr(mime_type, ==, "text/html");
g_assert(webkit_web_view_can_show_mime_type(view, mime_type));
} else if (g_str_equal(type, "text")) {
+ WebKitNetworkResponse* response = webkit_web_frame_get_network_response(frame);
+ SoupMessage* message = webkit_network_response_get_message(response);
+ char* disposition;
+
+ g_assert(message);
+ soup_message_headers_get_content_disposition(message->response_headers,
+ &disposition, NULL);
+ g_object_unref(response);
+
+ g_assert_cmpstr(disposition, ==, "attachment");
+ g_free(disposition);
+
g_assert_cmpstr(mime_type, ==, "text/plain");
g_assert(webkit_web_view_can_show_mime_type(view, mime_type));
} else if (g_str_equal(type, "ogg")) {
diff --git a/WebKit/gtk/tests/testwebframe.c b/WebKit/gtk/tests/testwebframe.c
index 068e2cf..620c9c9 100644
--- a/WebKit/gtk/tests/testwebframe.c
+++ b/WebKit/gtk/tests/testwebframe.c
@@ -155,6 +155,14 @@ cleanup:
g_free(temporaryFilename);
}
+static void test_webkit_web_frame_response()
+{
+ WebKitWebFrame* frame = g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL);
+ WebKitNetworkResponse* response = webkit_web_frame_get_network_response(frame);
+ g_assert(!response);
+ g_object_unref(frame);
+}
+
int main(int argc, char** argv)
{
g_thread_init(NULL);
@@ -164,6 +172,7 @@ int main(int argc, char** argv)
g_test_add_func("/webkit/webview/create_destroy", test_webkit_web_frame_create_destroy);
g_test_add_func("/webkit/webframe/lifetime", test_webkit_web_frame_lifetime);
g_test_add_func("/webkit/webview/printing", test_webkit_web_frame_printing);
+ g_test_add_func("/webkit/webview/response", test_webkit_web_frame_response);
return g_test_run ();
}
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index f3d263a..0870d90 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -37,8 +37,10 @@
#include "ResourceHandle.h"
#include "ResourceHandleClient.h"
#include "ResourceHandleInternal.h"
+#include "ResourceResponse.h"
#include <runtime/InitializeThreading.h>
#include "SecurityOrigin.h"
+#include "webkitnetworkresponse.h"
#if ENABLE(DATABASE)
#include "DatabaseTracker.h"
@@ -112,6 +114,15 @@ WebCore::ResourceRequest core(WebKitNetworkRequest* request)
return ResourceRequest(url);
}
+WebCore::ResourceResponse core(WebKitNetworkResponse* response)
+{
+ SoupMessage* soupMessage = webkit_network_response_get_message(response);
+ if (soupMessage)
+ return ResourceResponse(soupMessage);
+
+ return ResourceResponse();
+}
+
WebCore::EditingBehavior core(WebKitEditingBehavior type)
{
return (WebCore::EditingBehavior)type;
diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index 6ffd011..64fdc40 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -1141,3 +1141,29 @@ void webkit_web_frame_layout(WebKitWebFrame* frame)
view->layout();
}
+
+/**
+ * webkit_web_frame_get_network_response:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns a #WebKitNetworkResponse object representing the response
+ * that was given to the request for the given frame, or NULL if the
+ * frame was not created by a load. You must unref the object when you
+ * are done with it.
+ *
+ * Return value: a #WebKitNetworkResponse object
+ *
+ * Since: 1.1.18
+ */
+WebKitNetworkResponse* webkit_web_frame_get_network_response(WebKitWebFrame* frame)
+{
+ Frame* coreFrame = core(frame);
+ if (!coreFrame)
+ return NULL;
+
+ WebCore::DocumentLoader* loader = coreFrame->loader()->activeDocumentLoader();
+ if (!loader)
+ return NULL;
+
+ return webkit_network_response_new_with_core_response(loader->response());
+}
diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h
index 7a95545..28d7113 100644
--- a/WebKit/gtk/webkit/webkitwebframe.h
+++ b/WebKit/gtk/webkit/webkitwebframe.h
@@ -172,6 +172,9 @@ webkit_web_frame_get_provisional_data_source (WebKitWebFrame *frame);
WEBKIT_API WebKitSecurityOrigin*
webkit_web_frame_get_security_origin (WebKitWebFrame *frame);
+WEBKIT_API WebKitNetworkResponse*
+webkit_web_frame_get_network_response (WebKitWebFrame *frame);
+
G_END_DECLS
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list