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

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "webenginenavigationrequestinterceptor.h"
0008 #include "webenginepage.h"
0009 using namespace WebEngineViewer;
0010 
0011 WebEngineNavigationRequestInterceptor::WebEngineNavigationRequestInterceptor(QWebEnginePage *page)
0012     : QWebEnginePage(page)
0013     , mTargetPage(page)
0014 {
0015 }
0016 
0017 WebEngineNavigationRequestInterceptor::~WebEngineNavigationRequestInterceptor() = default;
0018 
0019 bool WebEngineNavigationRequestInterceptor::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
0020 {
0021     Q_UNUSED(isMainFrame)
0022     auto page = qobject_cast<WebEnginePage *>(mTargetPage);
0023     if (type == NavigationTypeLinkClicked && page) {
0024         Q_EMIT page->urlClicked(url);
0025         return false;
0026     }
0027     return false;
0028 }
0029 
0030 #include "moc_webenginenavigationrequestinterceptor.cpp"