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 = |
163 SuggestionsServiceFactory::GetForProfile(profile); | 178 SuggestionsServiceFactory::GetForProfile(profile); |
164 NTPSnippetsScheduler* scheduler = nullptr; | 179 NTPSnippetsScheduler* scheduler = nullptr; |
180 | |
Marc Treib
2016/08/11 12:53:09
nit: remove extra empty line
vitaliii
2016/08/11 14:29:58
Done.
| |
165 #if defined(OS_ANDROID) | 181 #if defined(OS_ANDROID) |
166 scheduler = NTPSnippetsLauncher::Get(); | 182 scheduler = NTPSnippetsLauncher::Get(); |
167 #endif // OS_ANDROID | 183 #endif // OS_ANDROID |
168 base::FilePath database_dir( | 184 base::FilePath database_dir( |
169 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); | 185 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); |
170 scoped_refptr<base::SequencedTaskRunner> task_runner = | 186 scoped_refptr<base::SequencedTaskRunner> task_runner = |
171 BrowserThread::GetBlockingPool() | 187 BrowserThread::GetBlockingPool() |
172 ->GetSequencedTaskRunnerWithShutdownBehavior( | 188 ->GetSequencedTaskRunnerWithShutdownBehavior( |
173 base::SequencedWorkerPool::GetSequenceToken(), | 189 base::SequencedWorkerPool::GetSequenceToken(), |
174 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 190 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
(...skipping 13 matching lines...) Expand all Loading... | |
188 base::MakeUnique<ImageDecoderImpl>(), | 204 base::MakeUnique<ImageDecoderImpl>(), |
189 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), | 205 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), |
190 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, | 206 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, |
191 profile->GetPrefs())); | 207 profile->GetPrefs())); |
192 service->set_ntp_snippets_service(ntp_snippets_service.get()); | 208 service->set_ntp_snippets_service(ntp_snippets_service.get()); |
193 service->RegisterProvider(std::move(ntp_snippets_service)); | 209 service->RegisterProvider(std::move(ntp_snippets_service)); |
194 } | 210 } |
195 | 211 |
196 return service; | 212 return service; |
197 } | 213 } |
OLD | NEW |