summaryrefslogtreecommitdiffstats
path: root/src/core/renderer_host/web_channel_ipc_transport_host.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/renderer_host/web_channel_ipc_transport_host.cpp')
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
index 9758f73bf..9ed3749ad 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -54,11 +54,6 @@
namespace QtWebEngineCore {
-enum {
- // sizeof(QJsonPrivate::Header) + sizeof(QJsonPrivate::Base)
- MinimumBinaryJsonSize = 8 + 12
-};
-
Q_LOGGING_CATEGORY(log, "qt.webengine.webchanneltransport")
inline QDebug operator<<(QDebug stream, content::RenderFrameHost *frame)
@@ -66,7 +61,7 @@ inline QDebug operator<<(QDebug stream, content::RenderFrameHost *frame)
return stream << "frame " << frame->GetRoutingID() << " in process " << frame->GetProcess()->GetID();
}
-template <class T>
+template<class T>
inline QDebug operator<<(QDebug stream, const base::Optional<T> &opt)
{
if (opt)
@@ -79,7 +74,7 @@ WebChannelIPCTransportHost::WebChannelIPCTransportHost(content::WebContents *con
: QWebChannelAbstractTransport(parent)
, content::WebContentsObserver(contents)
, m_worldId(worldId)
- , m_binding(contents, this)
+ , m_receiver(contents, this)
{
for (content::RenderFrameHost *frame : contents->GetAllFrames())
setWorldId(frame, worldId);
@@ -101,7 +96,7 @@ void WebChannelIPCTransportHost::sendMessage(const QJsonObject &message)
int size = 0;
const char *rawData = doc.rawData(&size);
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
- qtwebchannel::mojom::WebChannelTransportRenderAssociatedPtr webChannelTransport;
+ mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> webChannelTransport;
frame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
qCDebug(log).nospace() << "sending webchannel message to " << frame << ": " << doc;
webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size), m_worldId);
@@ -121,7 +116,7 @@ void WebChannelIPCTransportHost::setWorldId(content::RenderFrameHost *frame, uin
if (!frame->IsRenderFrameLive())
return;
qCDebug(log).nospace() << "sending setWorldId(" << worldId << ") message to " << frame;
- qtwebchannel::mojom::WebChannelTransportRenderAssociatedPtr webChannelTransport;
+ mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> webChannelTransport;
frame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
webChannelTransport->SetWorldId(worldId);
}
@@ -131,7 +126,7 @@ void WebChannelIPCTransportHost::resetWorldId()
for (content::RenderFrameHost *frame : web_contents()->GetAllFrames()) {
if (!frame->IsRenderFrameLive())
return;
- qtwebchannel::mojom::WebChannelTransportRenderAssociatedPtr webChannelTransport;
+ mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> webChannelTransport;
frame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
webChannelTransport->ResetWorldId();
}
@@ -141,16 +136,11 @@ void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector<uin
{
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
- if (m_binding.GetCurrentTargetFrame() != frame) {
+ if (m_receiver.GetCurrentTargetFrame() != frame) {
return;
}
- QJsonDocument doc;
- // QJsonDocument::fromRawData does not check the length before it starts
- // parsing the QJsonPrivate::Header and QJsonPrivate::Base structures.
- if (binaryJson.size() >= MinimumBinaryJsonSize)
- doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()),
- binaryJson.size());
+ QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), binaryJson.size());
if (!doc.isObject()) {
qCCritical(log).nospace() << "received invalid webchannel message from " << frame;