1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

PluginInterface: Replace createRequest with acceptNavigationRequest

This commit is contained in:
David Rosca 2015-05-24 21:41:09 +02:00
parent 7d9a07b379
commit b83c845bab
4 changed files with 16 additions and 17 deletions

View File

@ -20,12 +20,7 @@
#include <QPixmap>
#include <QtPlugin>
#include <QNetworkRequest>
#if QTWEBENGINE_DISABLED
#include <QWebHitTestResult>
#endif
#include <QNetworkAccessManager>
#include <QWebEnginePage>
#include "qzcommon.h"
@ -59,6 +54,7 @@ class QKeyEvent;
class QWheelEvent;
class WebView;
class WebPage;
class PluginInterface
{
@ -86,9 +82,9 @@ public:
virtual bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
virtual bool keyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
virtual QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { Q_UNUSED(op) Q_UNUSED(request) Q_UNUSED(outgoingData) return 0; }
virtual bool acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) { Q_UNUSED(page); Q_UNUSED(url); Q_UNUSED(type); Q_UNUSED(isMainFrame); return true; }
};
Q_DECLARE_INTERFACE(PluginInterface, "QupZilla.Browser.PluginInterface/1.2")
Q_DECLARE_INTERFACE(PluginInterface, "QupZilla.Browser.PluginInterface/2.0")
#endif // PLUGININTERFACE_H

View File

@ -191,16 +191,17 @@ bool PluginProxy::processKeyRelease(const Qz::ObjectName &type, QObject* obj, QK
return accepted;
}
QNetworkReply* PluginProxy::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
bool PluginProxy::acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
{
bool accepted = true;
foreach (PluginInterface* iPlugin, m_loadedPlugins) {
QNetworkReply* reply = iPlugin->createRequest(op, request, outgoingData);
if (reply) {
return reply;
if (!iPlugin->acceptNavigationRequest(page, url, type, isMainFrame)) {
accepted = false;
}
}
return 0;
return accepted;
}
void PluginProxy::emitWebPageCreated(WebPage* page)

View File

@ -49,7 +49,7 @@ public:
bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
bool acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame);
void emitWebPageCreated(WebPage* page);
void emitWebPageDeleted(WebPage* page);

View File

@ -785,6 +785,11 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio
{
m_lastRequestUrl = url;
if (!mApp->plugins()->acceptNavigationRequest(this, url, type, isMainFrame))
return false;
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
#if QTWEBENGINE_DISABLED
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
// Don't show this dialog if app is still starting
@ -800,9 +805,6 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio
}
}
#endif
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}
void WebPage::addAdBlockRule(const AdBlockRule* rule, const QUrl &url)