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

Unified Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 2145563002: Add ContentSuggestionsService to SnippetsInternals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@articleprovider2
Patch Set: Refactor NTPSnippetsService::UpdateStateForStatus switch statement 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
« no previous file with comments | « chrome/browser/ui/webui/snippets_internals_message_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_service.cc
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
index 3ca187619dabdaf930fe055bba7663d8d53a8503..e13b8c32d3307316fb25ed6e6e163650915f3d1b 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -700,12 +700,9 @@ void NTPSnippetsService::UpdateStateForStatus(DisabledReason disabled_reason) {
FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_,
NTPSnippetsServiceDisabledReasonChanged(disabled_reason));
- State new_state;
- ContentSuggestionsCategoryStatus new_status;
switch (disabled_reason) {
case DisabledReason::NONE:
- new_state = State::READY;
- new_status = ContentSuggestionsCategoryStatus::AVAILABLE;
+ EnterState(State::READY, ContentSuggestionsCategoryStatus::AVAILABLE);
break;
case DisabledReason::HISTORY_SYNC_STATE_UNKNOWN:
@@ -714,46 +711,35 @@ void NTPSnippetsService::UpdateStateForStatus(DisabledReason disabled_reason) {
// |OnStateChanged| will call this function again to update the state.
DVLOG(1) << "Sync configuration incomplete, continuing based on the "
"current state.";
- new_state = state_;
- new_status = ContentSuggestionsCategoryStatus::INITIALIZING;
+ EnterState(state_, ContentSuggestionsCategoryStatus::INITIALIZING);
break;
case DisabledReason::EXPLICITLY_DISABLED:
- new_state = State::DISABLED;
- new_status =
- ContentSuggestionsCategoryStatus::CATEGORY_EXPLICITLY_DISABLED;
+ EnterState(
+ State::DISABLED,
+ ContentSuggestionsCategoryStatus::CATEGORY_EXPLICITLY_DISABLED);
break;
case DisabledReason::SIGNED_OUT:
- new_state = State::DISABLED;
- new_status = ContentSuggestionsCategoryStatus::SIGNED_OUT;
+ EnterState(State::DISABLED, ContentSuggestionsCategoryStatus::SIGNED_OUT);
break;
case DisabledReason::SYNC_DISABLED:
- new_state = State::DISABLED;
- new_status = ContentSuggestionsCategoryStatus::SYNC_DISABLED;
+ EnterState(State::DISABLED,
+ ContentSuggestionsCategoryStatus::SYNC_DISABLED);
break;
case DisabledReason::PASSPHRASE_ENCRYPTION_ENABLED:
- new_state = State::DISABLED;
- new_status =
- ContentSuggestionsCategoryStatus::PASSPHRASE_ENCRYPTION_ENABLED;
+ EnterState(
+ State::DISABLED,
+ ContentSuggestionsCategoryStatus::PASSPHRASE_ENCRYPTION_ENABLED);
break;
case DisabledReason::HISTORY_SYNC_DISABLED:
- new_state = State::DISABLED;
- new_status = ContentSuggestionsCategoryStatus::HISTORY_SYNC_DISABLED;
- break;
-
- default:
- // All cases should be handled by the above switch
- NOTREACHED();
- new_state = State::DISABLED;
- new_status = ContentSuggestionsCategoryStatus::LOADING_ERROR;
+ EnterState(State::DISABLED,
+ ContentSuggestionsCategoryStatus::HISTORY_SYNC_DISABLED);
break;
}
-
- EnterState(new_state, new_status);
}
void NTPSnippetsService::EnterState(State state,
« no previous file with comments | « chrome/browser/ui/webui/snippets_internals_message_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698