File indexing completed on 2025-01-26 04:57:24

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include "webengineviewer_export.h"
0009 #include <WebEngineViewer/NetworkPluginUrlInterceptorInterface>
0010 namespace WebEngineViewer
0011 {
0012 class WEBENGINEVIEWER_EXPORT LoadExternalReferencesUrlInterceptor : public WebEngineViewer::NetworkPluginUrlInterceptorInterface
0013 {
0014     Q_OBJECT
0015 public:
0016     explicit LoadExternalReferencesUrlInterceptor(QObject *parent = nullptr);
0017     ~LoadExternalReferencesUrlInterceptor() override;
0018 
0019     [[nodiscard]] bool interceptRequest(QWebEngineUrlRequestInfo &info) override;
0020     void setAllowExternalContent(bool b);
0021     [[nodiscard]] bool allowExternalContent() const;
0022 
0023 Q_SIGNALS:
0024     void urlBlocked(const QUrl &url);
0025 
0026 protected:
0027     [[nodiscard]] virtual bool urlIsAuthorized(const QUrl &requestedUrl);
0028     [[nodiscard]] virtual bool urlIsBlocked(const QUrl &requestedUrl);
0029 
0030 private:
0031     bool mAllowLoadExternalReference = false;
0032 };
0033 }