File indexing completed on 2025-01-19 04:47:00

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <WebEngineViewer/NetworkPluginUrlInterceptorInterface>
0010 #include <WebEngineViewer/WebHitTestResult>
0011 class QWebEngineView;
0012 class AdblockInterceptorInterface : public WebEngineViewer::NetworkPluginUrlInterceptorInterface
0013 {
0014     Q_OBJECT
0015 public:
0016     explicit AdblockInterceptorInterface(QObject *parent = nullptr);
0017     ~AdblockInterceptorInterface() override;
0018 
0019     [[nodiscard]] bool interceptRequest(QWebEngineUrlRequestInfo &info) override;
0020     [[nodiscard]] QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const override;
0021     void createActions(KActionCollection *ac) override;
0022     [[nodiscard]] QWebEngineView *webEngineView() const;
0023 
0024     void setWebEngineView(QWebEngineView *webEngineView);
0025 
0026 private:
0027     mutable WebEngineViewer::WebHitTestResult mCurrentWebHitTest;
0028     QAction *mShowBlockableItems = nullptr;
0029     QAction *mBlockImage = nullptr;
0030     QWebEngineView *mWebEngineView = nullptr;
0031 };