Commit 5bdd4138 authored by Adam Kallai's avatar Adam Kallai Committed by Andras Becsi
Browse files

Fix assignment of observer to RenderProcessHost.


By default Chromium uses the process-per-site-instance process model.
Therefore if there is a renderProcessHost which is already observed
we do not need to add another observer for user scripts.

Change-Id: Ic0c2104ebbefb2b8427c43c4c665d96b5a991ba1
Reviewed-by: default avatarAndras Becsi <andras.becsi@theqtcompany.com>
Showing with 6 additions and 3 deletions
...@@ -332,7 +332,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* ...@@ -332,7 +332,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
{ {
// FIXME: Add a settings variable to enable/disable the file scheme. // FIXME: Add a settings variable to enable/disable the file scheme.
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), url::kFileScheme); content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), url::kFileScheme);
static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userScriptController()->renderProcessHostCreated(host); static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userScriptController()->renderProcessStartedWithHost(host);
} }
void ContentBrowserClientQt::ResourceDispatcherHostCreated() void ContentBrowserClientQt::ResourceDispatcherHostCreated()
......
...@@ -186,8 +186,11 @@ void UserScriptControllerHost::reserve(WebContentsAdapter *adapter, int count) ...@@ -186,8 +186,11 @@ void UserScriptControllerHost::reserve(WebContentsAdapter *adapter, int count)
m_perContentsScripts[adapter->webContents()].reserve(count); m_perContentsScripts[adapter->webContents()].reserve(count);
} }
void UserScriptControllerHost::renderProcessHostCreated(content::RenderProcessHost *renderer) void UserScriptControllerHost::renderProcessStartedWithHost(content::RenderProcessHost *renderer)
{ {
if (m_observedProcesses.contains(renderer))
return;
if (m_renderProcessObserver.isNull()) if (m_renderProcessObserver.isNull())
m_renderProcessObserver.reset(new RenderProcessObserverHelper(this)); m_renderProcessObserver.reset(new RenderProcessObserverHelper(this));
renderer->AddObserver(m_renderProcessObserver.data()); renderer->AddObserver(m_renderProcessObserver.data());
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void reserve(WebContentsAdapter *adapter, int count); void reserve(WebContentsAdapter *adapter, int count);
const QSet<UserScript> registeredScripts(WebContentsAdapter *adapter) const; const QSet<UserScript> registeredScripts(WebContentsAdapter *adapter) const;
void renderProcessHostCreated(content::RenderProcessHost *renderer); void renderProcessStartedWithHost(content::RenderProcessHost *renderer);
private: private:
Q_DISABLE_COPY(UserScriptControllerHost) Q_DISABLE_COPY(UserScriptControllerHost)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment