| 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 #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 "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 Profile* profile = Profile::FromBrowserContext(context); | 204 Profile* profile = Profile::FromBrowserContext(context); |
| 205 DCHECK(!profile->IsOffTheRecord()); | 205 DCHECK(!profile->IsOffTheRecord()); |
| 206 | 206 |
| 207 // Create the ContentSuggestionsService. | 207 // Create the ContentSuggestionsService. |
| 208 State state = | 208 State state = |
| 209 base::FeatureList::IsEnabled(ntp_snippets::kContentSuggestionsFeature) | 209 base::FeatureList::IsEnabled(ntp_snippets::kContentSuggestionsFeature) |
| 210 ? State::ENABLED | 210 ? State::ENABLED |
| 211 : State::DISABLED; | 211 : State::DISABLED; |
| 212 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 212 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 213 profile, ServiceAccessType::EXPLICIT_ACCESS); | 213 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 214 PrefService* pref_service = profile->GetPrefs(); |
| 214 ContentSuggestionsService* service = | 215 ContentSuggestionsService* service = |
| 215 new ContentSuggestionsService(state, history_service); | 216 new ContentSuggestionsService(state, history_service, pref_service); |
| 216 if (state == State::DISABLED) { | 217 if (state == State::DISABLED) { |
| 217 // Since we won't initialise the services, they won't get a chance to | 218 // Since we won't initialise the services, they won't get a chance to |
| 218 // unschedule their tasks. We do it explicitly here instead. | 219 // unschedule their tasks. We do it explicitly here instead. |
| 219 ClearScheduledTasks(); | 220 ClearScheduledTasks(); |
| 220 return service; | 221 return service; |
| 221 } | 222 } |
| 222 | 223 |
| 223 CategoryFactory* category_factory = service->category_factory(); | 224 CategoryFactory* category_factory = service->category_factory(); |
| 224 PrefService* pref_service = profile->GetPrefs(); | |
| 225 #if defined(OS_ANDROID) | 225 #if defined(OS_ANDROID) |
| 226 OfflinePageModel* offline_page_model = | 226 OfflinePageModel* offline_page_model = |
| 227 OfflinePageModelFactory::GetForBrowserContext(profile); | 227 OfflinePageModelFactory::GetForBrowserContext(profile); |
| 228 #endif // OS_ANDROID | 228 #endif // OS_ANDROID |
| 229 BookmarkModel* bookmark_model = | 229 BookmarkModel* bookmark_model = |
| 230 BookmarkModelFactory::GetForBrowserContext(profile); | 230 BookmarkModelFactory::GetForBrowserContext(profile); |
| 231 SigninManagerBase* signin_manager = | 231 SigninManagerBase* signin_manager = |
| 232 SigninManagerFactory::GetForProfile(profile); | 232 SigninManagerFactory::GetForProfile(profile); |
| 233 OAuth2TokenService* token_service = | 233 OAuth2TokenService* token_service = |
| 234 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 234 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 260 } | 260 } |
| 261 #endif // OS_ANDROID | 261 #endif // OS_ANDROID |
| 262 | 262 |
| 263 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { | 263 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { |
| 264 RegisterArticleProvider(signin_manager, token_service, suggestions_service, | 264 RegisterArticleProvider(signin_manager, token_service, suggestions_service, |
| 265 service, category_factory, pref_service, profile); | 265 service, category_factory, pref_service, profile); |
| 266 } | 266 } |
| 267 | 267 |
| 268 return service; | 268 return service; |
| 269 } | 269 } |
| OLD | NEW |