Falkon Develop
Cross-platform Qt-based web browser
cookiejar.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef COOKIEJAR_H
19#define COOKIEJAR_H
20
21#include <QVector>
22#include <QStringList>
23#include <QWebEngineCookieStore>
24#include <QtWebEngineWidgetsVersion>
25
26#include "qzcommon.h"
27
28class AutoSaver;
29
30class FALKON_EXPORT CookieJar : public QObject
31{
32 Q_OBJECT
33
34public:
35 explicit CookieJar(QObject* parent = nullptr);
36 ~CookieJar();
37
38 void loadSettings();
39
40 void setAllowCookies(bool allow);
41
42 void deleteCookie(const QNetworkCookie &cookie);
43
44 QVector<QNetworkCookie> getAllCookies() const;
45 void deleteAllCookies(bool deleteAll = true);
46
47Q_SIGNALS:
48 void cookieAdded(const QNetworkCookie &cookie);
49 void cookieRemoved(const QNetworkCookie &cookie);
50
51protected:
52 bool matchDomain(QString cookieDomain, QString siteDomain) const;
53 bool listMatchesDomain(const QStringList &list, const QString &cookieDomain) const;
54
55private:
56 void slotCookieAdded(const QNetworkCookie &cookie);
57 void slotCookieRemoved(const QNetworkCookie &cookie);
58
59 bool cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const;
60
61 bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) const;
62 bool rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const;
63
64 bool m_allowCookies;
65 bool m_filterTrackingCookie;
66 bool m_filterThirdParty;
67
68 QWebEngineCookieStore *m_client;
69 QVector<QNetworkCookie> m_cookies;
70};
71
72#endif // COOKIEJAR_H
#define FALKON_EXPORT
Definition: qzcommon.h:28