diff options
author | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-06-03 19:00:34 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-06-16 09:39:22 +0000 |
commit | 8a77cd16793bc91b0f7c267fc579a3041dd55e61 (patch) | |
tree | adeb282e7170f753719a6984252ff2b39aa9dc72 /src/core/cookie_monster_delegate_qt.h | |
parent | 0e006b8ea755ebad01faf3e747e61abdf158289a (diff) |
Add QWebEngineCookieStoreClient core API
This class or its subclass can be set on the
QWebEngineProfile and its API enables intercepting
Chromium's cookies, setting and deleting cookies
in the cookie store.
These functions are asynchronous so if the result
of the task is needed the user can provide a
callback which will be run on the calling thread
when the requested operation finishes.
This does not include a hook for QQuick layer yet,
there we have to figure out what the most convenient
way is from a developer's perspective.
Change-Id: I6a3af071883ce632df7a2fb952da93f306ac3fe2
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'src/core/cookie_monster_delegate_qt.h')
-rw-r--r-- | src/core/cookie_monster_delegate_qt.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h new file mode 100644 index 000000000..05ab24e9f --- /dev/null +++ b/src/core/cookie_monster_delegate_qt.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 COOKIE_MONSTER_DELEGATE_QT_H +#define COOKIE_MONSTER_DELEGATE_QT_H + +#include "qtwebenginecoreglobal.h" + +QT_WARNING_PUSH +// For some reason adding -Wno-unused-parameter to QMAKE_CXXFLAGS has no +// effect with clang, so use a pragma for these dirty chromium headers +QT_WARNING_DISABLE_CLANG("-Wunused-parameter") +#include "base/memory/ref_counted.h" +#include "net/cookies/cookie_monster.h" +QT_WARNING_POP + +#include <QList> +#include <QNetworkCookie> +#include <QPointer> + +QT_FORWARD_DECLARE_CLASS(QWebEngineCookieStoreClient) + +namespace QtWebEngineCore { + +class QWEBENGINE_EXPORT CookieMonsterDelegateQt: public net::CookieMonsterDelegate { + QPointer<QWebEngineCookieStoreClient> m_client; + scoped_refptr<net::CookieMonster> m_cookieMonster; +public: + CookieMonsterDelegateQt(); + ~CookieMonsterDelegateQt(); + + bool hasCookieMonster(); + + void setCookie(quint64 callbackId, const QNetworkCookie &cookie, const QUrl &origin); + void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin); + + void setCookieMonster(net::CookieMonster* monster); + void setClient(QWebEngineCookieStoreClient *client); + + void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) override; + void OnLoaded() override; +}; + +} + +#endif // COOKIE_MONSTER_DELEGATE_QT_H |