|
|
|
|
@ -73,8 +73,6 @@ WebPage::WebPage(QObject* parent) |
|
|
|
|
, m_blockAlerts(false) |
|
|
|
|
, m_secureStatus(false) |
|
|
|
|
{ |
|
|
|
|
setupWebChannelForUrl(QUrl()); |
|
|
|
|
|
|
|
|
|
connect(this, &QWebEnginePage::loadProgress, this, &WebPage::progress); |
|
|
|
|
connect(this, &QWebEnginePage::loadFinished, this, &WebPage::finished); |
|
|
|
|
connect(this, &QWebEnginePage::urlChanged, this, &WebPage::urlChanged); |
|
|
|
|
@ -109,6 +107,14 @@ WebPage::WebPage(QObject* parent) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Workaround for changing webchannel world inside acceptNavigationRequest not working
|
|
|
|
|
m_setupChannelTimer = new QTimer(this); |
|
|
|
|
m_setupChannelTimer->setSingleShot(true); |
|
|
|
|
m_setupChannelTimer->setInterval(100); |
|
|
|
|
connect(m_setupChannelTimer, &QTimer::timeout, this, [this]() { |
|
|
|
|
setupWebChannelForUrl(m_channelUrl); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WebPage::~WebPage() |
|
|
|
|
@ -377,10 +383,15 @@ void WebPage::setupWebChannelForUrl(const QUrl &url) |
|
|
|
|
channel = new QWebChannel(this); |
|
|
|
|
ExternalJsObject::setupWebChannel(channel, this); |
|
|
|
|
} |
|
|
|
|
int worldId = -1; |
|
|
|
|
if (url.scheme() == QL1S("falkon") || url.scheme() == QL1S("extension")) { |
|
|
|
|
setWebChannel(channel, UnsafeJsWorld); |
|
|
|
|
worldId = UnsafeJsWorld; |
|
|
|
|
} else { |
|
|
|
|
setWebChannel(channel, SafeJsWorld); |
|
|
|
|
worldId = SafeJsWorld; |
|
|
|
|
} |
|
|
|
|
if (worldId != m_channelWorldId) { |
|
|
|
|
m_channelWorldId = worldId; |
|
|
|
|
setWebChannel(channel, m_channelWorldId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -407,8 +418,8 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio |
|
|
|
|
const bool isWeb = url.scheme() == QL1S("http") || url.scheme() == QL1S("https") || url.scheme() == QL1S("file"); |
|
|
|
|
const bool globalJsEnabled = mApp->webSettings()->testAttribute(QWebEngineSettings::JavascriptEnabled); |
|
|
|
|
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, isWeb ? globalJsEnabled : true); |
|
|
|
|
|
|
|
|
|
setupWebChannelForUrl(url); |
|
|
|
|
m_channelUrl = url; |
|
|
|
|
m_setupChannelTimer->start(); |
|
|
|
|
} |
|
|
|
|
emit navigationRequestAccepted(url, type, isMainFrame); |
|
|
|
|
} |
|
|
|
|
|