diff options
author | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-11 19:57:58 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-01-12 16:34:58 +0100 |
commit | e6a74159cebdbfec575f40469c216c90ee8651c1 (patch) | |
tree | 331f7a51b9d0c77568bb2744fbd8155733424374 /src/core/browser_context_adapter.cpp | |
parent | 4557ccd9785f53abc11460211c84db3e564b364f (diff) |
Add QML download API
This patch exposes downloadStarted and downloadFinished
signals on the WebEngineProfile to notify about downloads.
The WebEngineDownloadItem exposes a subset of Chromium's
content::DownloadItem functionality.
For now we expose minimal requirements to be able to control
downloads in QML but this can be extended in the future.
This patch also adds a DownloadView to quicktestbrowser
to demonstrate the usage of the new API.
[ChangeLog][QtWebEngineQML] Add QtQuick download API
Change-Id: I8d8f0daf02c4e0151000427fc2a4b37d28b9db52
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/core/browser_context_adapter.cpp')
-rw-r--r-- | src/core/browser_context_adapter.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 637003f96..95ddc4d87 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -36,8 +36,10 @@ #include "browser_context_adapter.h" +#include "content/public/browser/browser_thread.h" #include "browser_context_qt.h" #include "content_client_qt.h" +#include "download_manager_delegate_qt.h" #include "web_engine_context.h" #include "web_engine_visited_links_manager.h" #include "url_request_context_getter_qt.h" @@ -67,6 +69,7 @@ BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord) , m_httpCacheType(DiskHttpCache) , m_persistentCookiesPolicy(AllowPersistentCookies) , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) + , m_client(0) , m_httpCacheMaxSize(0) { } @@ -84,6 +87,8 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName) BrowserContextAdapter::~BrowserContextAdapter() { + if (m_downloadManagerDelegate) + content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, m_downloadManagerDelegate.take()); } void BrowserContextAdapter::setStorageName(const QString &storageName) @@ -118,6 +123,23 @@ WebEngineVisitedLinksManager *BrowserContextAdapter::visitedLinksManager() return m_visitedLinksManager.data(); } +DownloadManagerDelegateQt *BrowserContextAdapter::downloadManagerDelegate() +{ + if (!m_downloadManagerDelegate) + m_downloadManagerDelegate.reset(new DownloadManagerDelegateQt(this)); + return m_downloadManagerDelegate.data(); +} + +void BrowserContextAdapter::setClient(BrowserContextAdapterClient *adapterClient) +{ + m_client = adapterClient; +} + +void BrowserContextAdapter::cancelDownload(quint32 downloadId) +{ + downloadManagerDelegate()->cancelDownload(downloadId); +} + BrowserContextAdapter* BrowserContextAdapter::defaultContext() { return WebEngineContext::current()->defaultBrowserContext(); |