Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 SigninManagerBase* signin_manager = | 142 SigninManagerBase* signin_manager = |
| 141 SigninManagerFactory::GetForProfile(profile); | 143 SigninManagerFactory::GetForProfile(profile); |
| 142 OAuth2TokenService* token_service = | 144 OAuth2TokenService* token_service = |
| 143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 145 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 144 scoped_refptr<net::URLRequestContextGetter> request_context = | 146 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 145 content::BrowserContext::GetDefaultStoragePartition(context) | 147 content::BrowserContext::GetDefaultStoragePartition(context) |
| 146 ->GetURLRequestContext(); | 148 ->GetURLRequestContext(); |
| 147 SuggestionsService* suggestions_service = | 149 SuggestionsService* suggestions_service = |
| 148 SuggestionsServiceFactory::GetForProfile(profile); | 150 SuggestionsServiceFactory::GetForProfile(profile); |
| 149 NTPSnippetsScheduler* scheduler = nullptr; | 151 NTPSnippetsScheduler* scheduler = nullptr; |
| 152 | |
| 153 #if defined(OS_ANDROID) | |
|
Marc Treib
2016/08/10 16:22:03
This block is in the wrong place: It's inside the
tschumann
2016/08/10 17:37:57
not really related to this CL, but as we are here.
Marc Treib
2016/08/11 12:15:24
Yep, this sounds like a good idea. Doesn't need to
vitaliii
2016/08/11 12:15:24
Done.
vitaliii
2016/08/11 12:15:24
Acknowledged.
| |
| 154 // Create the PhysicalWebPageSuggestionsProvider. | |
| 155 if (base::FeatureList::IsEnabled( | |
| 156 chrome::android::kNTPPhysicalWebPageSuggestionsFeature)) { | |
| 157 std::unique_ptr<PhysicalWebPageSuggestionsProvider> | |
| 158 physical_web_page_suggestions_provider = | |
| 159 base::MakeUnique<PhysicalWebPageSuggestionsProvider>( | |
| 160 service, service->category_factory()); | |
| 161 service->RegisterProvider( | |
| 162 std::move(physical_web_page_suggestions_provider)); | |
| 163 } | |
| 164 #endif // OS_ANDROID | |
| 165 | |
| 150 #if defined(OS_ANDROID) | 166 #if defined(OS_ANDROID) |
| 151 scheduler = NTPSnippetsLauncher::Get(); | 167 scheduler = NTPSnippetsLauncher::Get(); |
| 152 #endif // OS_ANDROID | 168 #endif // OS_ANDROID |
| 153 base::FilePath database_dir( | 169 base::FilePath database_dir( |
| 154 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); | 170 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); |
| 155 scoped_refptr<base::SequencedTaskRunner> task_runner = | 171 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 156 BrowserThread::GetBlockingPool() | 172 BrowserThread::GetBlockingPool() |
| 157 ->GetSequencedTaskRunnerWithShutdownBehavior( | 173 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 158 base::SequencedWorkerPool::GetSequenceToken(), | 174 base::SequencedWorkerPool::GetSequenceToken(), |
| 159 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 175 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 173 base::MakeUnique<ImageDecoderImpl>(), | 189 base::MakeUnique<ImageDecoderImpl>(), |
| 174 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), | 190 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), |
| 175 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, | 191 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, |
| 176 profile->GetPrefs())); | 192 profile->GetPrefs())); |
| 177 service->set_ntp_snippets_service(ntp_snippets_service.get()); | 193 service->set_ntp_snippets_service(ntp_snippets_service.get()); |
| 178 service->RegisterProvider(std::move(ntp_snippets_service)); | 194 service->RegisterProvider(std::move(ntp_snippets_service)); |
| 179 } | 195 } |
| 180 | 196 |
| 181 return service; | 197 return service; |
| 182 } | 198 } |
| OLD | NEW |