Messagelib

webenginenavigationrequestinterceptor.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 "webenginenavigationrequestinterceptor.h"
8#include "webenginepage.h"
9using namespace WebEngineViewer;
10
11WebEngineNavigationRequestInterceptor::WebEngineNavigationRequestInterceptor(QWebEnginePage *page)
12 : QWebEnginePage(page)
13 , mTargetPage(page)
14{
15}
16
17WebEngineNavigationRequestInterceptor::~WebEngineNavigationRequestInterceptor() = default;
18
19bool WebEngineNavigationRequestInterceptor::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
20{
21 Q_UNUSED(isMainFrame)
22 auto page = qobject_cast<WebEnginePage *>(mTargetPage);
23 if (type == NavigationTypeLinkClicked && page) {
24 Q_EMIT page->urlClicked(url);
25 return false;
26 }
27 return false;
28}
29
30#include "moc_webenginenavigationrequestinterceptor.cpp"
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.