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

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

Issue 2463133002: 📰 Make the MORE button more configurable (Closed)
Patch Set: rebase Created 4 years, 1 month 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/cards/SuggestionsCategoryInfo.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfo.java
index c5d86a1c20f1ebe01dbaffdd653963ff8a574004..aa2f90c04f29bd7d8c2ec1ccfb3579e9a3f15a2f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfo.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfo.java
@@ -36,11 +36,26 @@
private final int mCardLayout;
/**
- * Whether the category supports a "More" button. The button either triggers
- * a fixed action (like opening a native page) or, if there is no such fixed
- * action, it queries the provider for more suggestions.
+ * Whether the category supports a "More" action, that triggers fetching more suggestions for
+ * the category, while keeping the current ones.
+ * @see ActionItem
*/
- private final boolean mHasMoreButton;
+ private final boolean mHasMoreAction;
+
+ /**
+ * Whether the category supports a "Reload" action, that triggers fetching new suggestions to
+ * replace the current ones.
+ * @see ActionItem
+ */
+ private final boolean mHasReloadAction;
+
+ /**
+ * Whether the category supports a "ViewAll" action, that triggers displaying all the content
+ * related to the current categories.
+ * @see ActionItem
+ * @see #performViewAllAction(NewTabPageManager)
+ */
+ private final boolean mHasViewAllAction;
/** Whether this category should be shown if it offers no suggestions. */
private final boolean mShowIfEmpty;
@@ -51,12 +66,15 @@
private final String mNoSuggestionsMessage;
public SuggestionsCategoryInfo(@CategoryInt int category, String title,
- @ContentSuggestionsCardLayoutEnum int cardLayout, boolean hasMoreButton,
- boolean showIfEmpty, String noSuggestionsMessage) {
+ @ContentSuggestionsCardLayoutEnum int cardLayout, boolean hasMoreAction,
+ boolean hasReloadAction, boolean hasViewAllAction, boolean showIfEmpty,
+ String noSuggestionsMessage) {
mCategory = category;
mTitle = title;
mCardLayout = cardLayout;
- mHasMoreButton = hasMoreButton;
+ mHasMoreAction = hasMoreAction;
+ mHasReloadAction = hasReloadAction;
+ mHasViewAllAction = hasViewAllAction;
mShowIfEmpty = showIfEmpty;
mNoSuggestionsMessage = noSuggestionsMessage;
}
@@ -75,8 +93,22 @@ public int getCardLayout() {
return mCardLayout;
}
- public boolean hasMoreButton() {
- return mHasMoreButton;
+ public boolean hasMoreAction() {
+ return mHasMoreAction;
+ }
+
+ public boolean hasReloadAction() {
+ return mHasReloadAction;
+ }
+
+ public boolean hasViewAllAction() {
+ return mHasViewAllAction;
+ }
+
+ public boolean hasMoreButton(boolean hasSuggestions) {
+ if (hasViewAllAction()) return true;
+ if (hasSuggestions) return hasMoreAction();
+ return hasReloadAction();
}
public boolean showIfEmpty() {
@@ -92,11 +124,10 @@ public String getNoSuggestionsMessage() {
}
/**
- * Performs the appropriate action for the provided category, for the case where there are no
- * suggestions available. In general, this consists in navigating to the view showing all the
- * content, or fetching new content.
+ * Performs the View All action for the provided category, navigating navigating to the view
+ * showing all the content.
*/
- public void performEmptyStateAction(NewTabPageManager manager, NewTabPageAdapter adapter) {
+ public void performViewAllAction(NewTabPageManager manager) {
switch (mCategory) {
case KnownCategories.BOOKMARKS:
manager.navigateToBookmarks();
@@ -109,13 +140,9 @@ public void performEmptyStateAction(NewTabPageManager manager, NewTabPageAdapter
break;
case KnownCategories.PHYSICAL_WEB_PAGES:
case KnownCategories.RECENT_TABS:
- Log.wtf(TAG, "'Empty State' action called for unsupported category: %d", mCategory);
- break;
case KnownCategories.ARTICLES:
default:
- // TODO(dgn): For now, we assume any unknown sections are remote sections and just
- // reload all remote sections. crbug.com/656008
- adapter.reloadSnippets();
+ Log.wtf(TAG, "'Empty State' action called for unsupported category: %d", mCategory);
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698