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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 2534333002: Show 'Send Feedback' button on the sad tab page on multiple failures (Closed)
Patch Set: Fixed code based off of twellington's comments. Created 4 years 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/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index fac8ca7c579645b06b5cf89d3461077a8bb47539..0efef8caa76bc719164ac2831857c1073f76939d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -365,6 +365,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
*/
private View mSadTabView;
+ /**
+ * Counts the number of successive refreshes on the sad tab page. The count is is reset after a
+ * successful page load.
+ */
+ private int mSadTabSuccessiveRefreshCounter;
+
private final int mDefaultThemeColor;
private int mThemeColor;
@@ -1659,6 +1665,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
"Navigation.IsMobileOptimized", mContentViewCore.getIsMobileOptimizedHint());
}
+ // Reset the succressiveRefresh counter after successfully loading a page.
+ mSadTabSuccessiveRefreshCounter = 0;
+
if (mTabUma != null) mTabUma.onPageLoadFinished();
for (TabObserver observer : mObservers) observer.onPageLoadFinished(this);
@@ -1866,18 +1875,29 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
Profile.getLastUsedProfile(), null);
}
};
- OnClickListener reloadButtonAction = new OnClickListener() {
+
+ // If the tab has crashed twice in a row change the button to "Send Feedback" and
+ // change the onClickListener.
+ final boolean showSendFeedbackButton = mSadTabSuccessiveRefreshCounter >= 1;
+ OnClickListener buttonAction = new OnClickListener() {
+
@Override
- public void onClick(View view) {
- reload();
+ public void onClick(View v) {
+ if (showSendFeedbackButton) {
+ getActivity().startHelpAndFeedback(Tab.this, "MobileSadTabFeedback");
+ } else {
+ reload();
+ }
}
};
// Make sure we are not adding the "Aw, snap" view over an existing one.
assert mSadTabView == null;
- mSadTabView = SadTabViewFactory.createSadTabView(
- mThemedApplicationContext, suggestionAction, reloadButtonAction);
+ mSadTabView = SadTabViewFactory.createSadTabView(mThemedApplicationContext,
+ suggestionAction, buttonAction, showSendFeedbackButton
+ ? R.string.sad_tab_send_feedback_label : R.string.sad_tab_reload_label);
+ mSadTabSuccessiveRefreshCounter++;
// Show the sad tab inside ContentView.
getContentViewCore().getContainerView().addView(
mSadTabView, new FrameLayout.LayoutParams(
@@ -1902,6 +1922,16 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
+ * Removes any existing sad tab view and shows it again. This "reloads" the tab without
+ * going through any formal loading logic.
+ */
+ @VisibleForTesting
+ public void reloadSadTabForTesting() {
+ removeSadTabIfPresent();
+ showSadTab();
+ }
+
+ /**
* @return Whether or not the sad tab is showing.
*/
public boolean isShowingSadTab() {

Powered by Google App Engine
This is Rietveld 408576698