diff options
author | Adam Kallai <kadam@inf.u-szeged.hu> | 2015-04-20 01:50:45 -0700 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-04-21 12:26:07 +0000 |
commit | 5bdd41388fab6486061d1bd25be132533d05d711 (patch) | |
tree | 8b59bee5e8f277e0d3fec5026484e5bd267d5cfd | |
parent | 7ff8dc3dbfe4effce66bee8b7b59284f4b2f95be (diff) |
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: Andras Becsi <andras.becsi@theqtcompany.com>
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/user_script_controller_host.cpp | 5 | ||||
-rw-r--r-- | src/core/user_script_controller_host.h | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index a6a133271..60ca493ca 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -332,7 +332,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* { // FIXME: Add a settings variable to enable/disable the file scheme. 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() diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp index 2f4a55c27..227a639b1 100644 --- a/src/core/user_script_controller_host.cpp +++ b/src/core/user_script_controller_host.cpp @@ -186,8 +186,11 @@ void UserScriptControllerHost::reserve(WebContentsAdapter *adapter, int 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()) m_renderProcessObserver.reset(new RenderProcessObserverHelper(this)); renderer->AddObserver(m_renderProcessObserver.data()); diff --git a/src/core/user_script_controller_host.h b/src/core/user_script_controller_host.h index 293b5d2dd..49c96b333 100644 --- a/src/core/user_script_controller_host.h +++ b/src/core/user_script_controller_host.h @@ -66,7 +66,7 @@ public: void reserve(WebContentsAdapter *adapter, int count); const QSet<UserScript> registeredScripts(WebContentsAdapter *adapter) const; - void renderProcessHostCreated(content::RenderProcessHost *renderer); + void renderProcessStartedWithHost(content::RenderProcessHost *renderer); private: Q_DISABLE_COPY(UserScriptControllerHost) |