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

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

Issue 2158883002: Change NTPSnippetsBridge to read from ContentSuggestionsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offlinepagesprovider
Patch Set: Marc's comments Created 4 years, 5 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/cards/StatusListItem.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java
index 68a8e9457b33ece90f5fc5b71c2d1b6982b7ed21..9205ff253fcfde6b9e8d017cf66b36f68edb2f9a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/StatusListItem.java
@@ -13,7 +13,7 @@ import android.widget.TextView;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
-import org.chromium.chrome.browser.ntp.snippets.DisabledReason;
+import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCategoryStatus;
import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.signin.AccountSigninActivity;
import org.chromium.chrome.browser.signin.SigninAccessPoint;
@@ -145,37 +145,48 @@ public abstract class StatusListItem implements NewTabPageListItem {
private final int mActionStringId;
public static StatusListItem create(
- int disabledReason, NewTabPageAdapter adapter, NewTabPageManager manager) {
- switch (disabledReason) {
- case DisabledReason.NONE:
+ int categoryStatus, NewTabPageAdapter adapter, NewTabPageManager manager) {
+ switch (categoryStatus) {
+ case ContentSuggestionsCategoryStatus.AVAILABLE:
+ case ContentSuggestionsCategoryStatus.AVAILABLE_LOADING:
return new NoSnippets(adapter);
- case DisabledReason.SIGNED_OUT:
+ case ContentSuggestionsCategoryStatus.SIGNED_OUT:
return new SignedOut();
- case DisabledReason.SYNC_DISABLED:
+ case ContentSuggestionsCategoryStatus.SYNC_DISABLED:
return new SyncDisabled();
- case DisabledReason.PASSPHRASE_ENCRYPTION_ENABLED:
+ case ContentSuggestionsCategoryStatus.PASSPHRASE_ENCRYPTION_ENABLED:
return new PassphraseEncryptionEnabled(manager);
- case DisabledReason.HISTORY_SYNC_STATE_UNKNOWN:
+ case ContentSuggestionsCategoryStatus.INITIALIZING:
// This should only be a transient state: during app launch, or when the sync
// settings are being modified, and the user should never see a card showing this.
// So let's just use HistorySyncDisabled as fallback.
// TODO(dgn): If we add a spinner at some point (e.g. to show that we are fetching
// snippets) we could use it here too.
- case DisabledReason.HISTORY_SYNC_DISABLED:
+ case ContentSuggestionsCategoryStatus.HISTORY_SYNC_DISABLED:
return new HistorySyncDisabled();
- case DisabledReason.EXPLICITLY_DISABLED:
+ case ContentSuggestionsCategoryStatus.ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
+ case ContentSuggestionsCategoryStatus.CATEGORY_EXPLICITLY_DISABLED:
Log.wtf(TAG, "FATAL: Attempted to create a status card while the feature should be "
+ "off.");
return null;
+ case ContentSuggestionsCategoryStatus.NOT_PROVIDED:
+ Log.wtf(TAG, "FATAL: Attempted to create a status card for content suggestions "
+ + " when provider for ARTICLES is not registered.");
+ return null;
+
+ case ContentSuggestionsCategoryStatus.LOADING_ERROR:
+ Log.i(TAG, "Not showing ARTICLES suggestions because of provider error.");
Bernhard Bauer 2016/07/20 11:09:04 Log.d maybe?
Philipp Keck 2016/07/20 13:20:02 Done.
+ return null;
+
default:
Log.wtf(TAG, "FATAL: Attempted to create a status card for an unknown value: %d",
- disabledReason);
+ categoryStatus);
return null;
}
}

Powered by Google App Engine
This is Rietveld 408576698