diff --git a/src/lib/plugins/plugininterface.h b/src/lib/plugins/plugininterface.h index 3aeb76433..cac4264e4 100644 --- a/src/lib/plugins/plugininterface.h +++ b/src/lib/plugins/plugininterface.h @@ -20,12 +20,7 @@ #include #include -#include -#if QTWEBENGINE_DISABLED -#include -#endif - -#include +#include #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 diff --git a/src/lib/plugins/pluginproxy.cpp b/src/lib/plugins/pluginproxy.cpp index 09342f40b..a4e04bf1c 100644 --- a/src/lib/plugins/pluginproxy.cpp +++ b/src/lib/plugins/pluginproxy.cpp @@ -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) diff --git a/src/lib/plugins/pluginproxy.h b/src/lib/plugins/pluginproxy.h index 041c7b913..3d0aae45a 100644 --- a/src/lib/plugins/pluginproxy.h +++ b/src/lib/plugins/pluginproxy.h @@ -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); diff --git a/src/lib/webkit/webpage.cpp b/src/lib/webkit/webpage.cpp index ac06f7cda..c69e63313 100644 --- a/src/lib/webkit/webpage.cpp +++ b/src/lib/webkit/webpage.cpp @@ -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)