| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_
H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_
H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_
H_ | 6 #define COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_
H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "components/ntp_snippets/content_suggestion.h" | 13 #include "components/ntp_snippets/content_suggestion.h" |
| 14 #include "components/ntp_snippets/content_suggestions_category.h" | 14 #include "components/ntp_snippets/content_suggestions_category.h" |
| 15 #include "components/ntp_snippets/content_suggestions_category_factory.h" |
| 15 #include "components/ntp_snippets/content_suggestions_category_status.h" | 16 #include "components/ntp_snippets/content_suggestions_category_status.h" |
| 16 #include "components/ntp_snippets/content_suggestions_provider.h" | 17 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 17 #include "components/offline_pages/offline_page_model.h" | 18 #include "components/offline_pages/offline_page_model.h" |
| 18 #include "components/offline_pages/offline_page_types.h" | 19 #include "components/offline_pages/offline_page_types.h" |
| 19 | 20 |
| 20 namespace gfx { | 21 namespace gfx { |
| 21 class Image; | 22 class Image; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace ntp_snippets { | 25 namespace ntp_snippets { |
| 25 | 26 |
| 26 // Provides content suggestions from the offline pages model. | 27 // Provides content suggestions from the offline pages model. |
| 27 // Currently, those are only the pages that the user last navigated to in an | 28 // Currently, those are only the pages that the user last navigated to in an |
| 28 // open tab and offlined bookmarks. | 29 // open tab and offlined bookmarks. |
| 29 class OfflinePageSuggestionsProvider | 30 class OfflinePageSuggestionsProvider |
| 30 : public KeyedService, | 31 : public KeyedService, |
| 31 public ContentSuggestionsProvider, | 32 public ContentSuggestionsProvider, |
| 32 public offline_pages::OfflinePageModel::Observer { | 33 public offline_pages::OfflinePageModel::Observer { |
| 33 public: | 34 public: |
| 34 OfflinePageSuggestionsProvider( | 35 OfflinePageSuggestionsProvider( |
| 36 ContentSuggestionsCategoryFactory* category_factory, |
| 35 offline_pages::OfflinePageModel* offline_page_model); | 37 offline_pages::OfflinePageModel* offline_page_model); |
| 36 ~OfflinePageSuggestionsProvider() override; | 38 ~OfflinePageSuggestionsProvider() override; |
| 37 | 39 |
| 38 // Inherited from KeyedService. | 40 // Inherited from KeyedService. |
| 39 void Shutdown() override; | 41 void Shutdown() override; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 // ContentSuggestionsProvider implementation. | 44 // ContentSuggestionsProvider implementation. |
| 45 std::vector<ContentSuggestionsCategory> GetProvidedCategories() override; |
| 43 void SetObserver(ContentSuggestionsProvider::Observer* observer) override; | 46 void SetObserver(ContentSuggestionsProvider::Observer* observer) override; |
| 44 ContentSuggestionsCategoryStatus GetCategoryStatus( | 47 ContentSuggestionsCategoryStatus GetCategoryStatus( |
| 45 ContentSuggestionsCategory category) override; | 48 ContentSuggestionsCategory category) override; |
| 46 void DismissSuggestion(const std::string& suggestion_id) override; | 49 void DismissSuggestion(const std::string& suggestion_id) override; |
| 47 void FetchSuggestionImage(const std::string& suggestion_id, | 50 void FetchSuggestionImage(const std::string& suggestion_id, |
| 48 const ImageFetchedCallback& callback) override; | 51 const ImageFetchedCallback& callback) override; |
| 49 void ClearCachedSuggestionsForDebugging() override; | 52 void ClearCachedSuggestionsForDebugging() override; |
| 50 void ClearDismissedSuggestionsForDebugging() override; | 53 void ClearDismissedSuggestionsForDebugging() override; |
| 51 | 54 |
| 52 // OfflinePageModel::Observer implementation. | 55 // OfflinePageModel::Observer implementation. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 | 67 |
| 65 // Updates the |category_status_| and notifies the |observer_|, if necessary. | 68 // Updates the |category_status_| and notifies the |observer_|, if necessary. |
| 66 void NotifyStatusChanged(ContentSuggestionsCategoryStatus new_status); | 69 void NotifyStatusChanged(ContentSuggestionsCategoryStatus new_status); |
| 67 | 70 |
| 68 ContentSuggestionsCategoryStatus category_status_; | 71 ContentSuggestionsCategoryStatus category_status_; |
| 69 | 72 |
| 70 ContentSuggestionsProvider::Observer* observer_; | 73 ContentSuggestionsProvider::Observer* observer_; |
| 71 | 74 |
| 72 offline_pages::OfflinePageModel* offline_page_model_; | 75 offline_pages::OfflinePageModel* offline_page_model_; |
| 73 | 76 |
| 77 const ContentSuggestionsCategory provided_category_; |
| 78 |
| 74 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider); | 79 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider); |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 } // namespace ntp_snippets | 82 } // namespace ntp_snippets |
| 78 | 83 |
| 79 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID
ER_H_ | 84 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID
ER_H_ |
| OLD | NEW |