Commit 87bca4c4 authored by Anthony Fieroni's avatar Anthony Fieroni Committed by Stefano Crocco
Browse files

Restore adblock filter


Signed-off-by: Anthony Fieroni's avatarAnthony Fieroni <bvbfan@abv.bg>
parent 779c1f43
......@@ -30,6 +30,7 @@ set(kwebenginepartlib_LIB_SRCS
webenginecustomizecacheablefieldsdlg.cpp
webfieldsdataview.cpp
ui/credentialsdetailswidget.cpp
webengineurlrequestinterceptor.cpp
)
ki18n_wrap_ui(kwebenginepartlib_LIB_SRCS webenginecustomizecacheablefieldsdlg.ui ui/credentialsdetailswidget.ui)
......
......@@ -387,7 +387,7 @@ void WebEngineSettings::init( KConfig * config, bool reset )
if (filterEnabled && url.isValid()) {
/** determine where to cache HTMLFilterList file */
QString localFile = cgFilter.readEntry(QStringLiteral("HTMLFilterListLocalFilename-").append(QString::number(id)));
localFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, "khtml/" + localFile);
localFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, "khtml/", QStandardPaths::LocateDirectory) + localFile;
/** determine existence and age of cache file */
QFileInfo fileInfo(localFile);
......
......@@ -41,6 +41,7 @@
#include "webenginewallet.h"
#include "webengineparterrorschemehandler.h"
#include "webenginepartcookiejar.h"
#include "webengineurlrequestinterceptor.h"
#include "ui/searchbar.h"
#include "ui/passwordbar.h"
......@@ -133,6 +134,7 @@ WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
prof->installUrlSchemeHandler("help", new WebEnginePartKIOHandler(prof));
prof->installUrlSchemeHandler("tar", new WebEnginePartKIOHandler(prof));
}
prof->setUrlRequestInterceptor(new WebEngineUrlRequestInterceptor(this));
static WebEnginePartCookieJar s_cookieJar(prof, nullptr);
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
......
/*
* This file is part of the KDE project.
*
* Copyright (C) 2021 Anthony Fieroni <bvbfan@abv.bg>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "settings/webenginesettings.h"
#include "webengineurlrequestinterceptor.h"
WebEngineUrlRequestInterceptor::WebEngineUrlRequestInterceptor(QObject* parent) :
QWebEngineUrlRequestInterceptor(parent)
{
}
void WebEngineUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage) {
info.block(WebEngineSettings::self()->isAdFiltered(info.requestUrl().url()));
}
}
/*
* This file is part of the KDE project.
*
* Copyright (C) 2021 Anthony Fieroni <bvbfan@abv.bg>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef WEBENGINEURLREQUESTINTERCEPTOR
#define WEBENGINEURLREQUESTINTERCEPTOR
#include <QWebEngineUrlRequestInfo>
#include <QWebEngineUrlRequestInterceptor>
class WebEngineUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
{
public:
WebEngineUrlRequestInterceptor(QObject* parent = nullptr);
void interceptRequest(QWebEngineUrlRequestInfo &info) override;
};
#endif // WEBENGINEURLREQUESTINTERCEPTOR
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