Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDER_H _ | |
| 6 #define COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDER_H _ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "components/ntp_snippets/category.h" | |
| 14 #include "components/ntp_snippets/category_status.h" | |
| 15 #include "components/ntp_snippets/content_suggestions_provider.h" | |
| 16 #include "components/sync/driver/sync_service.h" | |
| 17 #include "components/sync/driver/sync_service_observer.h" | |
| 18 #include "components/sync_sessions/open_tabs_ui_delegate.h" | |
| 19 #include "components/sync_sessions/synced_session.h" | |
| 20 | |
| 21 class PrefRegistrySimple; | |
| 22 class PrefService; | |
| 23 | |
| 24 namespace ntp_snippets { | |
| 25 | |
| 26 // Provides content suggestions from foreign sessions. | |
| 27 class ForeignSessionsSuggestionsProvider | |
| 28 : public ContentSuggestionsProvider, | |
| 29 public sync_driver::SyncServiceObserver { | |
| 30 public: | |
| 31 ForeignSessionsSuggestionsProvider( | |
| 32 ContentSuggestionsProvider::Observer* observer, | |
| 33 CategoryFactory* category_factory, | |
| 34 sync_driver::SyncService* sync_service, | |
| 35 PrefService* pref_service); | |
| 36 ~ForeignSessionsSuggestionsProvider() override; | |
| 37 | |
| 38 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | |
| 39 | |
| 40 private: | |
| 41 // ContentSuggestionsProvider implementation. | |
| 42 CategoryStatus GetCategoryStatus(Category category) override; | |
| 43 CategoryInfo GetCategoryInfo(Category category) override; | |
| 44 void DismissSuggestion(const std::string& suggestion_id) override; | |
| 45 void FetchSuggestionImage(const std::string& suggestion_id, | |
| 46 const ImageFetchedCallback& callback) override; | |
| 47 void ClearCachedSuggestions(Category category) override; | |
| 48 void GetDismissedSuggestionsForDebugging( | |
| 49 Category category, | |
| 50 const DismissedSuggestionsCallback& callback) override; | |
| 51 void ClearDismissedSuggestionsForDebugging(Category category) override; | |
| 52 | |
| 53 // SyncServiceObserver implementation. | |
| 54 void OnStateChanged() override; | |
| 55 void OnSyncConfigurationCompleted() override; | |
| 56 void OnForeignSessionUpdated() override; | |
| 57 | |
| 58 void TrySuggest(); | |
| 59 std::vector<ContentSuggestion> BuildSuggestions( | |
| 60 const std::vector<const sync_driver::SyncedSession*>& foreign_sessions); | |
| 61 ContentSuggestion BuildSuggestion( | |
| 62 const sessions::SessionTab& tab, | |
| 63 const sessions::SerializedNavigationEntry& navigation); | |
| 64 | |
| 65 CategoryStatus category_status_; | |
| 66 const Category provided_category_; | |
| 67 sync_driver::SyncService* sync_service_; | |
| 68 PrefService* pref_service_; | |
| 69 std::set<std::string> dismissed_ids_; | |
|
Marc Treib
2016/08/29 09:18:51
optional: Just read these from the pref on demand?
skym
2016/09/15 23:18:18
Interesting. So if we assume prefs are all stored
Marc Treib
2016/09/16 12:26:48
Yes, all prefs are in memory, otherwise reading th
| |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(ForeignSessionsSuggestionsProvider); | |
| 72 }; | |
| 73 | |
| 74 } // namespace ntp_snippets | |
| 75 | |
| 76 #endif // COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDE R_H_ | |
| OLD | NEW |