Commit e43f2f12 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to add new interceptor

parent db667856
......@@ -26,11 +26,13 @@ class MessageViewer::NetworkAccessManagerWebEnginePrivate
{
public:
NetworkAccessManagerWebEnginePrivate()
: mManager(Q_NULLPTR)
: mManager(Q_NULLPTR),
mNetworkUrlInterceptor(Q_NULLPTR)
{
}
MessageViewer::NetworkUrlInterceptorManager *mManager;
MessageViewer::NetworkUrlInterceptor *mNetworkUrlInterceptor;
};
NetworkAccessManagerWebEngine::NetworkAccessManagerWebEngine(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent)
......@@ -40,14 +42,19 @@ NetworkAccessManagerWebEngine::NetworkAccessManagerWebEngine(QWebEngineView *web
d->mManager = new MessageViewer::NetworkUrlInterceptorManager(webEngine, ac, this);
// Add interceptor.
MessageViewer::NetworkUrlInterceptor *networkUrlInterceptor = new MessageViewer::NetworkUrlInterceptor(this);
d->mNetworkUrlInterceptor = new MessageViewer::NetworkUrlInterceptor(this);
Q_FOREACH (MessageViewer::NetworkPluginUrlInterceptorInterface *interface, d->mManager->interfaceList()) {
networkUrlInterceptor->addInterceptor(interface);
d->mNetworkUrlInterceptor->addInterceptor(interface);
}
QWebEngineProfile::defaultProfile()->setRequestInterceptor(networkUrlInterceptor);
QWebEngineProfile::defaultProfile()->setRequestInterceptor(d->mNetworkUrlInterceptor);
}
NetworkAccessManagerWebEngine::~NetworkAccessManagerWebEngine()
{
delete d;
}
void NetworkAccessManagerWebEngine::addInterceptor(MessageViewer::NetworkPluginUrlInterceptorInterface *interceptor)
{
d->mNetworkUrlInterceptor->addInterceptor(interceptor);
}
......@@ -24,6 +24,7 @@ class KActionCollection;
class QWebEngineView;
namespace MessageViewer
{
class NetworkPluginUrlInterceptorInterface;
class NetworkAccessManagerWebEnginePrivate;
class MESSAGEVIEWER_EXPORT NetworkAccessManagerWebEngine : public QNetworkAccessManager
{
......@@ -31,6 +32,7 @@ class MESSAGEVIEWER_EXPORT NetworkAccessManagerWebEngine : public QNetworkAccess
public:
explicit NetworkAccessManagerWebEngine(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent = Q_NULLPTR);
~NetworkAccessManagerWebEngine();
void addInterceptor(MessageViewer::NetworkPluginUrlInterceptorInterface *interceptor);
private:
NetworkAccessManagerWebEnginePrivate *const d;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment