Chromium Code Reviews| Index: chrome/browser/android/tab_android.cc |
| diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc |
| index 53a53b8906c7edec1bd8883d5fe86cba8281be5e..880cccb028c6f4724c6f2dc51f0fd6859ed797db 100644 |
| --- a/chrome/browser/android/tab_android.cc |
| +++ b/chrome/browser/android/tab_android.cc |
| @@ -12,6 +12,7 @@ |
| #include "cc/layers/layer.h" |
| #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
| #include "chrome/browser/android/compositor/tab_content_manager.h" |
| +#include "chrome/browser/android/hung_renderer_infobar_delegate.h" |
| #include "chrome/browser/android/metrics/uma_utils.h" |
| #include "chrome/browser/android/offline_pages/offline_page_bridge.h" |
| #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| @@ -55,6 +56,7 @@ |
| #include "components/bookmarks/managed/managed_bookmark_service.h" |
| #include "components/dom_distiller/core/url_utils.h" |
| #include "components/favicon/content/content_favicon_driver.h" |
| +#include "components/infobars/core/infobar.h" |
| #include "components/infobars/core/infobar_container.h" |
| #include "components/navigation_interception/intercept_navigation_delegate.h" |
| #include "components/navigation_interception/navigation_params.h" |
| @@ -101,6 +103,20 @@ const int kImageSearchThumbnailMinSize = 300 * 300; |
| const int kImageSearchThumbnailMaxWidth = 600; |
| const int kImageSearchThumbnailMaxHeight = 600; |
| +infobars::InfoBar* FindHungRendererInfoBar(InfoBarService* infobar_service) { |
| + for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| + infobars::InfoBar* infobar = infobar_service->infobar_at(i); |
| + if (!infobar || !infobar->delegate()) |
|
Peter Kasting
2015/09/01 22:24:05
These cannot be null.
jdduke (slow)
2015/09/02 00:04:01
Done.
|
| + continue; |
| + |
| + if (!infobar->delegate()->AsHungRendererInfoBarDelegate()) |
|
Peter Kasting
2015/09/01 22:24:05
Nit: Simpler:
if (infobar->delegate()->AsHung
jdduke (slow)
2015/09/02 00:04:01
Done.
|
| + continue; |
| + |
| + return infobar; |
| + } |
| + return nullptr; |
| +} |
| + |
| } // namespace |
| TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
| @@ -842,6 +858,37 @@ bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { |
| return HasPrerenderedUrl(gurl); |
| } |
| +void TabAndroid::OnRendererUnresponsive(JNIEnv* env, jobject obj) { |
| + InfoBarService* infobar_service = |
| + InfoBarService::FromWebContents(web_contents()); |
| + if (!infobar_service) |
|
Peter Kasting
2015/09/01 22:24:05
When will this be null? Either you shouldn't be c
jdduke (slow)
2015/09/02 00:04:01
I don't think it can be, I looked at some other co
|
| + return; |
| + |
| + DCHECK(!FindHungRendererInfoBar(infobar_service)); |
| + |
| + scoped_ptr<ConfirmInfoBarDelegate> delegate( |
| + new HungRendererInfoBarDelegate(web_contents())); |
| + infobar_service->AddInfoBar( |
| + infobar_service->CreateConfirmInfoBar(delegate.Pass())); |
| +} |
| + |
| +void TabAndroid::OnRendererResponsive(JNIEnv* env, jobject obj) { |
| + InfoBarService* infobar_service = |
| + InfoBarService::FromWebContents(web_contents()); |
| + if (!infobar_service) |
| + return; |
| + |
| + infobars::InfoBar* hung_renderer_infobar = |
| + FindHungRendererInfoBar(infobar_service); |
| + if (!hung_renderer_infobar) |
| + return; |
| + |
| + hung_renderer_infobar->delegate() |
| + ->AsHungRendererInfoBarDelegate() |
| + ->OnRendererResponsive(); |
| + infobar_service->RemoveInfoBar(hung_renderer_infobar); |
| +} |
| + |
| namespace { |
| class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { |