diff --git a/browser/native_window.cc b/browser/native_window.cc index b7bed1717961..391e64719996 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -6,6 +6,7 @@ #include +#include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "brightray/browser/inspectable_web_contents.h" @@ -39,6 +40,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, base::DictionaryValue* options) : content::WebContentsObserver(web_contents), is_closed_(false), + not_responding_(false), inspectable_web_contents_( brightray::InspectableWebContents::Create(web_contents)) { web_contents->SetDelegate(this); @@ -275,10 +277,16 @@ bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const { } void NativeWindow::RendererUnresponsive(content::WebContents* source) { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererUnresponsive()); + not_responding_ = true; + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&NativeWindow::RendererUnresponsiveDelayed, + base::Unretained(this)), + base::TimeDelta::FromSeconds(1)); } void NativeWindow::RendererResponsive(content::WebContents* source) { + not_responding_ = false; FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive()); } @@ -297,6 +305,13 @@ void NativeWindow::RenderViewGone(base::TerminationStatus status) { FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererCrashed()); } +void NativeWindow::RendererUnresponsiveDelayed() { + if (not_responding_) + FOR_EACH_OBSERVER(NativeWindowObserver, + observers_, + OnRendererUnresponsive()); +} + void NativeWindow::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/browser/native_window.h b/browser/native_window.h index c6a6c8401d26..762920cfd082 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -163,6 +163,8 @@ class NativeWindow : public content::WebContentsDelegate, const content::NotificationDetails& details) OVERRIDE; private: + void RendererUnresponsiveDelayed(); + void OnRendererMessage(const std::string& channel, const base::ListValue& args); @@ -176,8 +178,12 @@ class NativeWindow : public content::WebContentsDelegate, // Observers of this window. ObserverList observers_; + // The windows has been closed. bool is_closed_; + // The window is not responding. + bool not_responding_; + scoped_ptr dialog_manager_; scoped_ptr inspectable_web_contents_;