summaryrefslogtreecommitdiffstats
path: root/src/core/user_script_controller_host.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-06-24 14:02:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-07-01 11:50:03 +0200
commitaf855756f728f608f9e30ba3c334564229341da9 (patch)
tree7e8a65f6baad1d428f6485fea9f42ab38de684a2 /src/core/user_script_controller_host.cpp
parent6caa3a534567f487350f950dfc9bd937f4317746 (diff)
Switch UserScriptControllerHost to listen for created RenderViewHosts
AboutToNavigateRenderView(RenderViewHost*) no longer exists so we must listen to something else to know when to send the scripts to a new RenderView. Change-Id: Ic4d296feab722a149ba304b35bfceaf4952c136e Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'src/core/user_script_controller_host.cpp')
-rw-r--r--src/core/user_script_controller_host.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp
index 227a639b1..d57518275 100644
--- a/src/core/user_script_controller_host.cpp
+++ b/src/core/user_script_controller_host.cpp
@@ -52,9 +52,12 @@ namespace QtWebEngineCore {
class UserScriptControllerHost::WebContentsObserverHelper : public content::WebContentsObserver {
public:
WebContentsObserverHelper(UserScriptControllerHost *, content::WebContents *);
- virtual void AboutToNavigateRenderView(content::RenderViewHost* renderViewHost) Q_DECL_OVERRIDE;
- virtual void WebContentsDestroyed() Q_DECL_OVERRIDE;
+ // WebContentsObserver overrides:
+ void RenderViewCreated(content::RenderViewHost *renderViewHost) override;
+ void RenderViewHostChanged(content::RenderViewHost *oldHost, content::RenderViewHost *newHost) override;
+ void WebContentsDestroyed() override;
+
private:
UserScriptControllerHost *m_controllerHost;
};
@@ -65,13 +68,23 @@ UserScriptControllerHost::WebContentsObserverHelper::WebContentsObserverHelper(U
{
}
-void UserScriptControllerHost::WebContentsObserverHelper::AboutToNavigateRenderView(content::RenderViewHost *renderViewHost)
+void UserScriptControllerHost::WebContentsObserverHelper::RenderViewCreated(content::RenderViewHost *renderViewHost)
{
content::WebContents *contents = web_contents();
Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
renderViewHost->Send(new RenderViewObserverHelper_AddScript(renderViewHost->GetRoutingID(), script.data()));
}
+void UserScriptControllerHost::WebContentsObserverHelper::RenderViewHostChanged(content::RenderViewHost *oldHost,
+ content::RenderViewHost *newHost)
+{
+ oldHost->Send(new RenderViewObserverHelper_ClearScripts(oldHost->GetRoutingID()));
+
+ content::WebContents *contents = web_contents();
+ Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
+ newHost->Send(new RenderViewObserverHelper_AddScript(newHost->GetRoutingID(), script.data()));
+}
+
void UserScriptControllerHost::WebContentsObserverHelper::WebContentsDestroyed()
{
m_controllerHost->webContentsDestroyed(web_contents());