From 6a6fd71af52bcbffc4fccf58e1f35b7612d16a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 15 Jan 2018 17:30:50 +0100 Subject: QuotaPermissionController: Use implementation subclass Try to separate quota-unrelated bookkeeping from quota-specific glue code. Task-number: QTBUG-62783 Change-Id: I0c7c3fd554a4b3a195a99ff4034f158f2547eecb Reviewed-by: Allan Sandfeld Jensen --- src/core/core_chromium.pri | 4 +- src/core/quota_permission_context_qt.cpp | 7 +- src/core/quota_permission_controller.cpp | 98 --------------------------- src/core/quota_permission_controller.h | 39 ++++++++--- src/core/quota_permission_controller_impl.cpp | 67 ++++++++++++++++++ src/core/quota_permission_controller_impl.h | 66 ++++++++++++++++++ src/core/quota_permission_controller_p.h | 66 ------------------ 7 files changed, 166 insertions(+), 181 deletions(-) delete mode 100644 src/core/quota_permission_controller.cpp create mode 100644 src/core/quota_permission_controller_impl.cpp create mode 100644 src/core/quota_permission_controller_impl.h delete mode 100644 src/core/quota_permission_controller_p.h (limited to 'src/core') diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 08552800d..c81b661a6 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -78,7 +78,7 @@ SOURCES = \ proxy_config_service_qt.cpp \ qrc_protocol_handler_qt.cpp \ quota_permission_context_qt.cpp \ - quota_permission_controller.cpp \ + quota_permission_controller_impl.cpp \ render_view_context_menu_qt.cpp \ render_view_observer_host_qt.cpp \ render_widget_host_view_qt.cpp \ @@ -161,7 +161,7 @@ HEADERS = \ qrc_protocol_handler_qt.h \ quota_permission_context_qt.h \ quota_permission_controller.h \ - quota_permission_controller_p.h \ + quota_permission_controller_impl.h \ render_view_context_menu_qt.h \ render_view_observer_host_qt.h \ render_widget_host_view_qt.h \ diff --git a/src/core/quota_permission_context_qt.cpp b/src/core/quota_permission_context_qt.cpp index 10249bbf0..bb59512c0 100644 --- a/src/core/quota_permission_context_qt.cpp +++ b/src/core/quota_permission_context_qt.cpp @@ -42,8 +42,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" -#include "quota_permission_controller.h" -#include "quota_permission_controller_p.h" +#include "quota_permission_controller_impl.h" #include "web_contents_delegate_qt.h" #include "web_contents_view_qt.h" @@ -83,8 +82,8 @@ void QuotaPermissionContextQt::RequestQuotaPermission(const StorageQuotaParams & if (!client) return; - QSharedPointer controller(new QuotaPermissionController(new QuotaPermissionControllerPrivate(this, params, callback))); - client->runQuotaPermissionRequest(controller); + QSharedPointer request(new QuotaPermissionControllerImpl(this, params, callback)); + client->runQuotaPermissionRequest(request); } void QuotaPermissionContextQt::dispatchCallbackOnIOThread(const PermissionCallback &callback, diff --git a/src/core/quota_permission_controller.cpp b/src/core/quota_permission_controller.cpp deleted file mode 100644 index b874c0449..000000000 --- a/src/core/quota_permission_controller.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "quota_permission_controller.h" -#include "quota_permission_controller_p.h" - -#include "quota_permission_context_qt.h" -#include "type_conversion.h" - -namespace QtWebEngineCore { - -QuotaPermissionControllerPrivate::QuotaPermissionControllerPrivate(QuotaPermissionContextQt *context, - const content::StorageQuotaParams ¶ms, - const content::QuotaPermissionContext::PermissionCallback &callback) - : m_context(context), - m_originUrl(toQt(params.origin_url)), - m_requestedSize(params.requested_size), - m_callback(callback) -{ -} - -QuotaPermissionControllerPrivate::~QuotaPermissionControllerPrivate() -{ -} - -QuotaPermissionController::QuotaPermissionController(QuotaPermissionControllerPrivate *controllerPrivate) - : d(controllerPrivate) - , m_answered(false) -{ -} - -QuotaPermissionController::~QuotaPermissionController() -{ -} - -void QuotaPermissionController::accept() -{ - if (!m_answered) { - d->m_context->dispatchCallbackOnIOThread(d->m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_ALLOW); - m_answered = true; - } -} - -void QuotaPermissionController::reject() -{ - if (!m_answered) { - d->m_context->dispatchCallbackOnIOThread(d->m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_DISALLOW); - m_answered = true; - } -} - -QUrl QuotaPermissionController::origin() -{ - return d->m_originUrl; -} - -qint64 QuotaPermissionController::requestedSize() -{ - return d->m_requestedSize; -} - -} // namespace QtWebEngineCore diff --git a/src/core/quota_permission_controller.h b/src/core/quota_permission_controller.h index e584d7b52..cdd5e226a 100644 --- a/src/core/quota_permission_controller.h +++ b/src/core/quota_permission_controller.h @@ -41,28 +41,45 @@ #define QUOTA_PERMISSION_CONTROLLER_H #include "qtwebenginecoreglobal.h" -#include #include namespace QtWebEngineCore { -class QuotaPermissionContextQt; -class QuotaPermissionControllerPrivate; - class QWEBENGINE_EXPORT QuotaPermissionController { public: - QuotaPermissionController(QuotaPermissionControllerPrivate *controllerPrivate); - ~QuotaPermissionController(); + QuotaPermissionController(QUrl origin, qint64 requestedSize) + : m_answered(false) + , m_origin(std::move(origin)) + , m_requestedSize(requestedSize) + {} + + QUrl origin() const { return m_origin; } + qint64 requestedSize() const { return m_requestedSize; } + + void accept() { + if (!m_answered) { + m_answered = true; + accepted(); + } + } + + void reject() { + if (!m_answered) { + m_answered = true; + rejected(); + } + } - void accept(); - void reject(); + virtual ~QuotaPermissionController() {} - QUrl origin(); - qint64 requestedSize(); +protected: + virtual void accepted() = 0; + virtual void rejected() = 0; private: - QScopedPointer d; bool m_answered; + QUrl m_origin; + qint64 m_requestedSize; }; } // namespace QtWebEngineCore diff --git a/src/core/quota_permission_controller_impl.cpp b/src/core/quota_permission_controller_impl.cpp new file mode 100644 index 000000000..ebad4b2fb --- /dev/null +++ b/src/core/quota_permission_controller_impl.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quota_permission_controller_impl.h" + +#include "type_conversion.h" + +namespace QtWebEngineCore { + +QuotaPermissionControllerImpl::QuotaPermissionControllerImpl( + QuotaPermissionContextQt *context, + const content::StorageQuotaParams ¶ms, + const content::QuotaPermissionContext::PermissionCallback &callback) + : QuotaPermissionController( + toQt(params.origin_url), + params.requested_size) + , m_context(context) + , m_callback(callback) +{} + +void QuotaPermissionControllerImpl::accepted() +{ + m_context->dispatchCallbackOnIOThread(m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_ALLOW); +} + +void QuotaPermissionControllerImpl::rejected() +{ + m_context->dispatchCallbackOnIOThread(m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_DISALLOW); +} + +} // namespace QtWebEngineCore diff --git a/src/core/quota_permission_controller_impl.h b/src/core/quota_permission_controller_impl.h new file mode 100644 index 000000000..297c6711b --- /dev/null +++ b/src/core/quota_permission_controller_impl.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUOTA_PERMISSION_CONTROLLER_IMPL_H +#define QUOTA_PERMISSION_CONTROLLER_IMPL_H + +#include "quota_permission_controller.h" +#include "quota_permission_context_qt.h" + +namespace QtWebEngineCore { + +class QuotaPermissionControllerImpl final : public QuotaPermissionController { +public: + QuotaPermissionControllerImpl( + QuotaPermissionContextQt *context, + const content::StorageQuotaParams ¶ms, + const content::QuotaPermissionContext::PermissionCallback &callback); + +protected: + void accepted() override; + void rejected() override; + +private: + scoped_refptr m_context; + content::QuotaPermissionContext::PermissionCallback m_callback; +}; + +} // namespace QtWebEngineCore + +#endif // QUOTA_PERMISSION_CONTROLLER_IMPL_H diff --git a/src/core/quota_permission_controller_p.h b/src/core/quota_permission_controller_p.h deleted file mode 100644 index c00ae42c9..000000000 --- a/src/core/quota_permission_controller_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QUOTA_PERMISSION_CONTROLLER_P_H -#define QUOTA_PERMISSION_CONTROLLER_P_H - -#include "quota_permission_context_qt.h" -#include - -namespace QtWebEngineCore { - -class QuotaPermissionControllerPrivate { -public: - QuotaPermissionControllerPrivate(QuotaPermissionContextQt *context, - const content::StorageQuotaParams ¶ms, - const content::QuotaPermissionContext::PermissionCallback &callback); - ~QuotaPermissionControllerPrivate(); - -private: - scoped_refptr m_context; - QUrl m_originUrl; - qint64 m_requestedSize; - content::QuotaPermissionContext::PermissionCallback m_callback; - - friend class QuotaPermissionController; -}; - -} // namespace QtWebEngineCore - -#endif // QUOTA_PERMISSION_CONTROLLER_P_H -- cgit v1.2.3