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

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

Issue 2844033002: 📰 Move metrics and scheduling events out of SnippetsBridge (Closed)
Patch Set: Created 3 years, 8 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 9d6131fe0de4499c6dcaf46354583cc7c9930f39..febc3c22eb5d5b4f5a5bdd8653f03a9d233f576e 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
@@ -40,13 +40,13 @@
*/
public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetContent {
private static SuggestionsSource sSuggestionsSourceForTesting;
- private static SuggestionsMetricsReporter sMetricsReporterForTesting;
+ private static SuggestionsEventReporter sMetricsReporterForTesting;
private final View mView;
private final FadingShadowView mShadowView;
private final SuggestionsRecyclerView mRecyclerView;
private final ContextMenuManager mContextMenuManager;
- private final SuggestionsUiDelegateImpl mSuggestionsManager;
+ private final SuggestionsUiDelegateImpl mSuggestionsUiDelegate;
private final TileGroup.Delegate mTileGroupDelegate;
public SuggestionsBottomSheetContent(final ChromeActivity activity, final BottomSheet sheet,
@@ -56,7 +56,7 @@ public SuggestionsBottomSheetContent(final ChromeActivity activity, final Bottom
new SuggestionsNavigationDelegateImpl(activity, profile, sheet, tabModelSelector);
mTileGroupDelegate = new TileGroupDelegateImpl(
activity, profile, tabModelSelector, navigationDelegate, snackbarManager);
- mSuggestionsManager = createSuggestionsDelegate(profile, navigationDelegate, sheet);
+ mSuggestionsUiDelegate = createSuggestionsDelegate(profile, navigationDelegate, sheet);
mView = LayoutInflater.from(activity).inflate(
R.layout.suggestions_bottom_sheet_content, null);
@@ -71,7 +71,7 @@ public void setTouchEnabled(boolean enabled) {
mContextMenuManager =
new ContextMenuManager(activity, navigationDelegate, touchEnabledDelegate);
activity.getWindowAndroid().addContextMenuCloseListener(mContextMenuManager);
- mSuggestionsManager.addDestructionObserver(new DestructionObserver() {
+ mSuggestionsUiDelegate.addDestructionObserver(new DestructionObserver() {
@Override
public void onDestroy() {
activity.getWindowAndroid().removeContextMenuCloseListener(mContextMenuManager);
@@ -80,12 +80,11 @@ public void onDestroy() {
UiConfig uiConfig = new UiConfig(mRecyclerView);
- final NewTabPageAdapter adapter = new NewTabPageAdapter(mSuggestionsManager,
+ final NewTabPageAdapter adapter = new NewTabPageAdapter(mSuggestionsUiDelegate,
/* aboveTheFoldView = */ null, uiConfig, OfflinePageBridge.getForProfile(profile),
mContextMenuManager, mTileGroupDelegate);
mRecyclerView.init(uiConfig, mContextMenuManager, adapter);
- final SuggestionsSource suggestionsSource = mSuggestionsManager.getSuggestionsSource();
activity.getBottomSheet().addObserver(new EmptyBottomSheetObserver() {
@Override
public void onSheetOpened() {
@@ -94,11 +93,11 @@ public void onSheetOpened() {
// TODO(https://crbug.com/689962) Ensure this call does not discard all suggestions
// every time the sheet is opened.
adapter.refreshSuggestions();
- suggestionsSource.onNtpInitialized();
+ mSuggestionsUiDelegate.getMetricsReporter().onSurfaceOpened();
}
});
adapter.refreshSuggestions();
- suggestionsSource.onNtpInitialized();
+ mSuggestionsUiDelegate.getMetricsReporter().onSurfaceOpened();
mShadowView = (FadingShadowView) mView.findViewById(R.id.shadow);
mShadowView.init(
@@ -150,7 +149,7 @@ public int getVerticalScrollOffset() {
@Override
public void destroy() {
- mSuggestionsManager.onDestroy();
+ mSuggestionsUiDelegate.onDestroy();
mTileGroupDelegate.destroy();
}
@@ -163,7 +162,7 @@ public static void setSuggestionsSourceForTesting(SuggestionsSource suggestionsS
sSuggestionsSourceForTesting = suggestionsSource;
}
- public static void setMetricsReporterForTesting(SuggestionsMetricsReporter metricsReporter) {
+ public static void setMetricsReporterForTesting(SuggestionsEventReporter metricsReporter) {
sMetricsReporterForTesting = metricsReporter;
}
@@ -171,7 +170,7 @@ private static SuggestionsUiDelegateImpl createSuggestionsDelegate(Profile profi
SuggestionsNavigationDelegate navigationDelegate, NativePageHost host) {
SnippetsBridge snippetsBridge = null;
SuggestionsSource suggestionsSource;
- SuggestionsMetricsReporter metricsReporter;
+ SuggestionsEventReporter metricsReporter;
if (sSuggestionsSourceForTesting == null) {
snippetsBridge = new SnippetsBridge(profile);
@@ -181,8 +180,7 @@ private static SuggestionsUiDelegateImpl createSuggestionsDelegate(Profile profi
}
if (sMetricsReporterForTesting == null) {
- if (snippetsBridge == null) snippetsBridge = new SnippetsBridge(profile);
- metricsReporter = snippetsBridge;
+ metricsReporter = new SuggestionsEventReporterBridge();
} else {
metricsReporter = sMetricsReporterForTesting;
}

Powered by Google App Engine
This is Rietveld 408576698