Commit 1297707f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Don't call all interceptor if we block it

parent 7a25c61a
...@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) ...@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory) include(ECMQtDeclareLoggingCategory)
include(ECMAddTests) include(ECMAddTests)
set(MESSAGELIB_LIB_VERSION "5.2.46") set(MESSAGELIB_LIB_VERSION "5.2.47")
set(KF5_VERSION "5.19.0") set(KF5_VERSION "5.19.0")
set(KDEPIMLIBS_LIB_VERSION "5.2.40") set(KDEPIMLIBS_LIB_VERSION "5.2.40")
......
...@@ -44,14 +44,15 @@ LoadExternalReferencesUrlInterceptor::~LoadExternalReferencesUrlInterceptor() ...@@ -44,14 +44,15 @@ LoadExternalReferencesUrlInterceptor::~LoadExternalReferencesUrlInterceptor()
delete d; delete d;
} }
void LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) bool LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{ {
if (!d->mAllowLoadExternalReference) { if (!d->mAllowLoadExternalReference) {
//TODO add more resource type //TODO add more resource type
if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage && !info.requestUrl().isLocalFile()) { if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage && !info.requestUrl().isLocalFile()) {
info.block(true); return true;
} }
} }
return false;
} }
void LoadExternalReferencesUrlInterceptor::setAllowExternalContent(bool b) void LoadExternalReferencesUrlInterceptor::setAllowExternalContent(bool b)
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
explicit LoadExternalReferencesUrlInterceptor(QObject *parent = Q_NULLPTR); explicit LoadExternalReferencesUrlInterceptor(QObject *parent = Q_NULLPTR);
~LoadExternalReferencesUrlInterceptor(); ~LoadExternalReferencesUrlInterceptor();
void interceptRequest(QWebEngineUrlRequestInfo &info) Q_DECL_OVERRIDE; bool interceptRequest(QWebEngineUrlRequestInfo &info) Q_DECL_OVERRIDE;
void setAllowExternalContent(bool b); void setAllowExternalContent(bool b);
bool allowExternalContent() const; bool allowExternalContent() const;
private: private:
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
virtual void createActions(KActionCollection *ac); virtual void createActions(KActionCollection *ac);
virtual QList<QAction *> actions() const; virtual QList<QAction *> actions() const;
virtual void interceptRequest(QWebEngineUrlRequestInfo &info) = 0; virtual bool interceptRequest(QWebEngineUrlRequestInfo &info) = 0;
}; };
} }
#endif // MAILNETWORKPLUGINURLINTERCEPTORINTERFACE_H #endif // MAILNETWORKPLUGINURLINTERCEPTORINTERFACE_H
...@@ -47,7 +47,10 @@ void NetworkUrlInterceptorPrivate::addInterceptor(NetworkPluginUrlInterceptorInt ...@@ -47,7 +47,10 @@ void NetworkUrlInterceptorPrivate::addInterceptor(NetworkPluginUrlInterceptorInt
void NetworkUrlInterceptorPrivate::interceptRequest(QWebEngineUrlRequestInfo &info) void NetworkUrlInterceptorPrivate::interceptRequest(QWebEngineUrlRequestInfo &info)
{ {
Q_FOREACH (NetworkPluginUrlInterceptorInterface *inter, listInterceptor) { Q_FOREACH (NetworkPluginUrlInterceptorInterface *inter, listInterceptor) {
inter->interceptRequest(info); if (inter->interceptRequest(info)) {
info.block(true);
break;
}
} }
} }
......
Supports Markdown
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