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

Side by Side Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2517113005: [NTP::PhysicalWeb] Wire Physical Web provider to the data source. (Closed)
Patch Set: rebase. Created 4 years 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
« no previous file with comments | « no previous file | components/ntp_snippets/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" 5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "net/url_request/url_request_context_getter.h" 53 #include "net/url_request/url_request_context_getter.h"
54 54
55 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
56 #include "chrome/browser/android/chrome_feature_list.h" 56 #include "chrome/browser/android/chrome_feature_list.h"
57 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" 57 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
58 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 58 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
59 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" 59 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h"
60 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" 60 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h"
61 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" 61 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h"
62 #include "components/offline_pages/offline_page_model.h" 62 #include "components/offline_pages/offline_page_model.h"
63 #include "components/physical_web/data_source/physical_web_data_source.h"
63 64
64 using content::DownloadManager; 65 using content::DownloadManager;
65 using ntp_snippets::PhysicalWebPageSuggestionsProvider; 66 using ntp_snippets::PhysicalWebPageSuggestionsProvider;
66 using ntp_snippets::RecentTabSuggestionsProvider; 67 using ntp_snippets::RecentTabSuggestionsProvider;
67 using offline_pages::OfflinePageModel; 68 using offline_pages::OfflinePageModel;
68 using offline_pages::OfflinePageModelFactory; 69 using offline_pages::OfflinePageModelFactory;
70 using physical_web::PhysicalWebDataSource;
69 #endif // OS_ANDROID 71 #endif // OS_ANDROID
70 72
71 using bookmarks::BookmarkModel; 73 using bookmarks::BookmarkModel;
72 using content::BrowserThread; 74 using content::BrowserThread;
73 using history::HistoryService; 75 using history::HistoryService;
74 using image_fetcher::ImageFetcherImpl; 76 using image_fetcher::ImageFetcherImpl;
75 using ntp_snippets::BookmarkSuggestionsProvider; 77 using ntp_snippets::BookmarkSuggestionsProvider;
76 using ntp_snippets::CategoryFactory; 78 using ntp_snippets::CategoryFactory;
77 using ntp_snippets::ContentSuggestionsService; 79 using ntp_snippets::ContentSuggestionsService;
78 using ntp_snippets::ForeignSessionsSuggestionsProvider; 80 using ntp_snippets::ForeignSessionsSuggestionsProvider;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void RegisterBookmarkProvider(BookmarkModel* bookmark_model, 124 void RegisterBookmarkProvider(BookmarkModel* bookmark_model,
123 ContentSuggestionsService* service, 125 ContentSuggestionsService* service,
124 CategoryFactory* category_factory, 126 CategoryFactory* category_factory,
125 PrefService* pref_service) { 127 PrefService* pref_service) {
126 auto provider = base::MakeUnique<BookmarkSuggestionsProvider>( 128 auto provider = base::MakeUnique<BookmarkSuggestionsProvider>(
127 service, category_factory, bookmark_model, pref_service); 129 service, category_factory, bookmark_model, pref_service);
128 service->RegisterProvider(std::move(provider)); 130 service->RegisterProvider(std::move(provider));
129 } 131 }
130 132
131 #if defined(OS_ANDROID) 133 #if defined(OS_ANDROID)
132 void RegisterPhysicalWebPageProvider(ContentSuggestionsService* service, 134 void RegisterPhysicalWebPageProvider(
133 CategoryFactory* category_factory) { 135 ContentSuggestionsService* service,
136 CategoryFactory* category_factory,
137 PhysicalWebDataSource* physical_web_data_source) {
134 auto provider = base::MakeUnique<PhysicalWebPageSuggestionsProvider>( 138 auto provider = base::MakeUnique<PhysicalWebPageSuggestionsProvider>(
135 service, category_factory); 139 service, category_factory, physical_web_data_source);
136 service->RegisterProvider(std::move(provider)); 140 service->RegisterProvider(std::move(provider));
137 } 141 }
138 #endif // OS_ANDROID 142 #endif // OS_ANDROID
139 143
140 void RegisterArticleProvider(SigninManagerBase* signin_manager, 144 void RegisterArticleProvider(SigninManagerBase* signin_manager,
141 OAuth2TokenService* token_service, 145 OAuth2TokenService* token_service,
142 ContentSuggestionsService* service, 146 ContentSuggestionsService* service,
143 CategoryFactory* category_factory, 147 CategoryFactory* category_factory,
144 LanguageModel* language_model, 148 LanguageModel* language_model,
145 PrefService* pref_service, 149 PrefService* pref_service,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ClearScheduledTasks(); 258 ClearScheduledTasks();
255 return service; 259 return service;
256 } 260 }
257 261
258 CategoryFactory* category_factory = service->category_factory(); 262 CategoryFactory* category_factory = service->category_factory();
259 #if defined(OS_ANDROID) 263 #if defined(OS_ANDROID)
260 OfflinePageModel* offline_page_model = 264 OfflinePageModel* offline_page_model =
261 OfflinePageModelFactory::GetForBrowserContext(profile); 265 OfflinePageModelFactory::GetForBrowserContext(profile);
262 DownloadManager* download_manager = 266 DownloadManager* download_manager =
263 content::BrowserContext::GetDownloadManager(profile); 267 content::BrowserContext::GetDownloadManager(profile);
268 PhysicalWebDataSource* physical_web_data_source =
269 g_browser_process->GetPhysicalWebDataSource();
264 #endif // OS_ANDROID 270 #endif // OS_ANDROID
265 BookmarkModel* bookmark_model = 271 BookmarkModel* bookmark_model =
266 BookmarkModelFactory::GetForBrowserContext(profile); 272 BookmarkModelFactory::GetForBrowserContext(profile);
267 OAuth2TokenService* token_service = 273 OAuth2TokenService* token_service =
268 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 274 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
269 SyncService* sync_service = 275 SyncService* sync_service =
270 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile); 276 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile);
271 LanguageModel* language_model = 277 LanguageModel* language_model =
272 LanguageModelFactory::GetInstance()->GetForBrowserContext(profile); 278 LanguageModelFactory::GetInstance()->GetForBrowserContext(profile);
273 279
(...skipping 19 matching lines...) Expand all
293 // |bookmark_model| can be null in tests. 299 // |bookmark_model| can be null in tests.
294 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) && 300 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) &&
295 bookmark_model) { 301 bookmark_model) {
296 RegisterBookmarkProvider(bookmark_model, service, category_factory, 302 RegisterBookmarkProvider(bookmark_model, service, category_factory,
297 pref_service); 303 pref_service);
298 } 304 }
299 305
300 #if defined(OS_ANDROID) 306 #if defined(OS_ANDROID)
301 if (base::FeatureList::IsEnabled( 307 if (base::FeatureList::IsEnabled(
302 ntp_snippets::kPhysicalWebPageSuggestionsFeature)) { 308 ntp_snippets::kPhysicalWebPageSuggestionsFeature)) {
303 RegisterPhysicalWebPageProvider(service, category_factory); 309 RegisterPhysicalWebPageProvider(service, category_factory,
310 physical_web_data_source);
304 } 311 }
305 #endif // OS_ANDROID 312 #endif // OS_ANDROID
306 313
307 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { 314 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) {
308 RegisterArticleProvider(signin_manager, token_service, service, 315 RegisterArticleProvider(signin_manager, token_service, service,
309 category_factory, language_model, pref_service, 316 category_factory, language_model, pref_service,
310 profile); 317 profile);
311 } 318 }
312 319
313 if (base::FeatureList::IsEnabled( 320 if (base::FeatureList::IsEnabled(
314 ntp_snippets::kForeignSessionsSuggestionsFeature)) { 321 ntp_snippets::kForeignSessionsSuggestionsFeature)) {
315 RegisterForeignSessionsProvider(sync_service, service, category_factory, 322 RegisterForeignSessionsProvider(sync_service, service, category_factory,
316 pref_service); 323 pref_service);
317 } 324 }
318 325
319 return service; 326 return service;
320 } 327 }
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698