diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | embed/ephy-web-view.c | 30 |
2 files changed, 30 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 869def41b..20a3f78b4 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,7 @@ LIBXSLT_REQUIRED=1.1.7 LIBSTARTUP_NOTIFICATION_REQUIRED=0.5 LIBNOTIFY_REQUIRED=0.4 DBUS_GLIB_REQUIRED=0.35 -WEBKIT_GTK_REQUIRED=1.1.17 +WEBKIT_GTK_REQUIRED=1.1.18 LIBSOUP_GNOME_REQUIRED=2.27.91 GNOME_KEYRING_REQUIRED=2.26.0 diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index c525ab1c2..09172b423 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -969,6 +969,7 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, gpointer user_data) { EphyWebViewDocumentType type; + gboolean should_download; g_return_val_if_fail (mime_type, FALSE); @@ -996,8 +997,35 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, /* If WebKit can't handle the mime type start the download process */ + should_download = !webkit_web_view_can_show_mime_type (web_view, mime_type); + + /* Make sure we respect the Content-Disposition header */ + if (!should_download) { + WebKitNetworkResponse *response = webkit_web_frame_get_network_response (frame); + SoupMessage *message = NULL; + + if (response) { + message = webkit_network_response_get_message (response); + } + + if (message) { + char *disposition = NULL; + + soup_message_headers_get_content_disposition (message->response_headers, + &disposition, + NULL); + + if (disposition) { + should_download = g_str_equal (disposition, "attachment"); + g_free (disposition); + } + } + + g_object_unref (response); + } + /* FIXME: need to use ephy_file_check_mime if auto-downloading */ - if (!webkit_web_view_can_show_mime_type (web_view, mime_type)) { + if (should_download) { GObject *single; const char *uri; gboolean handled = FALSE; |