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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java

Issue 2366443005: Remove local copies of SuggestionsSource. (Closed)
Patch Set: Added ntp OWNERS to ntp tests. Created 4 years, 3 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/ntp/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index fddc26ea35d472a32a9440fef3e929389722851d..2426ef7972aeec02e7ee04d14f418120ec759ac2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -15,6 +15,7 @@ import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
+import android.support.annotation.Nullable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v7.widget.RecyclerView;
@@ -50,8 +51,8 @@ import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter;
import org.chromium.chrome.browser.ntp.cards.NewTabPageItem;
import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView;
import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
-import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge;
import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig;
+import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource;
import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObserver;
import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.util.ViewUtils;
@@ -277,6 +278,13 @@ public class NewTabPageView extends FrameLayout
* Handles clicks on the "learn more" link in the footer.
*/
void onLearnMoreClicked();
+
+ /**
+ * Returns the SuggestionsSource or null if it doesn't exist. The SuggestionsSource is
+ * invalidated (has destroy() called) when the NewTabPage is destroyed so use this method
+ * instead of keeping your own reference.
+ */
+ @Nullable SuggestionsSource getSuggestionsSource();
}
/**
@@ -295,13 +303,12 @@ public class NewTabPageView extends FrameLayout
* @param searchProviderHasLogo Whether the search provider has a logo.
* @param snippetsBridge The optional bridge, that can be used to interact with the snippets.
*/
- public void initialize(NewTabPageManager manager, boolean searchProviderHasLogo,
- SnippetsBridge snippetsBridge) {
+ public void initialize(NewTabPageManager manager, boolean searchProviderHasLogo) {
mManager = manager;
mUiConfig = new UiConfig(this);
ViewStub stub = (ViewStub) findViewById(R.id.new_tab_page_layout_stub);
- mUseCardsUi = snippetsBridge != null;
+ mUseCardsUi = manager.getSuggestionsSource() != null;
if (mUseCardsUi) {
stub.setLayoutResource(R.layout.new_tab_page_recycler_view);
mRecyclerView = (NewTabPageRecyclerView) stub.inflate();
@@ -350,7 +357,7 @@ public class NewTabPageView extends FrameLayout
// Set up snippets
if (mUseCardsUi) {
mNewTabPageAdapter =
- new NewTabPageAdapter(mManager, mNewTabPageLayout, snippetsBridge, mUiConfig);
+ new NewTabPageAdapter(mManager, mNewTabPageLayout, mUiConfig);
mRecyclerView.setAdapter(mNewTabPageAdapter);
// Set up swipe-to-dismiss

Powered by Google App Engine
This is Rietveld 408576698