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

Side by Side 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 based of twellington's most recent 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.Application; 9 import android.app.Application;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 * The UMA object used to report stats for this tab. Note that this may be n ull under certain 358 * The UMA object used to report stats for this tab. Note that this may be n ull under certain
359 * conditions, such as incognito mode. 359 * conditions, such as incognito mode.
360 */ 360 */
361 private TabUma mTabUma; 361 private TabUma mTabUma;
362 362
363 /** 363 /**
364 * Reference to the current sadTabView if one is defined. 364 * Reference to the current sadTabView if one is defined.
365 */ 365 */
366 private View mSadTabView; 366 private View mSadTabView;
367 367
368 /**
369 * Counts the number of successive refreshes on the sad tab page. The count is is reset after a
370 * successful page load.
371 */
372 private int mSadTabSuccessiveRefreshCounter;
373
368 private final int mDefaultThemeColor; 374 private final int mDefaultThemeColor;
369 private int mThemeColor; 375 private int mThemeColor;
370 376
371 private ChromeDownloadDelegate mDownloadDelegate; 377 private ChromeDownloadDelegate mDownloadDelegate;
372 378
373 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */ 379 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */
374 private boolean mIsAllowedToReturnToExternalApp; 380 private boolean mIsAllowedToReturnToExternalApp;
375 381
376 private class TabContentViewClient extends ContentViewClient { 382 private class TabContentViewClient extends ContentViewClient {
377 @Override 383 @Override
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 protected void didFinishPageLoad() { 1658 protected void didFinishPageLoad() {
1653 mIsBeingRestored = false; 1659 mIsBeingRestored = false;
1654 mIsTabStateDirty = true; 1660 mIsTabStateDirty = true;
1655 updateTitle(); 1661 updateTitle();
1656 updateFullscreenEnabledState(); 1662 updateFullscreenEnabledState();
1657 if (!isNativePage()) { 1663 if (!isNativePage()) {
1658 RecordHistogram.recordBooleanHistogram( 1664 RecordHistogram.recordBooleanHistogram(
1659 "Navigation.IsMobileOptimized", mContentViewCore.getIsMobile OptimizedHint()); 1665 "Navigation.IsMobileOptimized", mContentViewCore.getIsMobile OptimizedHint());
1660 } 1666 }
1661 1667
1668 // Reset the succressiveRefresh counter after successfully loading a pag e.
1669 mSadTabSuccessiveRefreshCounter = 0;
1670
1662 if (mTabUma != null) mTabUma.onPageLoadFinished(); 1671 if (mTabUma != null) mTabUma.onPageLoadFinished();
1663 1672
1664 for (TabObserver observer : mObservers) observer.onPageLoadFinished(this ); 1673 for (TabObserver observer : mObservers) observer.onPageLoadFinished(this );
1665 } 1674 }
1666 1675
1667 /** 1676 /**
1668 * Called when a page has failed loading. 1677 * Called when a page has failed loading.
1669 * @param errorCode The error code causing the page to fail loading. 1678 * @param errorCode The error code causing the page to fail loading.
1670 */ 1679 */
1671 protected void didFailPageLoad(int errorCode) { 1680 protected void didFailPageLoad(int errorCode) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 OnClickListener suggestionAction = new OnClickListener() { 1868 OnClickListener suggestionAction = new OnClickListener() {
1860 @Override 1869 @Override
1861 public void onClick(View view) { 1870 public void onClick(View view) {
1862 Activity activity = mWindowAndroid.getActivity().get(); 1871 Activity activity = mWindowAndroid.getActivity().get();
1863 assert activity != null; 1872 assert activity != null;
1864 HelpAndFeedback.getInstance(activity).show(activity, 1873 HelpAndFeedback.getInstance(activity).show(activity,
1865 activity.getString(R.string.help_context_sad_tab), 1874 activity.getString(R.string.help_context_sad_tab),
1866 Profile.getLastUsedProfile(), null); 1875 Profile.getLastUsedProfile(), null);
1867 } 1876 }
1868 }; 1877 };
1878
1879 // If the tab has crashed twice in a row change the button to "Send Feedback" and
1880 // change the onClickListener.
1881 final boolean showSendFeedbackButton = mSadTabSuccessiveRefreshCount er >= 1;
1869 OnClickListener reloadButtonAction = new OnClickListener() { 1882 OnClickListener reloadButtonAction = new OnClickListener() {
Theresa 2016/12/01 19:54:05 nit: since this may not be a reload anymore, the v
JJ 2016/12/01 22:39:40 Done.
1883
1870 @Override 1884 @Override
1871 public void onClick(View view) { 1885 public void onClick(View v) {
1872 reload(); 1886 if (showSendFeedbackButton) {
1887 getActivity().startHelpAndFeedback(Tab.this, "MobileSadT abFeedback");
1888 } else {
1889 reload();
1890 }
1873 } 1891 }
1874 }; 1892 };
1875 1893
1876 // Make sure we are not adding the "Aw, snap" view over an existing one. 1894 // Make sure we are not adding the "Aw, snap" view over an existing one.
1877 assert mSadTabView == null; 1895 assert mSadTabView == null;
1878 mSadTabView = SadTabViewFactory.createSadTabView(
1879 mThemedApplicationContext, suggestionAction, reloadButtonAct ion);
1880 1896
1897 mSadTabView = SadTabViewFactory.createSadTabView(mThemedApplicationC ontext,
1898 suggestionAction, reloadButtonAction, showSendFeedbackButton
1899 ? R.string.sad_tab_send_feedback_label : R.string.sa d_tab_reload_label);
1900 mSadTabSuccessiveRefreshCounter++;
1881 // Show the sad tab inside ContentView. 1901 // Show the sad tab inside ContentView.
1882 getContentViewCore().getContainerView().addView( 1902 getContentViewCore().getContainerView().addView(
1883 mSadTabView, new FrameLayout.LayoutParams( 1903 mSadTabView, new FrameLayout.LayoutParams(
1884 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT )); 1904 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ));
1885 notifyContentChanged(); 1905 notifyContentChanged();
1886 } 1906 }
1887 FullscreenManager fullscreenManager = getFullscreenManager(); 1907 FullscreenManager fullscreenManager = getFullscreenManager();
1888 if (fullscreenManager != null) { 1908 if (fullscreenManager != null) {
1889 fullscreenManager.setPositionsForTabToNonFullscreen(); 1909 fullscreenManager.setPositionsForTabToNonFullscreen();
1890 } 1910 }
1891 } 1911 }
1892 1912
1893 /** 1913 /**
1894 * Removes the sad tab view if present. 1914 * Removes the sad tab view if present.
1895 */ 1915 */
1896 private void removeSadTabIfPresent() { 1916 private void removeSadTabIfPresent() {
1897 if (isShowingSadTab()) { 1917 if (isShowingSadTab()) {
1898 getContentViewCore().getContainerView().removeView(mSadTabView); 1918 getContentViewCore().getContainerView().removeView(mSadTabView);
1899 notifyContentChanged(); 1919 notifyContentChanged();
1900 } 1920 }
1901 mSadTabView = null; 1921 mSadTabView = null;
1902 } 1922 }
1903 1923
1904 /** 1924 /**
1925 * Removes any existing sad tab view and shows it again. This "reloads" the tab without
1926 * going through any formal loading logic.
1927 */
1928 @VisibleForTesting
1929 public void reloadSadTabForTesting() {
1930 removeSadTabIfPresent();
1931 showSadTab();
1932 }
1933
1934 /**
1905 * @return Whether or not the sad tab is showing. 1935 * @return Whether or not the sad tab is showing.
1906 */ 1936 */
1907 public boolean isShowingSadTab() { 1937 public boolean isShowingSadTab() {
1908 return mSadTabView != null && getContentViewCore() != null 1938 return mSadTabView != null && getContentViewCore() != null
1909 && mSadTabView.getParent() == getContentViewCore().getContainerV iew(); 1939 && mSadTabView.getParent() == getContentViewCore().getContainerV iew();
1910 } 1940 }
1911 1941
1912 /** 1942 /**
1913 * Calls onContentChanged on all TabObservers and updates accessibility visi bility. 1943 * Calls onContentChanged on all TabObservers and updates accessibility visi bility.
1914 */ 1944 */
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 private native void nativeLoadOriginalImage(long nativeTabAndroid); 3198 private native void nativeLoadOriginalImage(long nativeTabAndroid);
3169 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); 3199 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable);
3170 private native boolean nativeIsOfflinePage(long nativeTabAndroid); 3200 private native boolean nativeIsOfflinePage(long nativeTabAndroid);
3171 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid); 3201 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid);
3172 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3202 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3173 InterceptNavigationDelegate delegate); 3203 InterceptNavigationDelegate delegate);
3174 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3204 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3175 TabContentManager tabContentManager); 3205 TabContentManager tabContentManager);
3176 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3206 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3177 } 3207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698