mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Fix build with latest QtWebEngine 5.6
This commit is contained in:
parent
37f32021df
commit
de20021f10
|
@ -23,15 +23,25 @@
|
|||
#include "qztools.h"
|
||||
|
||||
#include <QNetworkCookie>
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QDateTime>
|
||||
|
||||
//#define COOKIE_DEBUG
|
||||
|
||||
CookieJar::CookieJar(QObject* parent)
|
||||
: QWebEngineCookieStoreClient(parent)
|
||||
: QObject(parent)
|
||||
, m_client(mApp->webProfile()->cookieStoreClient())
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
connect(m_client, &QWebEngineCookieStoreClient::cookieAdded, this, &CookieJar::cookieAdded);
|
||||
connect(m_client, &QWebEngineCookieStoreClient::cookieRemoved, this, &CookieJar::cookieRemoved);
|
||||
|
||||
m_client->setCookieFilter([this](const QWebEngineCookieStoreClient::FilterRequest &req) {
|
||||
QWebEngineCookieStoreClient::FilterRequest &r = const_cast<QWebEngineCookieStoreClient::FilterRequest&>(req);
|
||||
r.accepted = acceptCookie(r.firstPartyUrl, r.cookieLine, r.cookieSource);
|
||||
});
|
||||
}
|
||||
|
||||
void CookieJar::loadSettings()
|
||||
|
@ -51,7 +61,44 @@ void CookieJar::setAllowCookies(bool allow)
|
|||
m_allowCookies = allow;
|
||||
}
|
||||
|
||||
bool CookieJar::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource)
|
||||
void CookieJar::getAllCookies(const QWebEngineCallback<const QByteArray &> callback)
|
||||
{
|
||||
m_client->getAllCookies(callback);
|
||||
}
|
||||
|
||||
void CookieJar::deleteAllCookies()
|
||||
{
|
||||
m_client->deleteAllCookies();
|
||||
}
|
||||
|
||||
bool CookieJar::matchDomain(QString cookieDomain, QString siteDomain) const
|
||||
{
|
||||
// According to RFC 6265
|
||||
|
||||
// Remove leading dot
|
||||
if (cookieDomain.startsWith(QLatin1Char('.'))) {
|
||||
cookieDomain = cookieDomain.mid(1);
|
||||
}
|
||||
|
||||
if (siteDomain.startsWith(QLatin1Char('.'))) {
|
||||
siteDomain = siteDomain.mid(1);
|
||||
}
|
||||
|
||||
return QzTools::matchDomain(cookieDomain, siteDomain);
|
||||
}
|
||||
|
||||
bool CookieJar::listMatchesDomain(const QStringList &list, const QString &cookieDomain) const
|
||||
{
|
||||
foreach (const QString &d, list) {
|
||||
if (matchDomain(d, cookieDomain)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CookieJar::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) const
|
||||
{
|
||||
const QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(cookieLine);
|
||||
Q_ASSERT(cookies.size() == 1);
|
||||
|
@ -101,30 +148,3 @@ bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CookieJar::matchDomain(QString cookieDomain, QString siteDomain) const
|
||||
{
|
||||
// According to RFC 6265
|
||||
|
||||
// Remove leading dot
|
||||
if (cookieDomain.startsWith(QLatin1Char('.'))) {
|
||||
cookieDomain = cookieDomain.mid(1);
|
||||
}
|
||||
|
||||
if (siteDomain.startsWith(QLatin1Char('.'))) {
|
||||
siteDomain = siteDomain.mid(1);
|
||||
}
|
||||
|
||||
return QzTools::matchDomain(cookieDomain, siteDomain);
|
||||
}
|
||||
|
||||
bool CookieJar::listMatchesDomain(const QStringList &list, const QString &cookieDomain) const
|
||||
{
|
||||
foreach (const QString &d, list) {
|
||||
if (matchDomain(d, cookieDomain)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
class AutoSaver;
|
||||
|
||||
class QUPZILLA_EXPORT CookieJar : public QWebEngineCookieStoreClient
|
||||
class QUPZILLA_EXPORT CookieJar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -36,13 +36,20 @@ public:
|
|||
void loadSettings();
|
||||
|
||||
void setAllowCookies(bool allow);
|
||||
bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) Q_DECL_OVERRIDE;
|
||||
|
||||
void getAllCookies(const QWebEngineCallback<const QByteArray&> callback);
|
||||
void deleteAllCookies();
|
||||
|
||||
signals:
|
||||
void cookieAdded(const QNetworkCookie &cookie);
|
||||
void cookieRemoved(const QNetworkCookie &cookie);
|
||||
|
||||
protected:
|
||||
bool matchDomain(QString cookieDomain, QString siteDomain) const;
|
||||
bool listMatchesDomain(const QStringList &list, const QString &cookieDomain) const;
|
||||
|
||||
private:
|
||||
bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) const;
|
||||
bool rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const;
|
||||
|
||||
bool m_allowCookies;
|
||||
|
@ -51,6 +58,7 @@ private:
|
|||
|
||||
QStringList m_whitelist;
|
||||
QStringList m_blacklist;
|
||||
QWebEngineCookieStoreClient *m_client;
|
||||
};
|
||||
|
||||
#endif // COOKIEJAR_H
|
||||
|
|
|
@ -84,8 +84,8 @@ CookieManager::CookieManager()
|
|||
connect(removeShortcut, SIGNAL(activated()), this, SLOT(deletePressed()));
|
||||
|
||||
connect(ui->search, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString)));
|
||||
connect (mApp->cookieJar(), &CookieJar::cookieAdded, this, &CookieManager::addCookie);
|
||||
connect (mApp->cookieJar(), &CookieJar::cookieRemoved, this, &CookieManager::removeCookie);
|
||||
connect(mApp->cookieJar(), &CookieJar::cookieAdded, this, &CookieManager::addCookie);
|
||||
connect(mApp->cookieJar(), &CookieJar::cookieRemoved, this, &CookieManager::removeCookie);
|
||||
|
||||
// Load cookies
|
||||
mApp->cookieJar()->getAllCookies([this](const QByteArray &res) {
|
||||
|
|
|
@ -43,14 +43,14 @@ NetworkManager::NetworkManager(QObject *parent)
|
|||
: QNetworkAccessManager(parent)
|
||||
{
|
||||
// Create scheme handlers
|
||||
mApp->webProfile()->installUrlSchemeHandler(new QupZillaSchemeHandler(this));
|
||||
mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("qupzilla"), new QupZillaSchemeHandler(this));
|
||||
|
||||
// Create url interceptor
|
||||
m_urlInterceptor = new NetworkUrlInterceptor(this);
|
||||
mApp->webProfile()->setRequestInterceptor(m_urlInterceptor);
|
||||
|
||||
// Create cookie jar
|
||||
mApp->webProfile()->setCookieStoreClient(mApp->cookieJar());
|
||||
mApp->cookieJar();
|
||||
|
||||
connect(this, &QNetworkAccessManager::authenticationRequired, this, [this](QNetworkReply *reply, QAuthenticator *auth) {
|
||||
authentication(reply->url(), auth);
|
||||
|
|
|
@ -39,7 +39,7 @@ static QString authorString(const char* name, const QString &mail)
|
|||
}
|
||||
|
||||
QupZillaSchemeHandler::QupZillaSchemeHandler(QObject *parent)
|
||||
: QWebEngineUrlSchemeHandler(QByteArrayLiteral("qupzilla"), parent)
|
||||
: QWebEngineUrlSchemeHandler(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <QWebChannel>
|
||||
#include <QWebEngineHistory>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QWebEngineFullScreenRequest>
|
||||
#include <QTimer>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
|
@ -316,9 +317,16 @@ void WebPage::windowCloseRequested()
|
|||
view()->closeView();
|
||||
}
|
||||
|
||||
void WebPage::fullScreenRequested(bool fullScreen)
|
||||
void WebPage::fullScreenRequested(const QWebEngineFullScreenRequest &fullScreenRequest)
|
||||
{
|
||||
view()->requestFullScreen(fullScreen);
|
||||
view()->requestFullScreen(fullScreenRequest.toggleOn());
|
||||
|
||||
const bool accepted = fullScreenRequest.toggleOn() == view()->isFullScreen();
|
||||
|
||||
if (accepted)
|
||||
fullScreenRequest.accept();
|
||||
else
|
||||
fullScreenRequest.reject();
|
||||
}
|
||||
|
||||
void WebPage::featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature)
|
||||
|
@ -351,11 +359,6 @@ void WebPage::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationSt
|
|||
});
|
||||
}
|
||||
|
||||
bool WebPage::isFullScreen()
|
||||
{
|
||||
return view()->isFullScreen();
|
||||
}
|
||||
|
||||
bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
|
||||
{
|
||||
if (!mApp->plugins()->acceptNavigationRequest(this, url, type, isMainFrame))
|
||||
|
|
|
@ -74,12 +74,11 @@ private slots:
|
|||
void urlChanged(const QUrl &url);
|
||||
void watchedFileChanged(const QString &file);
|
||||
void windowCloseRequested();
|
||||
void fullScreenRequested(bool fullScreen);
|
||||
void fullScreenRequested(const QWebEngineFullScreenRequest &fullScreenRequest);
|
||||
void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature);
|
||||
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode);
|
||||
|
||||
private:
|
||||
bool isFullScreen() Q_DECL_OVERRIDE;
|
||||
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
||||
bool certificateError(const QWebEngineCertificateError &error) Q_DECL_OVERRIDE;
|
||||
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
|
||||
|
|
Loading…
Reference in New Issue
Block a user