OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 void NTPSnippetsService::OnDisabledReasonChanged( | 711 void NTPSnippetsService::OnDisabledReasonChanged( |
712 DisabledReason disabled_reason) { | 712 DisabledReason disabled_reason) { |
713 FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_, | 713 FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_, |
714 NTPSnippetsServiceDisabledReasonChanged(disabled_reason)); | 714 NTPSnippetsServiceDisabledReasonChanged(disabled_reason)); |
715 | 715 |
716 switch (disabled_reason) { | 716 switch (disabled_reason) { |
717 case DisabledReason::NONE: | 717 case DisabledReason::NONE: |
718 EnterState(State::READY, ContentSuggestionsCategoryStatus::AVAILABLE); | 718 EnterState(State::READY, ContentSuggestionsCategoryStatus::AVAILABLE); |
719 break; | 719 break; |
720 | 720 |
721 case DisabledReason::HISTORY_SYNC_STATE_UNKNOWN: | |
722 // HistorySync is not initialized yet, so we don't know what the actual | |
723 // state is and we just return the current one. If things change, | |
724 // |OnStateChanged| will call this function again to update the state. | |
725 DVLOG(1) << "Sync configuration incomplete, continuing based on the " | |
726 "current state."; | |
727 EnterState(state_, ContentSuggestionsCategoryStatus::INITIALIZING); | |
728 break; | |
729 | |
730 case DisabledReason::EXPLICITLY_DISABLED: | 721 case DisabledReason::EXPLICITLY_DISABLED: |
731 EnterState( | 722 EnterState( |
732 State::DISABLED, | 723 State::DISABLED, |
733 ContentSuggestionsCategoryStatus::CATEGORY_EXPLICITLY_DISABLED); | 724 ContentSuggestionsCategoryStatus::CATEGORY_EXPLICITLY_DISABLED); |
734 break; | 725 break; |
735 | 726 |
736 case DisabledReason::SIGNED_OUT: | 727 case DisabledReason::SIGNED_OUT: |
737 EnterState(State::DISABLED, ContentSuggestionsCategoryStatus::SIGNED_OUT); | 728 EnterState(State::DISABLED, ContentSuggestionsCategoryStatus::SIGNED_OUT); |
738 break; | 729 break; |
739 | |
740 case DisabledReason::SYNC_DISABLED: | |
741 EnterState(State::DISABLED, | |
742 ContentSuggestionsCategoryStatus::SYNC_DISABLED); | |
743 break; | |
744 | |
745 case DisabledReason::PASSPHRASE_ENCRYPTION_ENABLED: | |
746 EnterState( | |
747 State::DISABLED, | |
748 ContentSuggestionsCategoryStatus::PASSPHRASE_ENCRYPTION_ENABLED); | |
749 break; | |
750 | |
751 case DisabledReason::HISTORY_SYNC_DISABLED: | |
752 EnterState(State::DISABLED, | |
753 ContentSuggestionsCategoryStatus::HISTORY_SYNC_DISABLED); | |
754 break; | |
755 } | 730 } |
756 } | 731 } |
757 | 732 |
758 void NTPSnippetsService::EnterState(State state, | 733 void NTPSnippetsService::EnterState(State state, |
759 ContentSuggestionsCategoryStatus status) { | 734 ContentSuggestionsCategoryStatus status) { |
760 if (status != category_status_) { | 735 if (status != category_status_) { |
761 category_status_ = status; | 736 category_status_ = status; |
762 NotifyCategoryStatusChanged(); | 737 NotifyCategoryStatusChanged(); |
763 } | 738 } |
764 | 739 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 801 } |
827 | 802 |
828 void NTPSnippetsService::NotifyCategoryStatusChanged() { | 803 void NTPSnippetsService::NotifyCategoryStatusChanged() { |
829 if (observer_) { | 804 if (observer_) { |
830 observer_->OnCategoryStatusChanged(ContentSuggestionsCategory::ARTICLES, | 805 observer_->OnCategoryStatusChanged(ContentSuggestionsCategory::ARTICLES, |
831 category_status_); | 806 category_status_); |
832 } | 807 } |
833 } | 808 } |
834 | 809 |
835 } // namespace ntp_snippets | 810 } // namespace ntp_snippets |
OLD | NEW |