Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: chrome/browser/android/tab_android.cc

Issue 1299513002: [Android] Add support for a hung renderer dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index ab3a25c7059ce91a032b1e5667febeb75dcfae2f..2378d68ec57e0171d8d260e29b6b9107398e9fdd 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/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
@@ -53,6 +54,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"
@@ -124,7 +126,8 @@ TabAndroid::TabAndroid(JNIEnv* env, jobject obj)
: weak_java_tab_(env, obj),
content_layer_(cc::Layer::Create(content::Compositor::LayerSettings())),
tab_content_manager_(NULL),
- synced_tab_delegate_(new browser_sync::SyncedTabDelegateAndroid(this)) {
+ synced_tab_delegate_(new browser_sync::SyncedTabDelegateAndroid(this)),
+ hung_renderer_infobar_(nullptr) {
Java_Tab_setNativePtr(env, obj, reinterpret_cast<intptr_t>(this));
}
@@ -391,6 +394,11 @@ void TabAndroid::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
bool icon_url_changed) {
}
+void TabAndroid::OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) {
+ if (hung_renderer_infobar_ && hung_renderer_infobar_ == infobar)
+ hung_renderer_infobar_ = nullptr;
+}
+
void TabAndroid::Destroy(JNIEnv* env, jobject obj) {
delete this;
}
@@ -453,6 +461,11 @@ void TabAndroid::InitWebContents(JNIEnv* env,
if (instant_service)
instant_service->AddObserver(this);
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents());
+ if (infobar_service)
+ infobar_service->AddObserver(this);
+
content_layer_->InsertChild(content_view_core->GetLayer(), 0);
}
@@ -486,6 +499,11 @@ void TabAndroid::DestroyWebContents(JNIEnv* env,
if (instant_service)
instant_service->RemoveObserver(this);
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents());
+ if (infobar_service)
+ infobar_service->RemoveObserver(this);
+
web_contents()->SetDelegate(NULL);
if (delete_native) {
@@ -794,6 +812,31 @@ bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) {
return HasPrerenderedUrl(gurl);
}
+void TabAndroid::ShowHungRendererInfoBar(JNIEnv* env, jobject obj) {
+ DCHECK(!hung_renderer_infobar_);
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents());
+ if (!infobar_service)
+ return;
+
+ scoped_ptr<ConfirmInfoBarDelegate> delegate(
+ new HungRendererInfoBarDelegate(web_contents()));
+ hung_renderer_infobar_ = infobar_service->AddInfoBar(
+ infobar_service->CreateConfirmInfoBar(delegate.Pass()));
+}
+
+void TabAndroid::DismissHungRendererInfoBar(JNIEnv* env, jobject obj) {
+ if (!hung_renderer_infobar_)
gone 2015/08/18 20:45:17 instead of hanging onto the infobar*, would it mak
jdduke (slow) 2015/08/21 21:18:30 How would we know we've found it while iterating i
gone 2015/08/21 21:39:30 I think it'd be a little better safety-wise to add
+ return;
+
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents());
+ if (!infobar_service)
+ return;
+
+ infobar_service->RemoveInfoBar(hung_renderer_infobar_);
+}
+
namespace {
class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {

Powered by Google App Engine
This is Rietveld 408576698