1 /************************************************************************** 2 * Otter Browser: Web browser controlled by the user, not vice-versa. 3 * Copyright (C) 2015 - 2018 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 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 **************************************************************************/ 19 20 #ifndef OTTER_QTWEBKITCOOKIEJAR_H 21 #define OTTER_QTWEBKITCOOKIEJAR_H 22 23 #include "../../../../core/CookieJar.h" 24 25 #include <QtCore/QStringList> 26 27 namespace Otter 28 { 29 30 class WebWidget; 31 32 class QtWebKitCookieJar final : public QNetworkCookieJar 33 { 34 Q_OBJECT 35 36 public: 37 explicit QtWebKitCookieJar(CookieJar *cookieJar, WebWidget *widget); 38 39 void setup(const QStringList &thirdPartyAcceptedHosts, const QStringList &thirdPartyRejectedHosts, CookieJar::CookiesPolicy generalCookiesPolicy, CookieJar::CookiesPolicy thirdPartyCookiesPolicy, CookieJar::KeepMode keepMode); 40 void setWidget(WebWidget *widget); 41 QtWebKitCookieJar* clone(WebWidget *parent = nullptr); 42 CookieJar* getCookieJar(); 43 QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override; 44 bool insertCookie(const QNetworkCookie &cookie) override; 45 bool updateCookie(const QNetworkCookie &cookie) override; 46 bool deleteCookie(const QNetworkCookie &cookie) override; 47 bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) override; 48 49 protected: 50 void showDialog(const QNetworkCookie &cookie, CookieJar::CookieOperation operation); 51 bool canModifyCookie(const QNetworkCookie &cookie) const; 52 53 private: 54 WebWidget *m_widget; 55 CookieJar *m_cookieJar; 56 QStringList m_thirdPartyAcceptedHosts; 57 QStringList m_thirdPartyRejectedHosts; 58 CookieJar::CookiesPolicy m_generalCookiesPolicy; 59 CookieJar::CookiesPolicy m_thirdPartyCookiesPolicy; 60 CookieJar::KeepMode m_keepMode; 61 }; 62 63 } 64 65 #endif 66