Make window aware of renderer crashes.

This commit is contained in:
Cheng Zhao 2013-06-10 20:42:10 +08:00
parent 25df5caf63
commit e440ad2714
3 changed files with 13 additions and 0 deletions

View file

@ -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)

View file

@ -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;

View file

@ -31,6 +31,9 @@ class NativeWindowObserver {
// Called when renderer recovers.
virtual void OnRendererResponsive() {}
// Called when renderer has crashed.
virtual void OnRendererCrashed() {}
};
} // namespace atom