| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return base::Singleton<ContentSuggestionsServiceFactory>::get(); | 177 return base::Singleton<ContentSuggestionsServiceFactory>::get(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // static | 180 // static |
| 181 ContentSuggestionsService* ContentSuggestionsServiceFactory::GetForProfile( | 181 ContentSuggestionsService* ContentSuggestionsServiceFactory::GetForProfile( |
| 182 Profile* profile) { | 182 Profile* profile) { |
| 183 return static_cast<ContentSuggestionsService*>( | 183 return static_cast<ContentSuggestionsService*>( |
| 184 GetInstance()->GetServiceForBrowserContext(profile, true)); | 184 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 185 } | 185 } |
| 186 | 186 |
| 187 // static |
| 188 ContentSuggestionsService* |
| 189 ContentSuggestionsServiceFactory::GetForProfileIfExists(Profile* profile) { |
| 190 return static_cast<ContentSuggestionsService*>( |
| 191 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 192 } |
| 193 |
| 187 ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory() | 194 ContentSuggestionsServiceFactory::ContentSuggestionsServiceFactory() |
| 188 : BrowserContextKeyedServiceFactory( | 195 : BrowserContextKeyedServiceFactory( |
| 189 "ContentSuggestionsService", | 196 "ContentSuggestionsService", |
| 190 BrowserContextDependencyManager::GetInstance()) { | 197 BrowserContextDependencyManager::GetInstance()) { |
| 191 DependsOn(BookmarkModelFactory::GetInstance()); | 198 DependsOn(BookmarkModelFactory::GetInstance()); |
| 192 DependsOn(HistoryServiceFactory::GetInstance()); | 199 DependsOn(HistoryServiceFactory::GetInstance()); |
| 193 #if defined(OS_ANDROID) | 200 #if defined(OS_ANDROID) |
| 194 DependsOn(OfflinePageModelFactory::GetInstance()); | 201 DependsOn(OfflinePageModelFactory::GetInstance()); |
| 195 #endif // OS_ANDROID | 202 #endif // OS_ANDROID |
| 196 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 203 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 269 } |
| 263 #endif // OS_ANDROID | 270 #endif // OS_ANDROID |
| 264 | 271 |
| 265 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { | 272 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { |
| 266 RegisterArticleProvider(signin_manager, token_service, suggestions_service, | 273 RegisterArticleProvider(signin_manager, token_service, suggestions_service, |
| 267 service, category_factory, pref_service, profile); | 274 service, category_factory, pref_service, profile); |
| 268 } | 275 } |
| 269 | 276 |
| 270 return service; | 277 return service; |
| 271 } | 278 } |
| OLD | NEW |