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 CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
6 #define CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 6 #define CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "components/ntp_snippets/callbacks.h" | 15 #include "components/ntp_snippets/callbacks.h" |
16 #include "components/ntp_snippets/category.h" | 16 #include "components/ntp_snippets/category.h" |
17 #include "components/ntp_snippets/category_factory.h" | |
18 #include "components/ntp_snippets/category_status.h" | 17 #include "components/ntp_snippets/category_status.h" |
19 #include "components/ntp_snippets/content_suggestion.h" | 18 #include "components/ntp_snippets/content_suggestion.h" |
20 #include "components/ntp_snippets/content_suggestions_provider.h" | 19 #include "components/ntp_snippets/content_suggestions_provider.h" |
21 #include "components/offline_pages/core/offline_page_model.h" | 20 #include "components/offline_pages/core/offline_page_model.h" |
22 #include "content/public/browser/download_manager.h" | 21 #include "content/public/browser/download_manager.h" |
23 | 22 |
24 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
25 class PrefService; | 24 class PrefService; |
26 | 25 |
27 namespace offline_pages { | 26 namespace offline_pages { |
28 struct OfflinePageItem; | 27 struct OfflinePageItem; |
29 } | 28 } |
30 | 29 |
31 // Provides download content suggestions from the offline pages model and the | 30 // Provides download content suggestions from the offline pages model and the |
32 // download manager (obtaining the data through DownloadManager and each | 31 // download manager (obtaining the data through DownloadManager and each |
33 // DownloadItem). Offline page related downloads are referred to as offline page | 32 // DownloadItem). Offline page related downloads are referred to as offline page |
34 // downloads, while the remaining downloads (e.g. images, music, books) are | 33 // downloads, while the remaining downloads (e.g. images, music, books) are |
35 // called asset downloads. In case either of the data sources is |nullptr|, it | 34 // called asset downloads. In case either of the data sources is |nullptr|, it |
36 // is ignored. | 35 // is ignored. |
37 class DownloadSuggestionsProvider | 36 class DownloadSuggestionsProvider |
38 : public ntp_snippets::ContentSuggestionsProvider, | 37 : public ntp_snippets::ContentSuggestionsProvider, |
39 public offline_pages::OfflinePageModel::Observer, | 38 public offline_pages::OfflinePageModel::Observer, |
40 public content::DownloadManager::Observer, | 39 public content::DownloadManager::Observer, |
41 public content::DownloadItem::Observer { | 40 public content::DownloadItem::Observer { |
42 public: | 41 public: |
43 DownloadSuggestionsProvider( | 42 DownloadSuggestionsProvider( |
44 ContentSuggestionsProvider::Observer* observer, | 43 ContentSuggestionsProvider::Observer* observer, |
45 ntp_snippets::CategoryFactory* category_factory, | |
46 offline_pages::OfflinePageModel* offline_page_model, | 44 offline_pages::OfflinePageModel* offline_page_model, |
47 content::DownloadManager* download_manager, | 45 content::DownloadManager* download_manager, |
48 PrefService* pref_service, | 46 PrefService* pref_service, |
49 bool download_manager_ui_enabled); | 47 bool download_manager_ui_enabled); |
50 ~DownloadSuggestionsProvider() override; | 48 ~DownloadSuggestionsProvider() override; |
51 | 49 |
52 // ContentSuggestionsProvider implementation. | 50 // ContentSuggestionsProvider implementation. |
53 ntp_snippets::CategoryStatus GetCategoryStatus( | 51 ntp_snippets::CategoryStatus GetCategoryStatus( |
54 ntp_snippets::Category category) override; | 52 ntp_snippets::Category category) override; |
55 ntp_snippets::CategoryInfo GetCategoryInfo( | 53 ntp_snippets::CategoryInfo GetCategoryInfo( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // Whether the Download Manager UI is enabled, in which case the More button | 219 // Whether the Download Manager UI is enabled, in which case the More button |
222 // for the Downloads section can redirect there. | 220 // for the Downloads section can redirect there. |
223 const bool download_manager_ui_enabled_; | 221 const bool download_manager_ui_enabled_; |
224 | 222 |
225 base::WeakPtrFactory<DownloadSuggestionsProvider> weak_ptr_factory_; | 223 base::WeakPtrFactory<DownloadSuggestionsProvider> weak_ptr_factory_; |
226 | 224 |
227 DISALLOW_COPY_AND_ASSIGN(DownloadSuggestionsProvider); | 225 DISALLOW_COPY_AND_ASSIGN(DownloadSuggestionsProvider); |
228 }; | 226 }; |
229 | 227 |
230 #endif // CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ | 228 #endif // CHROME_BROWSER_NTP_SNIPPETS_DOWNLOAD_SUGGESTIONS_PROVIDER_H_ |
OLD | NEW |