From 17ecc4e7e0c88d891e1b18d5810a7ac2fd0b83ba Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 12 Mar 2017 22:59:59 +0100 Subject: Doc: QWebEngineUrlRequestJob: mention when to delete the device It's used from another thread, so it shouldn't be deleted immediately, and it's not deleted by the QtWebEngine code, so tell people to do it themselves at the right time. Change-Id: I54786be320f5fe82f144e7b1c2e6137260d9ceab Reviewed-by: Leena Miettinen Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebengineurlrequestjob.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core/api') diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp index 1db23f6ab..e95f58863 100644 --- a/src/core/api/qwebengineurlrequestjob.cpp +++ b/src/core/api/qwebengineurlrequestjob.cpp @@ -114,6 +114,13 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const /*! Replies to the request with \a device and the MIME type \a contentType. + + The device should remain available at least as long as the job exists. + When calling this method with a newly constructed device, one solution is to + make the device delete itself when closed, like this: + \code + connect(device, &QIODevice::aboutToClose, device, &QObject::deleteLater); + \endcode */ void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device) { -- cgit v1.2.3 From dfcd401333f96e8146ab81b919286f8bae187790 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 30 Nov 2017 17:59:57 +0100 Subject: Update setCookie documentation WebEngine prepends "." to domain if one is set explicitly to the cookie. Task-nmuber: QTBUG-64732 Change-Id: Ic54531281cf3a26f7a516118b8ecd78a2ac27e4a Reviewed-by: Leena Miettinen Reviewed-by: Kai Koehne --- src/core/api/qwebenginecookiestore.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core/api') diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 4617882ab..6b2d542ea 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -229,7 +229,10 @@ QWebEngineCookieStore::~QWebEngineCookieStore() /*! Adds \a cookie to the cookie store. - It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. + \note If \a cookie specifies a QNetworkCookie::domain() that does not start with a dot, + a dot is automatically prepended. To limit the cookie to the exact server, + omit QNetworkCookie::domain() and set \a origin instead. + The provided URL should also include the scheme. \note This operation is asynchronous. -- cgit v1.2.3 From a3fe8bc7859a84bbdd91f3ce73108878798b3986 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 9 Jan 2018 17:52:58 +0100 Subject: Protect QML profiles as well as core Moves QWebEngineBrowserContext to core and makes use of it from both widget and qml. Change-Id: I34748f302b0515b11b5831690d28478dfa6a852b Reviewed-by: Michal Klocek Reviewed-by: Alexandru Croitor --- src/core/api/core_api.pro | 2 + src/core/api/qwebenginebrowsercontext.cpp | 73 +++++++++++++++++++++++++++ src/core/api/qwebenginebrowsercontext_p.h | 83 +++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 src/core/api/qwebenginebrowsercontext.cpp create mode 100644 src/core/api/qwebenginebrowsercontext_p.h (limited to 'src/core/api') diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 270595378..93eebbc45 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -33,6 +33,7 @@ HEADERS = \ qwebenginecallback_p.h \ qtwebenginecoreglobal.h \ qtwebenginecoreglobal_p.h \ + qwebenginebrowsercontext_p.h \ qwebenginecookiestore.h \ qwebenginecookiestore_p.h \ qwebenginehttprequest.h \ @@ -44,6 +45,7 @@ HEADERS = \ SOURCES = \ qtwebenginecoreglobal.cpp \ + qwebenginebrowsercontext.cpp \ qwebenginecookiestore.cpp \ qwebenginehttprequest.cpp \ qwebengineurlrequestinfo.cpp \ diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp new file mode 100644 index 000000000..c3ab16460 --- /dev/null +++ b/src/core/api/qwebenginebrowsercontext.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 "qwebenginebrowsercontext_p.h" + +#include "browser_context_adapter.h" +#include + +QT_BEGIN_NAMESPACE + +QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer browserContext, + QtWebEngineCore::BrowserContextAdapterClient *profile) + : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot()) + , browserContextRef(browserContext) + , m_profile(profile) +{ + browserContextRef->addClient(m_profile); +} + +QWebEngineBrowserContext::~QWebEngineBrowserContext() +{ + if (m_profile) + shutdown(); +} + +void QWebEngineBrowserContext::shutdown() +{ + Q_ASSERT(m_profile); + // In the case the user sets this profile as the parent of the interceptor + // it can be deleted before the browser-context still referencing it is. + browserContextRef->setRequestInterceptor(nullptr); + browserContextRef->removeClient(m_profile); + m_profile = 0; + deleteLater(); +} + +QT_END_NAMESPACE diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h new file mode 100644 index 000000000..713ab730e --- /dev/null +++ b/src/core/api/qwebenginebrowsercontext_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 QWEBENGINEBROWSERCONTEXT_P_H +#define QWEBENGINEBROWSERCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include "qtwebenginecoreglobal_p.h" + +#include +#include + +namespace QtWebEngineCore { +class BrowserContextAdapter; +class BrowserContextAdapterClient; +} + +QT_BEGIN_NAMESPACE + +// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext +// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject. +// This guarantees the destruction together with the WebEngineContext. +class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject { +public: + QWebEngineBrowserContext(QSharedPointer browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile); + ~QWebEngineBrowserContext(); + + void shutdown(); + + QSharedPointer browserContextRef; + +private: + QtWebEngineCore::BrowserContextAdapterClient *m_profile; +}; + +QT_END_NAMESPACE + +#endif // QWEBENGINEBROWSERCONTEXT_P_H -- cgit v1.2.3