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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetContent.java

Issue 2846233003: 📰 Record user actions on the NTP and Home sheet (Closed)
Patch Set: Address bauerb@'s comment Created 3 years, 7 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/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;
}

Powered by Google App Engine
This is Rietveld 408576698