diff options
author | Michael BrĂ¼ning <michael.bruning@digia.com> | 2013-08-07 12:28:50 +0200 |
---|---|---|
committer | Michael Bruning <michael.bruning@digia.com> | 2013-08-08 09:54:48 +0200 |
commit | c931e3a0098c2e428558254f04b743c57f25eca8 (patch) | |
tree | 39415484af5e6248da1fe4278f6a1dedc86170b4 | |
parent | cc5368917662e90156eaeafc5ac7e2803d941160 (diff) |
Add a dummy implementation of DownloadManagerDelegate.
Prevents the the web engine from crashing by providing an
implementation and generating download Ids for downloads.
Change-Id: Iac1e98b74ec1fdc9d913951fbfed4b7ba394170f
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r-- | lib/browser_context_qt.h | 6 | ||||
-rw-r--r-- | lib/download_manager_delegate_qt.cpp | 130 | ||||
-rw-r--r-- | lib/download_manager_delegate_qt.h | 101 | ||||
-rw-r--r-- | lib/lib.pro | 2 |
4 files changed, 237 insertions, 2 deletions
diff --git a/lib/browser_context_qt.h b/lib/browser_context_qt.h index e79632ef3..065fb203f 100644 --- a/lib/browser_context_qt.h +++ b/lib/browser_context_qt.h @@ -63,6 +63,7 @@ #include <QString> #include <QStringBuilder> +#include "download_manager_delegate_qt.h" #include "resource_context_qt.h" #include "url_request_context_getter_qt.h" @@ -72,6 +73,7 @@ public: explicit BrowserContextQt() { resourceContext.reset(new ResourceContextQt(this)); + downloadManagerDelegate.reset(new DownloadManagerDelegateQt); } virtual ~BrowserContextQt() Q_DECL_OVERRIDE {} @@ -113,8 +115,7 @@ public: virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() Q_DECL_OVERRIDE { - QT_NOT_YET_IMPLEMENTED - return 0; + return downloadManagerDelegate.get(); } virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() Q_DECL_OVERRIDE { @@ -137,6 +138,7 @@ public: private: scoped_ptr<content::ResourceContext> resourceContext; scoped_refptr<net::URLRequestContextGetter> url_request_getter_; + scoped_ptr<DownloadManagerDelegateQt> downloadManagerDelegate; DISALLOW_COPY_AND_ASSIGN(BrowserContextQt); }; diff --git a/lib/download_manager_delegate_qt.cpp b/lib/download_manager_delegate_qt.cpp new file mode 100644 index 000000000..4cece01a3 --- /dev/null +++ b/lib/download_manager_delegate_qt.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "download_manager_delegate_qt.h" + +#include "content/public/browser/download_item.h" +#include "content/public/browser/save_page_type.h" +#include "content/public/browser/web_contents.h" +#include "shared/shared_globals.h" + +DownloadManagerDelegateQt::DownloadManagerDelegateQt() : m_currentId(0) +{ +} + +void DownloadManagerDelegateQt::Shutdown() +{ + QT_NOT_YET_IMPLEMENTED +} + +void DownloadManagerDelegateQt::GetNextId(const content::DownloadIdCallback& callback) +{ + callback.Run(++m_currentId); +} + +bool DownloadManagerDelegateQt::ShouldOpenFileBasedOnExtension(const base::FilePath& path) +{ + QT_NOT_YET_IMPLEMENTED + return false; +} + +bool DownloadManagerDelegateQt::ShouldCompleteDownload(content::DownloadItem* item, + const base::Closure& complete_callback) +{ + QT_NOT_YET_IMPLEMENTED + return true; +} + +bool DownloadManagerDelegateQt::ShouldOpenDownload(content::DownloadItem* item, + const content::DownloadOpenDelayedCallback& callback) +{ + QT_NOT_YET_IMPLEMENTED + return false; +} + +bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* item, + const content::DownloadTargetCallback& callback) +{ + QT_NOT_YET_IMPLEMENTED + return true; +} + +bool DownloadManagerDelegateQt::GenerateFileHash() +{ + QT_NOT_YET_IMPLEMENTED + return false; +} + +void DownloadManagerDelegateQt::ChooseSavePath( + content::WebContents* web_contents, + const base::FilePath& suggested_path, + const base::FilePath::StringType& default_extension, + bool can_save_as_complete, + const content::SavePackagePathPickedCallback& callback) +{ + QT_NOT_YET_IMPLEMENTED +} + +void DownloadManagerDelegateQt::OpenDownload(content::DownloadItem* download) +{ + QT_NOT_YET_IMPLEMENTED +} + +void DownloadManagerDelegateQt::ShowDownloadInShell(content::DownloadItem* download) +{ + QT_NOT_YET_IMPLEMENTED +} + +void DownloadManagerDelegateQt::CheckForFileExistence( + content::DownloadItem* download, + const content::CheckForFileExistenceCallback& callback) +{ + QT_NOT_YET_IMPLEMENTED +} + +void DownloadManagerDelegateQt::GetSaveDir(content::BrowserContext* browser_context, + base::FilePath* website_save_dir, + base::FilePath* download_save_dir, + bool* skip_dir_check) +{ + QT_NOT_YET_IMPLEMENTED +} + diff --git a/lib/download_manager_delegate_qt.h b/lib/download_manager_delegate_qt.h new file mode 100644 index 000000000..db2ba1fd2 --- /dev/null +++ b/lib/download_manager_delegate_qt.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DOWNLOAD_MANAGER_DELEGATE_QT_H +#define DOWNLOAD_MANAGER_DELEGATE_QT_H + +#include "content/public/browser/download_manager_delegate.h" + +#include <qglobal.h> + +namespace base { +class FilePath; +} + +namespace content { +class BrowserContext; +class DownloadItem; +class WebContents; +} + + +class DownloadManagerDelegateQt : public content::DownloadManagerDelegate +{ +public: + DownloadManagerDelegateQt(); + virtual ~DownloadManagerDelegateQt() { } + + void Shutdown() Q_DECL_OVERRIDE; + void GetNextId(const content::DownloadIdCallback& callback) Q_DECL_OVERRIDE; + bool ShouldOpenFileBasedOnExtension(const base::FilePath& path) Q_DECL_OVERRIDE; + bool ShouldCompleteDownload(content::DownloadItem* item, + const base::Closure& complete_callback) Q_DECL_OVERRIDE; + + bool ShouldOpenDownload(content::DownloadItem* item, + const content::DownloadOpenDelayedCallback& callback) Q_DECL_OVERRIDE; + + bool DetermineDownloadTarget(content::DownloadItem* item, + const content::DownloadTargetCallback& callback) Q_DECL_OVERRIDE; + + bool GenerateFileHash() Q_DECL_OVERRIDE; + void ChooseSavePath(content::WebContents* web_contents, + const base::FilePath& suggested_path, + const base::FilePath::StringType& default_extension, + bool can_save_as_complete, + const content::SavePackagePathPickedCallback& callback) Q_DECL_OVERRIDE; + + void OpenDownload(content::DownloadItem* download) Q_DECL_OVERRIDE; + void ShowDownloadInShell(content::DownloadItem* download) Q_DECL_OVERRIDE; + void CheckForFileExistence(content::DownloadItem* download, + const content::CheckForFileExistenceCallback& callback) Q_DECL_OVERRIDE; + + void GetSaveDir(content::BrowserContext* browser_context, + base::FilePath* website_save_dir, + base::FilePath* download_save_dir, + bool* skip_dir_check) Q_DECL_OVERRIDE; + +private: + uint64 m_currentId; + + DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt); +}; + +#endif //DOWNLOAD_MANAGER_DELEGATE_QT_H diff --git a/lib/lib.pro b/lib/lib.pro index 3627c984f..701e7d359 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -25,6 +25,7 @@ INCLUDEPATH += $$absolute_path(../resources, $$PWD) SOURCES = \ backing_store_qt.cpp \ content_browser_client_qt.cpp \ + download_manager_delegate_qt.cpp \ render_widget_host_view_qt.cpp \ render_widget_host_view_qt_delegate.cpp \ resource_context_qt.cpp \ @@ -39,6 +40,7 @@ HEADERS = \ backing_store_qt.h \ browser_context_qt.h \ content_browser_client_qt.h \ + download_manager_delegate_qt.h \ render_widget_host_view_qt.h \ render_widget_host_view_qt_delegate.h \ resource_context_qt.h \ |