File indexing completed on 2025-01-26 04:57:24
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "webengineviewer_export.h" 0010 #include <QDebug> 0011 #include <QList> 0012 #include <WebEngineViewer/NetworkPluginUrlInterceptorInterface> 0013 namespace WebEngineViewer 0014 { 0015 /** 0016 * @brief The BlockMailTrackingUrlInterceptor class 0017 * @author Laurent Montel <montel@kde.org> 0018 */ 0019 class WEBENGINEVIEWER_EXPORT BlockTrackingUrlInterceptor : public WebEngineViewer::NetworkPluginUrlInterceptorInterface 0020 { 0021 Q_OBJECT 0022 public: 0023 struct TrackerBlackList { 0024 TrackerBlackList() = default; 0025 TrackerBlackList(const QString &company, const QString &pattern, const QString &url) 0026 : mCompanyName(company) 0027 , mCompanyUrl(url) 0028 , mPattern(pattern) 0029 { 0030 } 0031 0032 QString mCompanyName; 0033 QString mCompanyUrl; 0034 QString mPattern; 0035 }; 0036 0037 explicit BlockTrackingUrlInterceptor(QObject *parent = nullptr); 0038 ~BlockTrackingUrlInterceptor() override; 0039 [[nodiscard]] bool interceptRequest(QWebEngineUrlRequestInfo &info) override; 0040 0041 [[nodiscard]] bool enabledMailTrackingInterceptor() const; 0042 void setEnabledMailTrackingInterceptor(bool enabledMailTrackingInterceptor); 0043 0044 Q_SIGNALS: 0045 void trackingFound(const WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList &); 0046 0047 private: 0048 WEBENGINEVIEWER_NO_EXPORT void initializeList(); 0049 QList<TrackerBlackList> mBackList; 0050 bool mEnabledMailTrackingInterceptor = false; 0051 }; 0052 } 0053 Q_DECLARE_TYPEINFO(WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList, Q_RELOCATABLE_TYPE); 0054 Q_DECLARE_METATYPE(WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList) 0055 WEBENGINEVIEWER_EXPORT QDebug operator<<(QDebug d, const WebEngineViewer::BlockTrackingUrlInterceptor::TrackerBlackList &t);