Messagelib

networkurlinterceptormanager.cpp
1/*
2 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "networkurlinterceptormanager.h"
8#include "networkurlinterceptorpluginmanager.h"
9
10using namespace WebEngineViewer;
11
12class WebEngineViewer::NetworkUrlInterceptorManagerPrivate
13{
14public:
15 NetworkUrlInterceptorManagerPrivate(QWebEngineView *webEngine, KActionCollection *ac, NetworkUrlInterceptorManager *qq)
16 : q(qq)
17 {
18 createInterfaces(webEngine, ac);
19 }
20
21 [[nodiscard]] QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
22 void createInterfaces(QWebEngineView *webEngine, KActionCollection *ac);
24
25private:
27};
28
29QList<QAction *> NetworkUrlInterceptorManagerPrivate::interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const
30{
31 QList<QAction *> lstActions;
32 for (WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface : std::as_const(mListInterface)) {
33 lstActions.append(interface->interceptorUrlActions(result));
34 }
35 return lstActions;
36}
37
38void NetworkUrlInterceptorManagerPrivate::createInterfaces(QWebEngineView *webEngine, KActionCollection *ac)
39{
40 const auto pluginsList = NetworkUrlInterceptorPluginManager::self()->pluginsList();
41 for (NetworkPluginUrlInterceptor *plugin : pluginsList) {
42 if (plugin->isEnabled()) {
43 WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface = plugin->createInterface(webEngine, q);
44 interface->createActions(ac);
45 mListInterface.append(interface);
46 }
47 }
48}
49
50NetworkUrlInterceptorManager::NetworkUrlInterceptorManager(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent)
51 : QObject(parent)
52 , d(new NetworkUrlInterceptorManagerPrivate(webEngine, ac, this))
53{
54}
55
56NetworkUrlInterceptorManager::~NetworkUrlInterceptorManager() = default;
57
58QList<WebEngineViewer::NetworkPluginUrlInterceptorInterface *> NetworkUrlInterceptorManager::interfaceList() const
59{
60 return d->mListInterface;
61}
62
63QList<QAction *> NetworkUrlInterceptorManager::interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const
64{
65 return d->interceptorUrlActions(result);
66}
67
68#include "moc_networkurlinterceptormanager.cpp"
The WebHitTestResult class.
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.