| 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 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
| 39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/storage_partition.h" | 40 #include "content/public/browser/storage_partition.h" |
| 41 #include "net/url_request/url_request_context_getter.h" | 41 #include "net/url_request/url_request_context_getter.h" |
| 42 | 42 |
| 43 #if defined(OS_ANDROID) | 43 #if defined(OS_ANDROID) |
| 44 #include "chrome/browser/android/chrome_feature_list.h" | 44 #include "chrome/browser/android/chrome_feature_list.h" |
| 45 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" | 45 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" |
| 46 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 46 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 47 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide
r.h" | 47 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide
r.h" |
| 48 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio
ns_provider.h" |
| 48 #include "components/offline_pages/offline_page_model.h" | 49 #include "components/offline_pages/offline_page_model.h" |
| 49 | 50 |
| 50 using ntp_snippets::OfflinePageSuggestionsProvider; | 51 using ntp_snippets::OfflinePageSuggestionsProvider; |
| 52 using ntp_snippets::PhysicalWebPageSuggestionsProvider; |
| 51 using offline_pages::OfflinePageModel; | 53 using offline_pages::OfflinePageModel; |
| 52 using offline_pages::OfflinePageModelFactory; | 54 using offline_pages::OfflinePageModelFactory; |
| 53 #endif // OS_ANDROID | 55 #endif // OS_ANDROID |
| 54 | 56 |
| 55 using bookmarks::BookmarkModel; | 57 using bookmarks::BookmarkModel; |
| 56 using content::BrowserThread; | 58 using content::BrowserThread; |
| 57 using image_fetcher::ImageFetcherImpl; | 59 using image_fetcher::ImageFetcherImpl; |
| 58 using ntp_snippets::BookmarkSuggestionsProvider; | 60 using ntp_snippets::BookmarkSuggestionsProvider; |
| 59 using ntp_snippets::ContentSuggestionsService; | 61 using ntp_snippets::ContentSuggestionsService; |
| 60 using ntp_snippets::NTPSnippetsDatabase; | 62 using ntp_snippets::NTPSnippetsDatabase; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (base::FeatureList::IsEnabled( | 145 if (base::FeatureList::IsEnabled( |
| 144 ntp_snippets::kBookmarkSuggestionsFeature)) { | 146 ntp_snippets::kBookmarkSuggestionsFeature)) { |
| 145 BookmarkModel* bookmark_model = | 147 BookmarkModel* bookmark_model = |
| 146 BookmarkModelFactory::GetForBrowserContext(profile); | 148 BookmarkModelFactory::GetForBrowserContext(profile); |
| 147 std::unique_ptr<BookmarkSuggestionsProvider> bookmark_suggestions_provider = | 149 std::unique_ptr<BookmarkSuggestionsProvider> bookmark_suggestions_provider = |
| 148 base::MakeUnique<BookmarkSuggestionsProvider>( | 150 base::MakeUnique<BookmarkSuggestionsProvider>( |
| 149 service, service->category_factory(), bookmark_model); | 151 service, service->category_factory(), bookmark_model); |
| 150 service->RegisterProvider(std::move(bookmark_suggestions_provider)); | 152 service->RegisterProvider(std::move(bookmark_suggestions_provider)); |
| 151 } | 153 } |
| 152 | 154 |
| 155 #if defined(OS_ANDROID) |
| 156 // Create the PhysicalWebPageSuggestionsProvider. |
| 157 if (base::FeatureList::IsEnabled( |
| 158 ntp_snippets::kPhysicalWebPageSuggestionsFeature)) { |
| 159 std::unique_ptr<PhysicalWebPageSuggestionsProvider> |
| 160 physical_web_page_suggestions_provider = |
| 161 base::MakeUnique<PhysicalWebPageSuggestionsProvider>( |
| 162 service, service->category_factory()); |
| 163 service->RegisterProvider( |
| 164 std::move(physical_web_page_suggestions_provider)); |
| 165 } |
| 166 #endif // OS_ANDROID |
| 167 |
| 153 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { | 168 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) { |
| 154 // Create the NTPSnippetsService (articles provider). | 169 // Create the NTPSnippetsService (articles provider). |
| 155 SigninManagerBase* signin_manager = | 170 SigninManagerBase* signin_manager = |
| 156 SigninManagerFactory::GetForProfile(profile); | 171 SigninManagerFactory::GetForProfile(profile); |
| 157 OAuth2TokenService* token_service = | 172 OAuth2TokenService* token_service = |
| 158 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 173 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 159 scoped_refptr<net::URLRequestContextGetter> request_context = | 174 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 160 content::BrowserContext::GetDefaultStoragePartition(context) | 175 content::BrowserContext::GetDefaultStoragePartition(context) |
| 161 ->GetURLRequestContext(); | 176 ->GetURLRequestContext(); |
| 162 SuggestionsService* suggestions_service = | 177 SuggestionsService* suggestions_service = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 188 base::MakeUnique<ImageDecoderImpl>(), | 203 base::MakeUnique<ImageDecoderImpl>(), |
| 189 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), | 204 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), |
| 190 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, | 205 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, |
| 191 profile->GetPrefs())); | 206 profile->GetPrefs())); |
| 192 service->set_ntp_snippets_service(ntp_snippets_service.get()); | 207 service->set_ntp_snippets_service(ntp_snippets_service.get()); |
| 193 service->RegisterProvider(std::move(ntp_snippets_service)); | 208 service->RegisterProvider(std::move(ntp_snippets_service)); |
| 194 } | 209 } |
| 195 | 210 |
| 196 return service; | 211 return service; |
| 197 } | 212 } |
| OLD | NEW |