From 6f92911e10fe4417c83af4ee356fd89549db29c6 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Date: Fri, 18 Sep 2015 17:43:43 +0200
Subject: [PATCH] Parse suggested filename from content-disposition

Chromium hasn't parsed content-disposition by the time we get the
download item, so we need to call the parsing manually.

Change-Id: I105d0c6904dd764b368cb774e377a6028c082513
Task-number: QTBUG-48206
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
---
 src/core/download_manager_delegate_qt.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index c01dcf63d..e9af98fd8 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -40,6 +40,7 @@
 #include "content/public/browser/download_item.h"
 #include "content/public/browser/save_page_type.h"
 #include "content/public/browser/web_contents.h"
+#include "net/http/http_content_disposition.h"
 
 #include <QDir>
 #include <QFile>
@@ -103,6 +104,9 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
 
     std::string suggestedFilename = item->GetSuggestedFilename();
 
+    if (suggestedFilename.empty())
+        suggestedFilename = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename();
+
     if (suggestedFilename.empty())
         suggestedFilename = item->GetTargetFilePath().AsUTF8Unsafe();
 
-- 
GitLab