| 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 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace sync_driver { | 55 namespace sync_driver { |
| 56 class SyncService; | 56 class SyncService; |
| 57 } | 57 } |
| 58 | 58 |
| 59 namespace ntp_snippets { | 59 namespace ntp_snippets { |
| 60 | 60 |
| 61 class NTPSnippetsDatabase; | 61 class NTPSnippetsDatabase; |
| 62 class NTPSnippetsServiceObserver; | 62 class NTPSnippetsServiceObserver; |
| 63 | 63 |
| 64 // Stores and vends fresh content data for the NTP. | 64 // Retrieves fresh content data (articles) from the server, stores them and |
| 65 // TODO(pke): Rename this service to ArticleSuggestionsService and move to | 65 // provides them as content suggestions. |
| 66 // TODO(pke): Rename this service to ArticleSuggestionsProvider and move to |
| 66 // a subdirectory. | 67 // a subdirectory. |
| 67 class NTPSnippetsService : public KeyedService, | 68 class NTPSnippetsService : public KeyedService, |
| 68 public image_fetcher::ImageFetcherDelegate, | 69 public image_fetcher::ImageFetcherDelegate, |
| 69 public ContentSuggestionsProvider { | 70 public ContentSuggestionsProvider { |
| 70 public: | 71 public: |
| 71 // |application_language_code| should be a ISO 639-1 compliant string, e.g. | 72 // |application_language_code| should be a ISO 639-1 compliant string, e.g. |
| 72 // 'en' or 'en-US'. Note that this code should only specify the language, not | 73 // 'en' or 'en-US'. Note that this code should only specify the language, not |
| 73 // the locale, so 'en_US' (English language with US locale) and 'en-GB_US' | 74 // the locale, so 'en_US' (English language with US locale) and 'en-GB_US' |
| 74 // (British English person in the US) are not language codes. | 75 // (British English person in the US) are not language codes. |
| 75 NTPSnippetsService(bool enabled, | 76 NTPSnippetsService(bool enabled, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::set<std::string> GetSuggestionsHosts() const; | 147 std::set<std::string> GetSuggestionsHosts() const; |
| 147 | 148 |
| 148 // Observer accessors. | 149 // Observer accessors. |
| 149 void AddObserver(NTPSnippetsServiceObserver* observer); | 150 void AddObserver(NTPSnippetsServiceObserver* observer); |
| 150 void RemoveObserver(NTPSnippetsServiceObserver* observer); | 151 void RemoveObserver(NTPSnippetsServiceObserver* observer); |
| 151 | 152 |
| 152 // Returns the maximum number of snippets that will be shown at once. | 153 // Returns the maximum number of snippets that will be shown at once. |
| 153 static int GetMaxSnippetCountForTesting(); | 154 static int GetMaxSnippetCountForTesting(); |
| 154 | 155 |
| 155 private: | 156 private: |
| 157 friend class NTPSnippetsServiceTest; |
| 156 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest, HistorySyncStateChanges); | 158 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest, HistorySyncStateChanges); |
| 157 | 159 |
| 158 // TODO(pke): As soon as the DisabledReason is replaced with the new status, | 160 // TODO(pke): As soon as the DisabledReason is replaced with the new status, |
| 159 // also remove the old State enum and replace it with | 161 // also remove the old State enum and replace it with |
| 160 // ContentSuggestionsCategoryStatus and a similar status diagram. | 162 // ContentSuggestionsCategoryStatus and a similar status diagram. |
| 161 // Possible state transitions: | 163 // Possible state transitions: |
| 162 // +------- NOT_INITED ------+ | 164 // +------- NOT_INITED ------+ |
| 163 // | / \ | | 165 // | / \ | |
| 164 // | READY <--> DISABLED <-+ | 166 // | READY <--> DISABLED <-+ |
| 165 // | \ / | 167 // | \ / |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // If the service might be enabled, DisabledReason::NONE will be provided. | 336 // If the service might be enabled, DisabledReason::NONE will be provided. |
| 335 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; | 337 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; |
| 336 | 338 |
| 337 protected: | 339 protected: |
| 338 virtual ~NTPSnippetsServiceObserver() {} | 340 virtual ~NTPSnippetsServiceObserver() {} |
| 339 }; | 341 }; |
| 340 | 342 |
| 341 } // namespace ntp_snippets | 343 } // namespace ntp_snippets |
| 342 | 344 |
| 343 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 345 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| OLD | NEW |