Index: components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h |
diff --git a/components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h b/components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd7c7c4d7a076452ba9b7caeeaa8a4ad9d33d4b7 |
--- /dev/null |
+++ b/components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDER_H_ |
+#define COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDER_H_ |
+ |
+#include <set> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "components/ntp_snippets/category.h" |
+#include "components/ntp_snippets/category_status.h" |
+#include "components/ntp_snippets/content_suggestions_provider.h" |
+#include "components/sync/driver/sync_service.h" |
+#include "components/sync/driver/sync_service_observer.h" |
+#include "components/sync_sessions/open_tabs_ui_delegate.h" |
+#include "components/sync_sessions/synced_session.h" |
+ |
+class PrefRegistrySimple; |
+class PrefService; |
+ |
+namespace ntp_snippets { |
+ |
+// Provides content suggestions from foreign sessions. |
+class ForeignSessionsSuggestionsProvider |
+ : public ContentSuggestionsProvider, |
+ public sync_driver::SyncServiceObserver { |
+ public: |
+ ForeignSessionsSuggestionsProvider( |
+ ContentSuggestionsProvider::Observer* observer, |
+ CategoryFactory* category_factory, |
+ sync_driver::SyncService* sync_service, |
+ PrefService* pref_service); |
+ ~ForeignSessionsSuggestionsProvider() override; |
+ |
+ static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
+ |
+ private: |
+ // ContentSuggestionsProvider implementation. |
+ CategoryStatus GetCategoryStatus(Category category) override; |
+ CategoryInfo GetCategoryInfo(Category category) override; |
+ void DismissSuggestion(const std::string& suggestion_id) override; |
+ void FetchSuggestionImage(const std::string& suggestion_id, |
+ const ImageFetchedCallback& callback) override; |
+ void ClearCachedSuggestions(Category category) override; |
+ void GetDismissedSuggestionsForDebugging( |
+ Category category, |
+ const DismissedSuggestionsCallback& callback) override; |
+ void ClearDismissedSuggestionsForDebugging(Category category) override; |
+ |
+ // SyncServiceObserver implementation. |
+ void OnStateChanged() override; |
+ void OnSyncConfigurationCompleted() override; |
+ void OnForeignSessionUpdated() override; |
+ |
+ void TrySuggest(); |
+ std::vector<ContentSuggestion> BuildSuggestions( |
+ const std::vector<const sync_driver::SyncedSession*>& foreign_sessions); |
+ ContentSuggestion BuildSuggestion( |
+ const sessions::SessionTab& tab, |
+ const sessions::SerializedNavigationEntry& navigation); |
+ |
+ CategoryStatus category_status_; |
+ const Category provided_category_; |
+ sync_driver::SyncService* sync_service_; |
+ PrefService* pref_service_; |
+ 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
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ForeignSessionsSuggestionsProvider); |
+}; |
+ |
+} // namespace ntp_snippets |
+ |
+#endif // COMPONENTS_NTP_SNIPPETS_SESSIONS_FOREIGN_SESSIONS_SUGGESTIONS_PROVIDER_H_ |