| 37 | } |
| 38 | |
| 39 | void BrowserScripts::initWebChannelScript() |
| 40 | { |
| 41 | QString webChannelJS; |
| 42 | QFile webChannelFile(QLatin1String(":/qtwebchannel/qwebchannel.js")); |
| 43 | if (webChannelFile.open(QIODevice::ReadOnly)) |
| 44 | webChannelJS = webChannelFile.readAll(); |
| 45 | webChannelFile.close(); |
| 46 | |
| 47 | QString webChannelSetup; |
| 48 | QFile webChannelSetupFile(QLatin1String(":/WebChannelSetup.js")); |
| 49 | if (webChannelSetupFile.open(QIODevice::ReadOnly)) |
| 50 | { |
| 51 | webChannelSetup = webChannelSetupFile.readAll(); |
| 52 | webChannelSetup = webChannelSetup.arg(webChannelJS); |
| 53 | } |
| 54 | webChannelSetupFile.close(); |
| 55 | |
| 56 | QWebEngineScript webChannelScript; |
| 57 | webChannelScript.setInjectionPoint(QWebEngineScript::DocumentCreation); |
| 58 | webChannelScript.setName(QLatin1String("viper-web-channel")); |
| 59 | webChannelScript.setRunsOnSubFrames(true); |
| 60 | webChannelScript.setWorldId(QWebEngineScript::ApplicationWorld); |
| 61 | webChannelScript.setSourceCode(webChannelSetup); |
| 62 | |
| 63 | m_globalScripts.push_back(webChannelScript); |
| 64 | } |
| 65 | |
| 66 | void BrowserScripts::initFaviconScript() |
| 67 | { |