summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-24 10:40:09 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-24 10:40:09 +0100
commit9c5f59d82120a0f25ab6ab9763a4166175c4508d (patch)
tree9601733e73536315e4848bdfc639ddb67b410611
parentd502c6e9d09803dd268100f8c53cf7bc563e3d1d (diff)
parentf2d938962fe9a029ec0baf37ca7f478051125780 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/core/download_manager_delegate_qt.cpp Change-Id: Ica57e582a323c6bd014a64bb615dd9454e656548
-rw-r--r--src/core/download_manager_delegate_qt.cpp21
-rw-r--r--src/core/download_manager_delegate_qt.h4
-rw-r--r--src/core/gl_surface_qt.cpp2
-rw-r--r--src/core/web_contents_adapter.cpp2
-rw-r--r--tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp8
5 files changed, 22 insertions, 15 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 5eb97c5ea..40df9b3a8 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -65,7 +65,7 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *cont
: m_contextAdapter(contextAdapter)
, m_currentId(0)
, m_weakPtrFactory(this)
- , m_downloadType(BrowserContextAdapterClient::Attachment)
+ , m_nextDownloadIsUserRequested(false)
{
Q_ASSERT(m_contextAdapter);
}
@@ -123,10 +123,17 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
QString suggestedFilename = toQt(item->GetSuggestedFilename());
QString mimeTypeString = toQt(item->GetMimeType());
- bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment();
-
- if (!isAttachment || !BrowserContextAdapterClient::UserRequested)
- m_downloadType = BrowserContextAdapterClient::DownloadAttribute;
+ int downloadType = 0;
+ if (m_nextDownloadIsUserRequested) {
+ downloadType = BrowserContextAdapterClient::UserRequested;
+ m_nextDownloadIsUserRequested = false;
+ } else {
+ bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment();
+ if (isAttachment)
+ downloadType = BrowserContextAdapterClient::Attachment;
+ else
+ downloadType = BrowserContextAdapterClient::DownloadAttribute;
+ }
if (suggestedFilename.isEmpty())
suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename());
@@ -173,7 +180,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
false /* accepted */,
false /* paused */,
false /* done */,
- m_downloadType,
+ downloadType,
item->GetLastReason()
};
@@ -308,7 +315,7 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa
true /* accepted */,
download->IsPaused(),
download->IsDone(),
- m_downloadType,
+ 0 /* downloadType (unused) */,
download->GetLastReason()
};
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index aec83cb41..df43211ed 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -86,7 +86,7 @@ public:
void pauseDownload(quint32 downloadId);
void resumeDownload(quint32 downloadId);
- void setDownloadType(int downloadType) { m_downloadType = downloadType; }
+ void markNextDownloadAsUserRequested() { m_nextDownloadIsUserRequested = true; }
// Inherited from content::DownloadItem::Observer
void OnDownloadUpdated(content::DownloadItem *download) override;
@@ -99,7 +99,7 @@ private:
uint64_t m_currentId;
base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory;
- int m_downloadType;
+ bool m_nextDownloadIsUserRequested;
friend class DownloadManagerDelegateInstance;
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt);
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index f731b0231..344a4459f 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -267,7 +267,7 @@ bool GLSurfaceQtGLX::Initialize(GLSurfaceFormat format)
GLX_PBUFFER_HEIGHT, m_size.height(),
GLX_LARGEST_PBUFFER, False,
GLX_PRESERVED_CONTENTS, False,
- GLX_NONE
+ 0
};
m_surfaceBuffer = glXCreatePbuffer(display, static_cast<GLXFBConfig>(g_config), pbuffer_attributes);
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 5850b07b5..e6a97b8bc 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -974,7 +974,7 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
if (!dlm)
return;
- dlmd->setDownloadType(BrowserContextAdapterClient::UserRequested);
+ dlmd->markNextDownloadAsUserRequested();
dlm->SetDelegate(dlmd);
net::NetworkTrafficAnnotationTag traffic_annotation =
diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
index 83e8d1101..606fe5b12 100644
--- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
+++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
@@ -99,7 +99,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
/* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* downloadType */ << QWebEngineDownloadItem::UserRequested;
// SaveLink should always trigger a download, also for text files.
QTest::newRow("save link to text file")
@@ -112,7 +112,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
/* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* downloadType */ << QWebEngineDownloadItem::UserRequested;
// ... adding the "download" attribute should have no effect.
QTest::newRow("save link to text file (attribute)")
@@ -125,7 +125,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
/* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* downloadType */ << QWebEngineDownloadItem::UserRequested;
// ... adding the "attachment" content disposition should also have no effect.
QTest::newRow("save link to text file (attachment)")
@@ -517,7 +517,7 @@ void tst_QWebEngineDownloads::downloadTwoLinks()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute);
+ QCOMPARE(item->type(), QWebEngineDownloadItem::Attachment);
QCOMPARE(item->mimeType(), QStringLiteral("text/plain"));
QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file2"));
QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);