From e440ad2714ba693c8c3ea103eac6485e0c8be466 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 10 Jun 2013 20:42:10 +0800 Subject: [PATCH] Make window aware of renderer crashes. --- browser/native_window.cc | 8 ++++++++ browser/native_window.h | 2 ++ browser/native_window_observer.h | 3 +++ 3 files changed, 13 insertions(+) diff --git a/browser/native_window.cc b/browser/native_window.cc index 62553eab89f7..fe00c100c9f6 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -15,6 +15,7 @@ #include "browser/atom_browser_main_parts.h" #include "browser/atom_javascript_dialog_manager.h" #include "browser/window_list.h" +#include "content/public/browser/invalidate_type.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -260,6 +261,13 @@ void NativeWindow::RendererResponsive(content::WebContents* source) { FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive()); } +void NativeWindow::NavigationStateChanged(const content::WebContents* source, + unsigned changed_flags) { + if (changed_flags == content::INVALIDATE_TYPE_TAB && + source->IsCrashed()) + FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed()); +} + bool NativeWindow::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(NativeWindow, message) diff --git a/browser/native_window.h b/browser/native_window.h index 56e138ea99fc..d14d70a593ef 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -149,6 +149,8 @@ class NativeWindow : public content::WebContentsDelegate, const content::WebContents* source) const OVERRIDE; virtual void RendererUnresponsive(content::WebContents* source) OVERRIDE; virtual void RendererResponsive(content::WebContents* source) OVERRIDE; + virtual void NavigationStateChanged(const content::WebContents* source, + unsigned changed_flags) OVERRIDE; // Implementations of content::WebContentsObserver. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; diff --git a/browser/native_window_observer.h b/browser/native_window_observer.h index dc274b0066fb..cffe39505ab5 100644 --- a/browser/native_window_observer.h +++ b/browser/native_window_observer.h @@ -31,6 +31,9 @@ class NativeWindowObserver { // Called when renderer recovers. virtual void OnRendererResponsive() {} + + // Called when renderer has crashed. + virtual void OnRendererCrashed() {} }; } // namespace atom