Chromium Code Reviews| 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..2135fbf05684a78914f54a77c2d888f3ca1ca342 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: |
| - // 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.INITIALIZING: |
| + // This should only be a transient state: during app launch, or when the sync |
|
Marc Treib
2016/07/19 09:30:24
I think the indentation here was on purpose, since
Philipp Keck
2016/07/19 13:53:23
The auto-formatter removed the indentation, and th
Marc Treib
2016/07/19 16:21:19
Well, it's a fancy "// fallthrough" comment, so th
Philipp Keck
2016/07/19 16:47:34
Acknowledged.
|
| + // 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 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."); |
| + return null; |
| + |
| default: |
| Log.wtf(TAG, "FATAL: Attempted to create a status card for an unknown value: %d", |
| - disabledReason); |
| + categoryStatus); |
| return null; |
| } |
| } |