aboutsummaryrefslogtreecommitdiffstats
path: root/src/window-commands.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-08-02 18:36:51 +0800
committerXan Lopez <xan@igalia.com>2012-08-02 18:44:39 +0800
commit18720165e359b9d127fd378214910b544121be7d (patch)
treec67df189ccf865d8cb0b07d05004424afed802ad /src/window-commands.c
parent85ae7a5cbb8e0ea22e149041b278bf8d031dabe9 (diff)
downloadgsoc2013-epiphany-18720165e359b9d127fd378214910b544121be7d.tar.gz
gsoc2013-epiphany-18720165e359b9d127fd378214910b544121be7d.tar.zst
gsoc2013-epiphany-18720165e359b9d127fd378214910b544121be7d.zip
window-commands: fallback correctly when Content-Disposition is not available
The suggested filename the network response gives us can be NULL. Fallback to the old method in that case.
Diffstat (limited to 'src/window-commands.c')
-rw-r--r--src/window-commands.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index 5a4d2117e..1c02a56d8 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -279,7 +279,7 @@ window_cmd_file_open (GtkAction *action,
static char *
get_suggested_filename (EphyWebView *view)
{
- char *suggested_filename;
+ char *suggested_filename = NULL;
const char *mimetype;
#ifdef HAVE_WEBKIT2
WebKitURIResponse *response;
@@ -307,8 +307,21 @@ get_suggested_filename (EphyWebView *view)
}
else
{
- WebKitNetworkResponse *response = webkit_web_frame_get_network_response (frame);
+ WebKitNetworkResponse *response;
+
+#ifdef HAVE_WEBKIT2
+ /* TODO: suggested filename */
+#else
+ response = webkit_web_frame_get_network_response (frame);
suggested_filename = g_strdup (webkit_network_response_get_suggested_filename (response));
+#endif
+
+ if (!suggested_filename)
+ {
+ SoupURI *soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
+ suggested_filename = g_path_get_basename (soup_uri->path);
+ soup_uri_free (soup_uri);
+ }
}
return suggested_filename;