| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SectionList.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SectionList.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SectionList.java
|
| index a0190f41f7137b9deb110cbb95d81fa366ea2421..090c9c002bc2be31f348b62f735b4a893b05afcf 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SectionList.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SectionList.java
|
| @@ -6,7 +6,6 @@
|
|
|
| import org.chromium.base.Log;
|
| import org.chromium.base.VisibleForTesting;
|
| -import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
|
| import org.chromium.chrome.browser.ntp.snippets.CategoryInt;
|
| import org.chromium.chrome.browser.ntp.snippets.CategoryStatus;
|
| import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnum;
|
| @@ -15,6 +14,7 @@
|
| import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig;
|
| import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource;
|
| import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
|
| +import org.chromium.chrome.browser.suggestions.ContentSuggestionsManager;
|
|
|
| import java.util.LinkedHashMap;
|
| import java.util.List;
|
| @@ -30,12 +30,12 @@
|
|
|
| /** Maps suggestion categories to sections, with stable iteration ordering. */
|
| private final Map<Integer, SuggestionsSection> mSections = new LinkedHashMap<>();
|
| - private final NewTabPageManager mNewTabPageManager;
|
| + private final ContentSuggestionsManager mSuggestionsManager;
|
| private final OfflinePageBridge mOfflinePageBridge;
|
|
|
| - public SectionList(NewTabPageManager newTabPageManager, OfflinePageBridge offlinePageBridge) {
|
| - mNewTabPageManager = newTabPageManager;
|
| - mNewTabPageManager.getSuggestionsSource().setObserver(this);
|
| + public SectionList(ContentSuggestionsManager manager, OfflinePageBridge offlinePageBridge) {
|
| + mSuggestionsManager = manager;
|
| + mSuggestionsManager.getSuggestionsSource().setObserver(this);
|
| mOfflinePageBridge = offlinePageBridge;
|
| resetSections(/* alwaysAllowEmptySections = */ false);
|
| }
|
| @@ -48,7 +48,7 @@ public SectionList(NewTabPageManager newTabPageManager, OfflinePageBridge offlin
|
| public void resetSections(boolean alwaysAllowEmptySections) {
|
| removeAllSections();
|
|
|
| - SuggestionsSource suggestionsSource = mNewTabPageManager.getSuggestionsSource();
|
| + SuggestionsSource suggestionsSource = mSuggestionsManager.getSuggestionsSource();
|
| int[] categories = suggestionsSource.getCategories();
|
| int[] suggestionsPerCategory = new int[categories.length];
|
| int i = 0;
|
| @@ -63,7 +63,7 @@ public void resetSections(boolean alwaysAllowEmptySections) {
|
| resetSection(category, categoryStatus, alwaysAllowEmptySections);
|
| }
|
|
|
| - mNewTabPageManager.trackSnippetsPageImpression(categories, suggestionsPerCategory);
|
| + mSuggestionsManager.trackSnippetsPageImpression(categories, suggestionsPerCategory);
|
| }
|
|
|
| /**
|
| @@ -78,7 +78,7 @@ public void resetSections(boolean alwaysAllowEmptySections) {
|
| */
|
| private int resetSection(@CategoryInt int category, @CategoryStatusEnum int categoryStatus,
|
| boolean alwaysAllowEmptySections) {
|
| - SuggestionsSource suggestionsSource = mNewTabPageManager.getSuggestionsSource();
|
| + SuggestionsSource suggestionsSource = mSuggestionsManager.getSuggestionsSource();
|
| List<SnippetArticle> suggestions = suggestionsSource.getSuggestionsForCategory(category);
|
| SuggestionsCategoryInfo info = suggestionsSource.getCategoryInfo(category);
|
|
|
| @@ -92,7 +92,7 @@ private int resetSection(@CategoryInt int category, @CategoryStatusEnum int cate
|
|
|
| // Create the section if needed.
|
| if (section == null) {
|
| - section = new SuggestionsSection(this, mNewTabPageManager, mOfflinePageBridge, info);
|
| + section = new SuggestionsSection(this, mSuggestionsManager, mOfflinePageBridge, info);
|
| mSections.put(category, section);
|
| addChild(section);
|
| }
|
| @@ -106,7 +106,7 @@ private int resetSection(@CategoryInt int category, @CategoryStatusEnum int cate
|
| @Override
|
| public void onNewSuggestions(@CategoryInt int category) {
|
| @CategoryStatusEnum
|
| - int status = mNewTabPageManager.getSuggestionsSource().getCategoryStatus(category);
|
| + int status = mSuggestionsManager.getSuggestionsSource().getCategoryStatus(category);
|
|
|
| if (!canLoadSuggestions(category, status)) return;
|
|
|
| @@ -114,7 +114,7 @@ public void onNewSuggestions(@CategoryInt int category) {
|
| if (mSections.get(category).hasSuggestions()) return;
|
|
|
| List<SnippetArticle> suggestions =
|
| - mNewTabPageManager.getSuggestionsSource().getSuggestionsForCategory(category);
|
| + mSuggestionsManager.getSuggestionsSource().getSuggestionsForCategory(category);
|
|
|
| Log.d(TAG, "Received %d new suggestions for category %d.", suggestions.size(), category);
|
|
|
| @@ -127,7 +127,7 @@ public void onNewSuggestions(@CategoryInt int category) {
|
| @Override
|
| public void onMoreSuggestions(@CategoryInt int category, List<SnippetArticle> suggestions) {
|
| @CategoryStatusEnum
|
| - int status = mNewTabPageManager.getSuggestionsSource().getCategoryStatus(category);
|
| + int status = mSuggestionsManager.getSuggestionsSource().getCategoryStatus(category);
|
| if (!canLoadSuggestions(category, status)) return;
|
|
|
| setSuggestions(category, suggestions, status);
|
| @@ -212,7 +212,7 @@ private boolean canLoadSuggestions(@CategoryInt int category, @CategoryStatusEnu
|
| public void dismissSection(SuggestionsSection section) {
|
| assert SnippetsConfig.isSectionDismissalEnabled();
|
|
|
| - mNewTabPageManager.getSuggestionsSource().dismissCategory(section.getCategory());
|
| + mSuggestionsManager.getSuggestionsSource().dismissCategory(section.getCategory());
|
| removeSection(section);
|
| }
|
|
|
| @@ -231,9 +231,9 @@ private void removeAllSections() {
|
| * Restores any sections that have been dismissed and triggers a new fetch.
|
| */
|
| public void restoreDismissedSections() {
|
| - mNewTabPageManager.getSuggestionsSource().restoreDismissedCategories();
|
| + mSuggestionsManager.getSuggestionsSource().restoreDismissedCategories();
|
| resetSections(/* allowEmptySections = */ true);
|
| - mNewTabPageManager.getSuggestionsSource().fetchRemoteSuggestions();
|
| + mSuggestionsManager.getSuggestionsSource().fetchRemoteSuggestions();
|
| }
|
|
|
| /**
|
|
|