mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
e6ab87ca73
due to iframe security policy and x-frame-option . the website online dictionary can not work in qt 5.15.2+ version. this is a workaround to pass through the restriction.
30 lines
865 B
C++
30 lines
865 B
C++
#include "weburlrequestinterceptor.h"
|
|
#include <QDebug>
|
|
#include "utils.hh"
|
|
#include "globalbroadcaster.h"
|
|
|
|
WebUrlRequestInterceptor::WebUrlRequestInterceptor(QObject *p)
|
|
:QWebEngineUrlRequestInterceptor(p)
|
|
{
|
|
|
|
}
|
|
void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info) {
|
|
if( Utils::isExternalLink( info.requestUrl() ) )
|
|
{
|
|
if(!GlobalBroadcaster::instance()-> existedInWhitelist(info.requestUrl().host()))
|
|
{
|
|
info.block( true );
|
|
}
|
|
}
|
|
|
|
if (QWebEngineUrlRequestInfo::NavigationTypeLink == info.navigationType() && info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {
|
|
//workaround to fix devtool "Switch devtool to chinese" interface was blocked.
|
|
if( info.requestUrl().scheme() == "devtools" )
|
|
{
|
|
return;
|
|
}
|
|
emit linkClicked( info.requestUrl() );
|
|
info.block(true);
|
|
}
|
|
}
|