Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h

Issue 2205233002: Combine all suggestions factories into ContentSuggestionsServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bernhard's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
13 #include "components/ntp_snippets/category.h" 12 #include "components/ntp_snippets/category.h"
14 #include "components/ntp_snippets/category_factory.h" 13 #include "components/ntp_snippets/category_factory.h"
15 #include "components/ntp_snippets/category_status.h" 14 #include "components/ntp_snippets/category_status.h"
16 #include "components/ntp_snippets/content_suggestion.h" 15 #include "components/ntp_snippets/content_suggestion.h"
17 #include "components/ntp_snippets/content_suggestions_provider.h" 16 #include "components/ntp_snippets/content_suggestions_provider.h"
18 #include "components/offline_pages/offline_page_model.h" 17 #include "components/offline_pages/offline_page_model.h"
19 #include "components/offline_pages/offline_page_types.h" 18 #include "components/offline_pages/offline_page_types.h"
20 19
21 namespace gfx { 20 namespace gfx {
22 class Image; 21 class Image;
23 } 22 }
24 23
25 namespace ntp_snippets { 24 namespace ntp_snippets {
26 25
27 // Provides content suggestions from the offline pages model. 26 // Provides content suggestions from the offline pages model.
28 // Currently, those are only the pages that the user last navigated to in an 27 // Currently, those are only the pages that the user last navigated to in an
29 // open tab and offlined bookmarks. 28 // open tab and offlined bookmarks.
30 class OfflinePageSuggestionsProvider 29 class OfflinePageSuggestionsProvider
31 : public KeyedService, 30 : public ContentSuggestionsProvider,
32 public ContentSuggestionsProvider,
33 public offline_pages::OfflinePageModel::Observer { 31 public offline_pages::OfflinePageModel::Observer {
34 public: 32 public:
35 OfflinePageSuggestionsProvider( 33 OfflinePageSuggestionsProvider(
34 ContentSuggestionsProvider::Observer* observer,
36 CategoryFactory* category_factory, 35 CategoryFactory* category_factory,
37 offline_pages::OfflinePageModel* offline_page_model); 36 offline_pages::OfflinePageModel* offline_page_model);
38 ~OfflinePageSuggestionsProvider() override; 37 ~OfflinePageSuggestionsProvider() override;
39 38
40 // Inherited from KeyedService.
41 void Shutdown() override;
42
43 private: 39 private:
44 // ContentSuggestionsProvider implementation. 40 // ContentSuggestionsProvider implementation.
45 std::vector<Category> GetProvidedCategories() override; 41 std::vector<Category> GetProvidedCategories() override;
46 void SetObserver(ContentSuggestionsProvider::Observer* observer) override;
47 CategoryStatus GetCategoryStatus(Category category) override; 42 CategoryStatus GetCategoryStatus(Category category) override;
48 void DismissSuggestion(const std::string& suggestion_id) override; 43 void DismissSuggestion(const std::string& suggestion_id) override;
49 void FetchSuggestionImage(const std::string& suggestion_id, 44 void FetchSuggestionImage(const std::string& suggestion_id,
50 const ImageFetchedCallback& callback) override; 45 const ImageFetchedCallback& callback) override;
51 void ClearCachedSuggestionsForDebugging() override; 46 void ClearCachedSuggestionsForDebugging() override;
52 void ClearDismissedSuggestionsForDebugging() override; 47 void ClearDismissedSuggestionsForDebugging() override;
53 48
54 // OfflinePageModel::Observer implementation. 49 // OfflinePageModel::Observer implementation.
55 void OfflinePageModelLoaded(offline_pages::OfflinePageModel* model) override; 50 void OfflinePageModelLoaded(offline_pages::OfflinePageModel* model) override;
56 void OfflinePageModelChanged(offline_pages::OfflinePageModel* model) override; 51 void OfflinePageModelChanged(offline_pages::OfflinePageModel* model) override;
57 void OfflinePageDeleted(int64_t offline_id, 52 void OfflinePageDeleted(int64_t offline_id,
58 const offline_pages::ClientId& client_id) override; 53 const offline_pages::ClientId& client_id) override;
59 54
60 // Queries the OfflinePageModel for offline pages. 55 // Queries the OfflinePageModel for offline pages.
61 void FetchOfflinePages(); 56 void FetchOfflinePages();
62 57
63 // Callback from the OfflinePageModel. 58 // Callback from the OfflinePageModel.
64 void OnOfflinePagesLoaded( 59 void OnOfflinePagesLoaded(
65 const offline_pages::MultipleOfflinePageItemResult& result); 60 const offline_pages::MultipleOfflinePageItemResult& result);
66 61
67 // Updates the |category_status_| and notifies the |observer_|, if necessary. 62 // Updates the |category_status_| and notifies the |observer_|, if necessary.
68 void NotifyStatusChanged(CategoryStatus new_status); 63 void NotifyStatusChanged(CategoryStatus new_status);
69 64
70 CategoryStatus category_status_; 65 CategoryStatus category_status_;
71 66
72 ContentSuggestionsProvider::Observer* observer_;
73
74 offline_pages::OfflinePageModel* offline_page_model_; 67 offline_pages::OfflinePageModel* offline_page_model_;
75 68
76 const Category provided_category_; 69 const Category provided_category_;
77 70
78 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider); 71 DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider);
79 }; 72 };
80 73
81 } // namespace ntp_snippets 74 } // namespace ntp_snippets
82 75
83 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID ER_H_ 76 #endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVID ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698