From 0f64c6ae03a583e1fb060d87fc9b9dedf3b14dd6 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 26 Nov 2015 17:19:31 +0100 Subject: Rename QWebEngineCookieStoreClient to QWebEngineCookieStore Change-Id: I8f9a4c5c155a65ede24908799218fd867db0767c Reviewed-by: Joerg Bornemann --- src/core/api/core_api.pro | 6 +- src/core/api/qwebenginecookiestore.cpp | 403 +++++++++++++++++++++++++++ src/core/api/qwebenginecookiestore.h | 104 +++++++ src/core/api/qwebenginecookiestore_p.h | 108 +++++++ src/core/api/qwebenginecookiestoreclient.cpp | 403 --------------------------- src/core/api/qwebenginecookiestoreclient.h | 104 ------- src/core/api/qwebenginecookiestoreclient_p.h | 108 ------- src/core/browser_context_adapter.cpp | 8 +- src/core/browser_context_adapter.h | 6 +- src/core/cookie_monster_delegate_qt.cpp | 12 +- src/core/cookie_monster_delegate_qt.h | 6 +- src/core/url_request_context_getter_qt.cpp | 6 +- 12 files changed, 637 insertions(+), 637 deletions(-) create mode 100644 src/core/api/qwebenginecookiestore.cpp create mode 100644 src/core/api/qwebenginecookiestore.h create mode 100644 src/core/api/qwebenginecookiestore_p.h delete mode 100644 src/core/api/qwebenginecookiestoreclient.cpp delete mode 100644 src/core/api/qwebenginecookiestoreclient.h delete mode 100644 src/core/api/qwebenginecookiestoreclient_p.h (limited to 'src/core') diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index e4cdf43cb..e62578db2 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -33,8 +33,8 @@ HEADERS = \ qwebenginecallback_p.h \ qtwebenginecoreglobal.h \ qtwebenginecoreglobal_p.h \ - qwebenginecookiestoreclient.h \ - qwebenginecookiestoreclient_p.h \ + qwebenginecookiestore.h \ + qwebenginecookiestore_p.h \ qwebengineurlrequestinterceptor.h \ qwebengineurlrequestinfo.h \ qwebengineurlrequestinfo_p.h \ @@ -42,7 +42,7 @@ HEADERS = \ qwebengineurlschemehandler.h SOURCES = \ - qwebenginecookiestoreclient.cpp \ + qwebenginecookiestore.cpp \ qwebengineurlrequestinfo.cpp \ qwebengineurlrequestjob.cpp \ qwebengineurlschemehandler.cpp diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp new file mode 100644 index 000000000..61d210192 --- /dev/null +++ b/src/core/api/qwebenginecookiestore.cpp @@ -0,0 +1,403 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginecookiestore.h" +#include "qwebenginecookiestore_p.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace QtWebEngineCore; + +QWebEngineCookieStorePrivate::QWebEngineCookieStorePrivate(QWebEngineCookieStore* q) + : m_nextCallbackId(CallbackDirectory::ReservedCallbackIdsEnd) + , m_deleteSessionCookiesPending(false) + , m_deleteAllCookiesPending(false) + , m_getAllCookiesPending(false) + , delegate(0) + , q_ptr(q) +{ +} + +QWebEngineCookieStorePrivate::~QWebEngineCookieStorePrivate() +{ + +} + +void QWebEngineCookieStorePrivate::processPendingUserCookies() +{ + Q_ASSERT(delegate); + Q_ASSERT(delegate->hasCookieMonster()); + + if (m_getAllCookiesPending) { + m_getAllCookiesPending = false; + delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId); + } + + if (m_deleteAllCookiesPending) { + m_deleteAllCookiesPending = false; + delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId); + } + + if (m_deleteSessionCookiesPending) { + m_deleteSessionCookiesPending = false; + delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId); + } + + if (m_pendingUserCookies.isEmpty()) + return; + + Q_FOREACH (const auto &cookieData, m_pendingUserCookies) { + if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId) + delegate->deleteCookie(cookieData.cookie, cookieData.origin); + else + delegate->setCookie(cookieData.callbackId, cookieData.cookie, cookieData.origin); + } + + m_pendingUserCookies.clear(); +} + +void QWebEngineCookieStorePrivate::setCookie(const QWebEngineCallback &callback, const QNetworkCookie &cookie, const QUrl &origin) +{ + const quint64 currentCallbackId = callback ? m_nextCallbackId++ : static_cast(CallbackDirectory::NoCallbackId); + + if (currentCallbackId != CallbackDirectory::NoCallbackId) + callbackDirectory.registerCallback(currentCallbackId, callback); + + if (!delegate || !delegate->hasCookieMonster()) { + m_pendingUserCookies.append(CookieData{ currentCallbackId, cookie, origin }); + return; + } + + delegate->setCookie(currentCallbackId, cookie, origin); +} + +void QWebEngineCookieStorePrivate::deleteCookie(const QNetworkCookie &cookie, const QUrl &url) +{ + if (!delegate || !delegate->hasCookieMonster()) { + m_pendingUserCookies.append(CookieData{ CallbackDirectory::DeleteCookieCallbackId, cookie, url }); + return; + } + + delegate->deleteCookie(cookie, url); +} + +void QWebEngineCookieStorePrivate::deleteSessionCookies() +{ + if (!delegate || !delegate->hasCookieMonster()) { + m_deleteSessionCookiesPending = true; + return; + } + + delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId); +} + +void QWebEngineCookieStorePrivate::deleteAllCookies() +{ + if (!delegate || !delegate->hasCookieMonster()) { + m_deleteAllCookiesPending = true; + m_deleteSessionCookiesPending = false; + return; + } + + delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId); +} + +void QWebEngineCookieStorePrivate::getAllCookies() +{ + if (!delegate || !delegate->hasCookieMonster()) { + m_getAllCookiesPending = true; + return; + } + + delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId); +} + +void QWebEngineCookieStorePrivate::onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList) +{ + callbackDirectory.invoke(callbackId, cookieList); +} +void QWebEngineCookieStorePrivate::onSetCallbackResult(qint64 callbackId, bool success) +{ + callbackDirectory.invoke(callbackId, success); +} + +void QWebEngineCookieStorePrivate::onDeleteCallbackResult(qint64 callbackId, int numCookies) +{ + callbackDirectory.invoke(callbackId, numCookies); +} + +void QWebEngineCookieStorePrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed) +{ + Q_Q(QWebEngineCookieStore); + if (removed) + Q_EMIT q->cookieRemoved(cookie); + else + Q_EMIT q->cookieAdded(cookie); +} + +bool QWebEngineCookieStorePrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) +{ + if (filterCallback) { + QWebEngineCookieStore::FilterRequest request; + request.accepted = true; + request.firstPartyUrl = firstPartyUrl; + request.cookieLine = cookieLine; + request.cookieSource = url; + callbackDirectory.invokeDirectly(filterCallback, request); + return request.accepted; + } + return true; +} + +/*! + \class QWebEngineCookieStore + \inmodule QtWebEngineCore + \since 5.6 + \brief The QWebEngineCookieStore class provides access to Chromium's cookies. + + The class allows to access HTTP cookies of Chromium for a specific profile. + It can be used to synchronize cookies of Chromium and the QNetworkAccessManager, as well as + to set, delete, and intercept cookies during navigation. + Because cookie operations are asynchronous, the user can choose to provide a callback function + to get notified about the success of the operation. + The signal handlers for removal and addition should not be used to execute heavy tasks, + because they might block the IO thread in case of a blocking connection. +*/ + +/*! + \class QWebEngineCookieStore::FilterRequest + \inmodule QtWebEngineCore + \since 5.6 + + The structure specifies properties of a cookie, and whether it should accepted or not. It is + used as an argument to a filter installed via setCookieFilter(). +*/ + +/*! + \variable QWebEngineCookieStore::FilterRequest::accepted + Whether the cookie shall be accepted. The default is \c true. + \variable QWebEngineCookieStore::FilterRequest::firstPartyUrl + URL of page that triggered the setting of the cookie. + \variable QWebEngineCookieStore::FilterRequest::cookieLine + Content of the cookie. + \variable QWebEngineCookieStore::FilterRequest::cookieSource + URL of site that sets the cookie. +*/ + + +/*! + \fn void QWebEngineCookieStore::cookieAdded(const QNetworkCookie &cookie) + + This signal is emitted whenever a new \a cookie is added to the cookie store. +*/ + +/*! + \fn void QWebEngineCookieStore::cookieRemoved(const QNetworkCookie &cookie) + + This signal is emitted whenever a \a cookie is deleted from the cookie store. +*/ + +/*! + Creates a new QWebEngineCookieStore object with \a parent. +*/ + +QWebEngineCookieStore::QWebEngineCookieStore(QObject *parent) + : QObject(parent) + , d_ptr(new QWebEngineCookieStorePrivate(this)) +{ + +} + +/*! + Destroys this QWebEngineCookieStore object. +*/ + +QWebEngineCookieStore::~QWebEngineCookieStore() +{ + +} + +/*! + \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()) + + Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed + on the caller thread. + It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. + The provided URL should also include the scheme. + + \sa setCookie() +*/ + +void QWebEngineCookieStore::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin) +{ + Q_D(QWebEngineCookieStore); + d->setCookie(resultCallback, cookie, origin); +} + +/*! + Adds \a cookie to the cookie store. This function is provided for convenience and is + equivalent to calling setCookieWithCallback() with an empty callback. + It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. + The provided URL should also include the scheme. + + \sa setCookieWithCallback() +*/ + +void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &origin) +{ + setCookieWithCallback(cookie, QWebEngineCallback(), origin); +} + +/*! + Deletes \a cookie from the cookie store. + It is possible to provide an optional \a origin URL argument to limit the scope of the + cookie to be deleted. + The provided URL should also include the scheme. +*/ + +void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin) +{ + Q_D(QWebEngineCookieStore); + d->deleteCookie(cookie, origin); +} + +/*! + \fn void QWebEngineCookieStore::getAllCookies(FunctorOrLambda resultCallback) + + Requests all the cookies in the cookie store. When the asynchronous operation finishes, + \a resultCallback will be called with a QByteArray as the argument containing the cookies. + This QByteArray can be parsed using QNetworkCookie::parseCookies(). + + \sa deleteCookie() +*/ + +void QWebEngineCookieStore::getAllCookies(const QWebEngineCallback &resultCallback) +{ + Q_D(QWebEngineCookieStore); + if (d->m_getAllCookiesPending) { + d->callbackDirectory.invokeEmpty(resultCallback); + return; + } + d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, resultCallback); + d->getAllCookies(); +} + +/*! + \fn void QWebEngineCookieStore::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback) + + Deletes all the session cookies in the cookie store. Session cookies do not have an + expiration date assigned to them. + When the asynchronous operation finishes, \a resultCallback will be called with the + number of cookies deleted as the argument. +*/ + +void QWebEngineCookieStore::deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback) +{ + Q_D(QWebEngineCookieStore); + if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) { + d->callbackDirectory.invokeEmpty(resultCallback); + return; + } + d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, resultCallback); + d->deleteSessionCookies(); +} + +/*! + \fn void QWebEngineCookieStore::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback) + + Deletes all the cookies in the cookie store. When the asynchronous operation finishes, + \a resultCallback will be called with the number of cookies deleted as the argument. + + \sa deleteSessionCookiesWithCallback(), getAllCookies() +*/ + +void QWebEngineCookieStore::deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback) +{ + Q_D(QWebEngineCookieStore); + if (d->m_deleteAllCookiesPending) { + d->callbackDirectory.invokeEmpty(resultCallback); + return; + } + d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, resultCallback); + d->deleteAllCookies(); +} + +/*! + Deletes all the session cookies in the cookie store. + + \sa deleteSessionCookiesWithCallback() +*/ + +void QWebEngineCookieStore::deleteSessionCookies() +{ + deleteSessionCookiesWithCallback(QWebEngineCallback()); +} + +/*! + Deletes all the cookies in the cookie store. + + \sa deleteAllCookiesWithCallback(), getAllCookies() +*/ + +void QWebEngineCookieStore::deleteAllCookies() +{ + deleteAllCookiesWithCallback(QWebEngineCallback()); +} + +/*! + \fn void QWebEngineCookieStore::setCookieFilter(FunctorOrLambda filterCallback) + + Installs a cookie filter that can reject cookies before they are added to the cookie store. + The \a filterCallback must be a lambda or functor taking FilterRequest structure. If the + cookie is to be rejected, the filter can set FilterRequest::accepted to \c false. + + The callback should not be used to execute heavy tasks since it is running on the + IO thread and therefore blocks the Chromium networking. + + \sa deleteAllCookiesWithCallback(), getAllCookies() +*/ +void QWebEngineCookieStore::setCookieFilter(const QWebEngineCallback &filter) +{ + Q_D(QWebEngineCookieStore); + d->filterCallback = filter; +} + +QT_END_NAMESPACE diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h new file mode 100644 index 000000000..6cbe399f2 --- /dev/null +++ b/src/core/api/qwebenginecookiestore.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINECOOKIESTORE_H +#define QWEBENGINECOOKIESTORE_H + +#include "qtwebenginecoreglobal.h" +#include "qwebenginecallback.h" + +#include +#include +#include +#include + +namespace QtWebEngineCore { +class BrowserContextAdapter; +class CookieMonsterDelegateQt; +} + +QT_BEGIN_NAMESPACE + +class QWebEngineCookieStorePrivate; +class QWEBENGINE_EXPORT QWebEngineCookieStore : public QObject { + Q_OBJECT + +public: + struct FilterRequest { + bool accepted; + + QUrl firstPartyUrl; + QByteArray cookieLine; + QUrl cookieSource; + }; + virtual ~QWebEngineCookieStore(); + +#ifdef Q_QDOC + void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()); + void deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback); + void deleteAllCookiesWithCallback(FunctorOrLambda resultCallback); + void getAllCookies(FunctorOrLambda resultCallback); + void setCookieFilter(FunctorOrLambda filterCallback); +#else + void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin = QUrl()); + void deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback); + void deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback); + void getAllCookies(const QWebEngineCallback &resultCallback); + void setCookieFilter(const QWebEngineCallback &filterCallback); +#endif + void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); + void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); + void deleteSessionCookies(); + void deleteAllCookies(); + +Q_SIGNALS: + void cookieAdded(const QNetworkCookie &cookie); + void cookieRemoved(const QNetworkCookie &cookie); + +private: + explicit QWebEngineCookieStore(QObject *parent = 0); + friend class QtWebEngineCore::BrowserContextAdapter; + friend class QtWebEngineCore::CookieMonsterDelegateQt; + Q_DISABLE_COPY(QWebEngineCookieStore) + Q_DECLARE_PRIVATE(QWebEngineCookieStore) + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QWebEngineCookieStore*) + +#endif // QWEBENGINECOOKIESTORE_H diff --git a/src/core/api/qwebenginecookiestore_p.h b/src/core/api/qwebenginecookiestore_p.h new file mode 100644 index 000000000..a253abd38 --- /dev/null +++ b/src/core/api/qwebenginecookiestore_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINECOOKIESTORE_P_H +#define QWEBENGINECOOKIESTORE_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 "qwebenginecallback_p.h" +#include "qwebenginecookiestore.h" + +#include +#include +#include + +namespace QtWebEngineCore { +class CookieMonsterDelegateQt; +} + +QT_BEGIN_NAMESPACE + +class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate { + struct CookieData { + quint64 callbackId; + QNetworkCookie cookie; + QUrl origin; + }; + friend class QTypeInfo; +public: + Q_DECLARE_PUBLIC(QWebEngineCookieStore) + QtWebEngineCore::CallbackDirectory callbackDirectory; + QWebEngineCallback filterCallback; + QVector m_pendingUserCookies; + quint64 m_nextCallbackId; + bool m_deleteSessionCookiesPending; + bool m_deleteAllCookiesPending; + bool m_getAllCookiesPending; + + QtWebEngineCore::CookieMonsterDelegateQt *delegate; + QWebEngineCookieStore *q_ptr; + + QWebEngineCookieStorePrivate(QWebEngineCookieStore *q); + ~QWebEngineCookieStorePrivate(); + + void processPendingUserCookies(); + void setCookie(const QWebEngineCallback &callback, const QNetworkCookie &cookie, const QUrl &origin); + void deleteCookie(const QNetworkCookie &cookie, const QUrl &url); + void deleteSessionCookies(); + void deleteAllCookies(); + void getAllCookies(); + + bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); + + void onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList); + void onSetCallbackResult(qint64 callbackId, bool success); + void onDeleteCallbackResult(qint64 callbackId, int numCookies); + void onCookieChanged(const QNetworkCookie &cookie, bool removed); +}; + +Q_DECLARE_TYPEINFO(QWebEngineCookieStorePrivate::CookieData, Q_MOVABLE_TYPE); + +QT_END_NAMESPACE + +#endif // QWEBENGINECOOKIESTORE_P_H diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp deleted file mode 100644 index bd43b871d..000000000 --- a/src/core/api/qwebenginecookiestoreclient.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwebenginecookiestoreclient.h" -#include "qwebenginecookiestoreclient_p.h" - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -using namespace QtWebEngineCore; - -QWebEngineCookieStoreClientPrivate::QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient* q) - : m_nextCallbackId(CallbackDirectory::ReservedCallbackIdsEnd) - , m_deleteSessionCookiesPending(false) - , m_deleteAllCookiesPending(false) - , m_getAllCookiesPending(false) - , delegate(0) - , q_ptr(q) -{ -} - -QWebEngineCookieStoreClientPrivate::~QWebEngineCookieStoreClientPrivate() -{ - -} - -void QWebEngineCookieStoreClientPrivate::processPendingUserCookies() -{ - Q_ASSERT(delegate); - Q_ASSERT(delegate->hasCookieMonster()); - - if (m_getAllCookiesPending) { - m_getAllCookiesPending = false; - delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId); - } - - if (m_deleteAllCookiesPending) { - m_deleteAllCookiesPending = false; - delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId); - } - - if (m_deleteSessionCookiesPending) { - m_deleteSessionCookiesPending = false; - delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId); - } - - if (m_pendingUserCookies.isEmpty()) - return; - - Q_FOREACH (const auto &cookieData, m_pendingUserCookies) { - if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId) - delegate->deleteCookie(cookieData.cookie, cookieData.origin); - else - delegate->setCookie(cookieData.callbackId, cookieData.cookie, cookieData.origin); - } - - m_pendingUserCookies.clear(); -} - -void QWebEngineCookieStoreClientPrivate::setCookie(const QWebEngineCallback &callback, const QNetworkCookie &cookie, const QUrl &origin) -{ - const quint64 currentCallbackId = callback ? m_nextCallbackId++ : static_cast(CallbackDirectory::NoCallbackId); - - if (currentCallbackId != CallbackDirectory::NoCallbackId) - callbackDirectory.registerCallback(currentCallbackId, callback); - - if (!delegate || !delegate->hasCookieMonster()) { - m_pendingUserCookies.append(CookieData{ currentCallbackId, cookie, origin }); - return; - } - - delegate->setCookie(currentCallbackId, cookie, origin); -} - -void QWebEngineCookieStoreClientPrivate::deleteCookie(const QNetworkCookie &cookie, const QUrl &url) -{ - if (!delegate || !delegate->hasCookieMonster()) { - m_pendingUserCookies.append(CookieData{ CallbackDirectory::DeleteCookieCallbackId, cookie, url }); - return; - } - - delegate->deleteCookie(cookie, url); -} - -void QWebEngineCookieStoreClientPrivate::deleteSessionCookies() -{ - if (!delegate || !delegate->hasCookieMonster()) { - m_deleteSessionCookiesPending = true; - return; - } - - delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId); -} - -void QWebEngineCookieStoreClientPrivate::deleteAllCookies() -{ - if (!delegate || !delegate->hasCookieMonster()) { - m_deleteAllCookiesPending = true; - m_deleteSessionCookiesPending = false; - return; - } - - delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId); -} - -void QWebEngineCookieStoreClientPrivate::getAllCookies() -{ - if (!delegate || !delegate->hasCookieMonster()) { - m_getAllCookiesPending = true; - return; - } - - delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId); -} - -void QWebEngineCookieStoreClientPrivate::onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList) -{ - callbackDirectory.invoke(callbackId, cookieList); -} -void QWebEngineCookieStoreClientPrivate::onSetCallbackResult(qint64 callbackId, bool success) -{ - callbackDirectory.invoke(callbackId, success); -} - -void QWebEngineCookieStoreClientPrivate::onDeleteCallbackResult(qint64 callbackId, int numCookies) -{ - callbackDirectory.invoke(callbackId, numCookies); -} - -void QWebEngineCookieStoreClientPrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed) -{ - Q_Q(QWebEngineCookieStoreClient); - if (removed) - Q_EMIT q->cookieRemoved(cookie); - else - Q_EMIT q->cookieAdded(cookie); -} - -bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) -{ - if (filterCallback) { - QWebEngineCookieStoreClient::FilterRequest request; - request.accepted = true; - request.firstPartyUrl = firstPartyUrl; - request.cookieLine = cookieLine; - request.cookieSource = url; - callbackDirectory.invokeDirectly(filterCallback, request); - return request.accepted; - } - return true; -} - -/*! - \class QWebEngineCookieStoreClient - \inmodule QtWebEngineCore - \since 5.6 - \brief The QWebEngineCookieStoreClient class provides access to Chromium's cookies. - - The class allows to access HTTP cookies of Chromium for a specific profile. - It can be used to synchronize cookies of Chromium and the QNetworkAccessManager, as well as - to set, delete, and intercept cookies during navigation. - Because cookie operations are asynchronous, the user can choose to provide a callback function - to get notified about the success of the operation. - The signal handlers for removal and addition should not be used to execute heavy tasks, - because they might block the IO thread in case of a blocking connection. -*/ - -/*! - \class QWebEngineCookieStoreClient::FilterRequest - \inmodule QtWebEngineCore - \since 5.6 - - The structure specifies properties of a cookie, and whether it should accepted or not. It is - used as an argument to a filter installed via setCookieFilter(). -*/ - -/*! - \variable QWebEngineCookieStoreClient::FilterRequest::accepted - Whether the cookie shall be accepted. The default is \c true. - \variable QWebEngineCookieStoreClient::FilterRequest::firstPartyUrl - URL of page that triggered the setting of the cookie. - \variable QWebEngineCookieStoreClient::FilterRequest::cookieLine - Content of the cookie. - \variable QWebEngineCookieStoreClient::FilterRequest::cookieSource - URL of site that sets the cookie. -*/ - - -/*! - \fn void QWebEngineCookieStoreClient::cookieAdded(const QNetworkCookie &cookie) - - This signal is emitted whenever a new \a cookie is added to the cookie store. -*/ - -/*! - \fn void QWebEngineCookieStoreClient::cookieRemoved(const QNetworkCookie &cookie) - - This signal is emitted whenever a \a cookie is deleted from the cookie store. -*/ - -/*! - Creates a new QWebEngineCookieStoreClient object with \a parent. -*/ - -QWebEngineCookieStoreClient::QWebEngineCookieStoreClient(QObject *parent) - : QObject(parent) - , d_ptr(new QWebEngineCookieStoreClientPrivate(this)) -{ - -} - -/*! - Destroys this QWebEngineCookieStoreClient object. -*/ - -QWebEngineCookieStoreClient::~QWebEngineCookieStoreClient() -{ - -} - -/*! - \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()) - - Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed - on the caller thread. - It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. - The provided URL should also include the scheme. - - \sa setCookie() -*/ - -void QWebEngineCookieStoreClient::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin) -{ - Q_D(QWebEngineCookieStoreClient); - d->setCookie(resultCallback, cookie, origin); -} - -/*! - Adds \a cookie to the cookie store. This function is provided for convenience and is - equivalent to calling setCookieWithCallback() with an empty callback. - It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. - The provided URL should also include the scheme. - - \sa setCookieWithCallback() -*/ - -void QWebEngineCookieStoreClient::setCookie(const QNetworkCookie &cookie, const QUrl &origin) -{ - setCookieWithCallback(cookie, QWebEngineCallback(), origin); -} - -/*! - Deletes \a cookie from the cookie store. - It is possible to provide an optional \a origin URL argument to limit the scope of the - cookie to be deleted. - The provided URL should also include the scheme. -*/ - -void QWebEngineCookieStoreClient::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin) -{ - Q_D(QWebEngineCookieStoreClient); - d->deleteCookie(cookie, origin); -} - -/*! - \fn void QWebEngineCookieStoreClient::getAllCookies(FunctorOrLambda resultCallback) - - Requests all the cookies in the cookie store. When the asynchronous operation finishes, - \a resultCallback will be called with a QByteArray as the argument containing the cookies. - This QByteArray can be parsed using QNetworkCookie::parseCookies(). - - \sa deleteCookie() -*/ - -void QWebEngineCookieStoreClient::getAllCookies(const QWebEngineCallback &resultCallback) -{ - Q_D(QWebEngineCookieStoreClient); - if (d->m_getAllCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); - return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, resultCallback); - d->getAllCookies(); -} - -/*! - \fn void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback) - - Deletes all the session cookies in the cookie store. Session cookies do not have an - expiration date assigned to them. - When the asynchronous operation finishes, \a resultCallback will be called with the - number of cookies deleted as the argument. -*/ - -void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback) -{ - Q_D(QWebEngineCookieStoreClient); - if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); - return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, resultCallback); - d->deleteSessionCookies(); -} - -/*! - \fn void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback) - - Deletes all the cookies in the cookie store. When the asynchronous operation finishes, - \a resultCallback will be called with the number of cookies deleted as the argument. - - \sa deleteSessionCookiesWithCallback(), getAllCookies() -*/ - -void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback) -{ - Q_D(QWebEngineCookieStoreClient); - if (d->m_deleteAllCookiesPending) { - d->callbackDirectory.invokeEmpty(resultCallback); - return; - } - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, resultCallback); - d->deleteAllCookies(); -} - -/*! - Deletes all the session cookies in the cookie store. - - \sa deleteSessionCookiesWithCallback() -*/ - -void QWebEngineCookieStoreClient::deleteSessionCookies() -{ - deleteSessionCookiesWithCallback(QWebEngineCallback()); -} - -/*! - Deletes all the cookies in the cookie store. - - \sa deleteAllCookiesWithCallback(), getAllCookies() -*/ - -void QWebEngineCookieStoreClient::deleteAllCookies() -{ - deleteAllCookiesWithCallback(QWebEngineCallback()); -} - -/*! - \fn void QWebEngineCookieStoreClient::setCookieFilter(FunctorOrLambda filterCallback) - - Installs a cookie filter that can reject cookies before they are added to the cookie store. - The \a filterCallback must be a lambda or functor taking FilterRequest structure. If the - cookie is to be rejected, the filter can set FilterRequest::accepted to \c false. - - The callback should not be used to execute heavy tasks since it is running on the - IO thread and therefore blocks the Chromium networking. - - \sa deleteAllCookiesWithCallback(), getAllCookies() -*/ -void QWebEngineCookieStoreClient::setCookieFilter(const QWebEngineCallback &filter) -{ - Q_D(QWebEngineCookieStoreClient); - d->filterCallback = filter; -} - -QT_END_NAMESPACE diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h deleted file mode 100644 index 4664a8459..000000000 --- a/src/core/api/qwebenginecookiestoreclient.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWEBENGINECOOKIESTORECLIENT_H -#define QWEBENGINECOOKIESTORECLIENT_H - -#include "qtwebenginecoreglobal.h" -#include "qwebenginecallback.h" - -#include -#include -#include -#include - -namespace QtWebEngineCore { -class BrowserContextAdapter; -class CookieMonsterDelegateQt; -} - -QT_BEGIN_NAMESPACE - -class QWebEngineCookieStoreClientPrivate; -class QWEBENGINE_EXPORT QWebEngineCookieStoreClient : public QObject { - Q_OBJECT - -public: - struct FilterRequest { - bool accepted; - - QUrl firstPartyUrl; - QByteArray cookieLine; - QUrl cookieSource; - }; - virtual ~QWebEngineCookieStoreClient(); - -#ifdef Q_QDOC - void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()); - void deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback); - void deleteAllCookiesWithCallback(FunctorOrLambda resultCallback); - void getAllCookies(FunctorOrLambda resultCallback); - void setCookieFilter(FunctorOrLambda filterCallback); -#else - void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback &resultCallback, const QUrl &origin = QUrl()); - void deleteSessionCookiesWithCallback(const QWebEngineCallback &resultCallback); - void deleteAllCookiesWithCallback(const QWebEngineCallback &resultCallback); - void getAllCookies(const QWebEngineCallback &resultCallback); - void setCookieFilter(const QWebEngineCallback &filterCallback); -#endif - void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); - void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); - void deleteSessionCookies(); - void deleteAllCookies(); - -Q_SIGNALS: - void cookieAdded(const QNetworkCookie &cookie); - void cookieRemoved(const QNetworkCookie &cookie); - -private: - explicit QWebEngineCookieStoreClient(QObject *parent = 0); - friend class QtWebEngineCore::BrowserContextAdapter; - friend class QtWebEngineCore::CookieMonsterDelegateQt; - Q_DISABLE_COPY(QWebEngineCookieStoreClient) - Q_DECLARE_PRIVATE(QWebEngineCookieStoreClient) - QScopedPointer d_ptr; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QWebEngineCookieStoreClient*) - -#endif // QWEBENGINECOOKIESTORECLIENT_H diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h deleted file mode 100644 index 54f3b9eb7..000000000 --- a/src/core/api/qwebenginecookiestoreclient_p.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.LGPLv3 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.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 later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWEBENGINECOOKIESTORECLIENT_P_H -#define QWEBENGINECOOKIESTORECLIENT_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 "qwebenginecallback_p.h" -#include "qwebenginecookiestoreclient.h" - -#include -#include -#include - -namespace QtWebEngineCore { -class CookieMonsterDelegateQt; -} - -QT_BEGIN_NAMESPACE - -class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate { - struct CookieData { - quint64 callbackId; - QNetworkCookie cookie; - QUrl origin; - }; - friend class QTypeInfo; -public: - Q_DECLARE_PUBLIC(QWebEngineCookieStoreClient) - QtWebEngineCore::CallbackDirectory callbackDirectory; - QWebEngineCallback filterCallback; - QVector m_pendingUserCookies; - quint64 m_nextCallbackId; - bool m_deleteSessionCookiesPending; - bool m_deleteAllCookiesPending; - bool m_getAllCookiesPending; - - QtWebEngineCore::CookieMonsterDelegateQt *delegate; - QWebEngineCookieStoreClient *q_ptr; - - QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient *q); - ~QWebEngineCookieStoreClientPrivate(); - - void processPendingUserCookies(); - void setCookie(const QWebEngineCallback &callback, const QNetworkCookie &cookie, const QUrl &origin); - void deleteCookie(const QNetworkCookie &cookie, const QUrl &url); - void deleteSessionCookies(); - void deleteAllCookies(); - void getAllCookies(); - - bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); - - void onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList); - void onSetCallbackResult(qint64 callbackId, bool success); - void onDeleteCallbackResult(qint64 callbackId, int numCookies); - void onCookieChanged(const QNetworkCookie &cookie, bool removed); -}; - -Q_DECLARE_TYPEINFO(QWebEngineCookieStoreClientPrivate::CookieData, Q_MOVABLE_TYPE); - -QT_END_NAMESPACE - -#endif // QWEBENGINECOOKIESTORECLIENT_P_H diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index b5fdf2ce0..7b40688a1 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -136,11 +136,11 @@ DownloadManagerDelegateQt *BrowserContextAdapter::downloadManagerDelegate() return m_downloadManagerDelegate.data(); } -QWebEngineCookieStoreClient *BrowserContextAdapter::cookieStoreClient() +QWebEngineCookieStore *BrowserContextAdapter::cookieStore() { - if (!m_cookieStoreClient) - m_cookieStoreClient.reset(new QWebEngineCookieStoreClient); - return m_cookieStoreClient.data(); + if (!m_cookieStore) + m_cookieStore.reset(new QWebEngineCookieStore); + return m_cookieStore.data(); } QWebEngineUrlRequestInterceptor *BrowserContextAdapter::requestInterceptor() diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index 818dfda3d..97a4dca4a 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -46,7 +46,7 @@ #include #include -#include "api/qwebenginecookiestoreclient.h" +#include "api/qwebenginecookiestore.h" #include "api/qwebengineurlrequestinterceptor.h" #include "api/qwebengineurlschemehandler.h" @@ -73,7 +73,7 @@ public: WebEngineVisitedLinksManager *visitedLinksManager(); DownloadManagerDelegateQt *downloadManagerDelegate(); - QWebEngineCookieStoreClient *cookieStoreClient(); + QWebEngineCookieStore *cookieStore(); QWebEngineUrlRequestInterceptor* requestInterceptor(); void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); @@ -164,7 +164,7 @@ private: QScopedPointer m_visitedLinksManager; QScopedPointer m_downloadManagerDelegate; QScopedPointer m_userScriptController; - QScopedPointer m_cookieStoreClient; + QScopedPointer m_cookieStore; QPointer m_requestInterceptor; QString m_dataPath; diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp index 7622614ca..a81670a6c 100644 --- a/src/core/cookie_monster_delegate_qt.cpp +++ b/src/core/cookie_monster_delegate_qt.cpp @@ -40,8 +40,8 @@ #include "content/public/browser/browser_thread.h" #include "net/cookies/cookie_util.h" -#include "api/qwebenginecookiestoreclient.h" -#include "api/qwebenginecookiestoreclient_p.h" +#include "api/qwebenginecookiestore.h" +#include "api/qwebenginecookiestore_p.h" #include "type_conversion.h" #include @@ -53,15 +53,15 @@ static GURL sourceUrlForCookie(const QNetworkCookie &cookie) { return net::cookie_util::CookieOriginToURL(urlFragment.toStdString(), /* is_https */ cookie.isSecure()); } -static void onSetCookieCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, bool success) { +static void onSetCookieCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, bool success) { client->onSetCallbackResult(callbackId, success); } -static void onDeleteCookiesCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, int numCookies) { +static void onDeleteCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, int numCookies) { client->onDeleteCallbackResult(callbackId, numCookies); } -static void onGetAllCookiesCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, const net::CookieList& cookies) { +static void onGetAllCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, const net::CookieList& cookies) { QByteArray rawCookies; for (auto&& cookie: cookies) rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n"); @@ -145,7 +145,7 @@ void CookieMonsterDelegateQt::setCookieMonster(net::CookieMonster* monster) m_client->d_func()->processPendingUserCookies(); } -void CookieMonsterDelegateQt::setClient(QWebEngineCookieStoreClient *client) +void CookieMonsterDelegateQt::setClient(QWebEngineCookieStore *client) { m_client = client; diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h index db80bf0a1..c9f27c2bc 100644 --- a/src/core/cookie_monster_delegate_qt.h +++ b/src/core/cookie_monster_delegate_qt.h @@ -50,7 +50,7 @@ QT_WARNING_POP #include #include -QT_FORWARD_DECLARE_CLASS(QWebEngineCookieStoreClient) +QT_FORWARD_DECLARE_CLASS(QWebEngineCookieStore) namespace QtWebEngineCore { @@ -62,7 +62,7 @@ static const char* const kCookieableSchemes[] = { "http", "https", "qrc", "ws", "wss" }; class QWEBENGINE_EXPORT CookieMonsterDelegateQt: public net::CookieMonsterDelegate { - QPointer m_client; + QPointer m_client; scoped_refptr m_cookieMonster; public: CookieMonsterDelegateQt(); @@ -77,7 +77,7 @@ public: void deleteAllCookies(quint64 callbackId); void setCookieMonster(net::CookieMonster* monster); - void setClient(QWebEngineCookieStoreClient *client); + void setClient(QWebEngineCookieStore *client); bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) override; diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 26e1dbea8..5460e083f 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -74,8 +74,8 @@ #include "network_delegate_qt.h" #include "proxy_config_service_qt.h" #include "qrc_protocol_handler_qt.h" -#include "qwebenginecookiestoreclient.h" -#include "qwebenginecookiestoreclient_p.h" +#include "qwebenginecookiestore.h" +#include "qwebenginecookiestore_p.h" #include "type_conversion.h" namespace QtWebEngineCore { @@ -204,7 +204,7 @@ void URLRequestContextGetterQt::generateCookieStore() // Unset it first to get a chance to destroy and flush the old cookie store before before opening a new on possibly the same file. m_storage->set_cookie_store(0); m_cookieDelegate->setCookieMonster(0); - m_cookieDelegate->setClient(m_browserContext->cookieStoreClient()); + m_cookieDelegate->setClient(m_browserContext->cookieStore()); net::CookieStore* cookieStore = 0; switch (m_browserContext->persistentCookiesPolicy()) { -- cgit v1.2.3