From 60319f0ceae72c288c1a304f189bb915bf317682 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 11 Jan 2013 23:20:13 +0000 Subject: [PATCH] Avoid re-registration of a RenderViewHost with NotificationRegistrar which can occur after a renderer crashes. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@980 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/browser/browser_host_impl.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 4616b7db6..0fe060e23 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -1647,14 +1647,23 @@ void CefBrowserHostImpl::RenderViewCreated( devtools_delegate->GetDevToolsURL(render_view_host, false); } - registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, - content::Source(render_view_host)); + // May be already registered if the renderer crashed previously. + if (!registrar_->IsRegistered( + this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host))) { + registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host)); + } } void CefBrowserHostImpl::RenderViewDeleted( content::RenderViewHost* render_view_host) { - registrar_->Remove(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, - content::Source(render_view_host)); + if (registrar_->IsRegistered( + this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host))) { + registrar_->Remove(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host)); + } } void CefBrowserHostImpl::RenderViewReady() {