diff options
author | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-07-10 17:27:45 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-08-03 20:46:55 +0000 |
commit | e11cd75ff506e8dcbfc990d70baeec821f1f0563 (patch) | |
tree | db4e58d9b0c66656e5eccb368dd61cdb36034c75 /src/webenginewidgets | |
parent | 853d5867644fd53f2d779c3c7b39a34803a3e566 (diff) |
Add API for intercepting url requests
This patch is adding a QWebEngineUrlRequestInterceptor interface
that can be subclassed to observe or intercept all resource requests
making it possible to implement browser features like adblocking
and setting custom request headers for url requests.
The interceptRequest virtual function is executed on the IO thread.
This patch also includes a unit test for the testable API parts.
Change-Id: Ibe740fc55551a9a5da40794088ccb6d03d913631
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Martin Rotter <rotter.martinos@gmail.com>
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 6 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index afe2277f2..b73355ac2 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -416,6 +416,12 @@ void QWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient *client d->browserContext()->setCookieStoreClient(client); } +void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) +{ + Q_D(QWebEngineProfile); + d->browserContext()->setRequestInterceptor(interceptor); +} + /*! Clears all links from the visited links database. diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index b13f3d631..c90ea01e5 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -54,6 +54,7 @@ class QWebEnginePagePrivate; class QWebEngineProfilePrivate; class QWebEngineSettings; class QWebEngineScriptCollection; +class QWebEngineUrlRequestInterceptor; class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject { Q_OBJECT @@ -96,6 +97,7 @@ public: QWebEngineCookieStoreClient* cookieStoreClient(); void setCookieStoreClient(QWebEngineCookieStoreClient *client); + void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); void clearAllVisitedLinks(); void clearVisitedLinks(const QList<QUrl> &urls); |