Index: chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java |
index 9fd7a66cd553682937ae7d8fcb75cb6fea6ab811..6c10e4a5fedfaf00ce12fb41ee3166fbde1ed397 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java |
@@ -35,9 +35,6 @@ |
/** |
* Provides content to be displayed inside of the Home tab of bottom sheet. |
- * |
- * TODO(dgn): If the bottom sheet view is not recreated across tab changes, it will have to be |
- * notified of it, at least when it is pulled up on the new tab. |
*/ |
public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetContent { |
private static SuggestionsSource sSuggestionsSourceForTesting; |
@@ -92,17 +89,19 @@ public void onDestroy() { |
@Override |
public void onSheetOpened() { |
mRecyclerView.scrollToPosition(0); |
+ prepareSuggestionsForReveal(adapter); |
+ } |
- // TODO(https://crbug.com/689962) Ensure this call does not discard all suggestions |
- // every time the sheet is opened. |
- adapter.refreshSuggestions(); |
- mSuggestionsUiDelegate.getEventReporter().onSurfaceOpened(); |
+ @Override |
+ public void onSheetClosed() { |
+ SuggestionsMetrics.recordSurfaceHidden(); |
} |
+ |
}; |
mBottomSheet = activity.getBottomSheet(); |
mBottomSheet.addObserver(mBottomSheetObserver); |
- adapter.refreshSuggestions(); |
- mSuggestionsUiDelegate.getEventReporter().onSurfaceOpened(); |
+ |
+ if (mBottomSheet.isSheetOpen()) prepareSuggestionsForReveal(adapter); |
mShadowView = (FadingShadowView) mView.findViewById(R.id.shadow); |
mShadowView.init( |
@@ -164,6 +163,13 @@ public int getType() { |
return BottomSheetContentController.TYPE_SUGGESTIONS; |
} |
+ /** Called when the UI is revlealed, prepares the list of suggestions. */ |
+ private void prepareSuggestionsForReveal(NewTabPageAdapter adapter) { |
+ adapter.refreshSuggestions(); |
+ mSuggestionsUiDelegate.getEventReporter().onSurfaceOpened(); |
+ SuggestionsMetrics.recordSurfaceVisible(); |
+ } |
+ |
public static void setSuggestionsSourceForTesting(SuggestionsSource suggestionsSource) { |
sSuggestionsSourceForTesting = suggestionsSource; |
} |