diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-06-10 15:06:03 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-06-13 15:08:35 +0000 |
commit | ca6762abde85fe3104ec4f064b85319474ba2deb (patch) | |
tree | 00302c342376f345b454c9e6cbb52ff40e45d9c4 /src/core/renderer | |
parent | c7aeb3b03ecce75c40d3f53352e8b7b3a4d6d050 (diff) |
Fix the IPC webChannelTransport not being available on reload
The gin JavaScript binging gets destroyed on page reload
after all references to it disappear from the previous document.
Do like other gin wrapper and reinstall the transport binding on
DidCreateDocumentElement, following how it's done by the
MojoBindingsController.
Task-number: QTBUG-53411
Change-Id: Ibcd9ef9dbedc5762d4f2210fd81f68e5b9127680
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/renderer')
-rw-r--r-- | src/core/renderer/web_channel_ipc_transport.cpp | 12 | ||||
-rw-r--r-- | src/core/renderer/web_channel_ipc_transport.h | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index d1e5f2245..6bbbe28bd 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -153,6 +153,8 @@ content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate) WebChannelIPCTransport::WebChannelIPCTransport(content::RenderView *renderView) : content::RenderViewObserver(renderView) + , m_installed(false) + , m_installedWorldId(0) { } @@ -162,6 +164,8 @@ void WebChannelIPCTransport::installWebChannel(uint worldId) if (!webView) return; WebChannelTransport::Install(webView->mainFrame(), worldId); + m_installed = true; + m_installedWorldId = worldId; } void WebChannelIPCTransport::uninstallWebChannel(uint worldId) @@ -170,6 +174,7 @@ void WebChannelIPCTransport::uninstallWebChannel(uint worldId) if (!webView) return; WebChannelTransport::Uninstall(webView->mainFrame(), worldId); + m_installed = false; } void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId) @@ -217,6 +222,13 @@ void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> & frame->callFunctionEvenIfScriptDisabled(callback, webChannelObjectValue->ToObject(), argc, argv); } +void WebChannelIPCTransport::DidCreateDocumentElement(blink::WebLocalFrame* frame) +{ + blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + if (m_installed && frame == main_frame) + WebChannelTransport::Install(frame, m_installedWorldId); +} + bool WebChannelIPCTransport::OnMessageReceived(const IPC::Message &message) { bool handled = true; diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h index f799f47af..fcee13bda 100644 --- a/src/core/renderer/web_channel_ipc_transport.h +++ b/src/core/renderer/web_channel_ipc_transport.h @@ -58,7 +58,11 @@ private: void dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId); void installWebChannel(uint worldId); void uninstallWebChannel(uint worldId); + virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) override; virtual bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE; + + bool m_installed; + uint m_installedWorldId; }; } // namespace |