| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #endif // OS_ANDROID | 78 #endif // OS_ANDROID |
| 79 | 79 |
| 80 using bookmarks::BookmarkModel; | 80 using bookmarks::BookmarkModel; |
| 81 using content::BrowserThread; | 81 using content::BrowserThread; |
| 82 using history::HistoryService; | 82 using history::HistoryService; |
| 83 using image_fetcher::ImageFetcherImpl; | 83 using image_fetcher::ImageFetcherImpl; |
| 84 using ntp_snippets::BookmarkSuggestionsProvider; | 84 using ntp_snippets::BookmarkSuggestionsProvider; |
| 85 using ntp_snippets::CategoryRanker; | 85 using ntp_snippets::CategoryRanker; |
| 86 using ntp_snippets::ContentSuggestionsService; | 86 using ntp_snippets::ContentSuggestionsService; |
| 87 using ntp_snippets::ForeignSessionsSuggestionsProvider; | 87 using ntp_snippets::ForeignSessionsSuggestionsProvider; |
| 88 using ntp_snippets::GetFetchEndpoint; |
| 88 using ntp_snippets::PersistentScheduler; | 89 using ntp_snippets::PersistentScheduler; |
| 89 using ntp_snippets::RemoteSuggestionsDatabase; | 90 using ntp_snippets::RemoteSuggestionsDatabase; |
| 90 using ntp_snippets::RemoteSuggestionsFetcher; | 91 using ntp_snippets::RemoteSuggestionsFetcher; |
| 91 using ntp_snippets::RemoteSuggestionsProviderImpl; | 92 using ntp_snippets::RemoteSuggestionsProviderImpl; |
| 92 using ntp_snippets::RemoteSuggestionsStatusService; | 93 using ntp_snippets::RemoteSuggestionsStatusService; |
| 93 using ntp_snippets::SchedulingRemoteSuggestionsProvider; | 94 using ntp_snippets::SchedulingRemoteSuggestionsProvider; |
| 94 using ntp_snippets::TabDelegateSyncAdapter; | 95 using ntp_snippets::TabDelegateSyncAdapter; |
| 95 using suggestions::ImageDecoderImpl; | 96 using suggestions::ImageDecoderImpl; |
| 96 using syncer::SyncService; | 97 using syncer::SyncService; |
| 97 using translate::LanguageModel; | 98 using translate::LanguageModel; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 scoped_refptr<base::SequencedTaskRunner> task_runner = | 183 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 183 BrowserThread::GetBlockingPool() | 184 BrowserThread::GetBlockingPool() |
| 184 ->GetSequencedTaskRunnerWithShutdownBehavior( | 185 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 185 base::SequencedWorkerPool::GetSequenceToken(), | 186 base::SequencedWorkerPool::GetSequenceToken(), |
| 186 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 187 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 187 bool is_stable_channel = | 188 bool is_stable_channel = |
| 188 chrome::GetChannel() == version_info::Channel::STABLE; | 189 chrome::GetChannel() == version_info::Channel::STABLE; |
| 189 auto suggestions_fetcher = base::MakeUnique<RemoteSuggestionsFetcher>( | 190 auto suggestions_fetcher = base::MakeUnique<RemoteSuggestionsFetcher>( |
| 190 signin_manager, token_service, request_context, pref_service, | 191 signin_manager, token_service, request_context, pref_service, |
| 191 language_model, base::Bind(&safe_json::SafeJsonParser::Parse), | 192 language_model, base::Bind(&safe_json::SafeJsonParser::Parse), |
| 193 GetFetchEndpoint(chrome::GetChannel() >= version_info::Channel::BETA), |
| 192 is_stable_channel ? google_apis::GetAPIKey() | 194 is_stable_channel ? google_apis::GetAPIKey() |
| 193 : google_apis::GetNonStableAPIKey(), | 195 : google_apis::GetNonStableAPIKey(), |
| 194 service->user_classifier()); | 196 service->user_classifier()); |
| 195 auto provider = base::MakeUnique<RemoteSuggestionsProviderImpl>( | 197 auto provider = base::MakeUnique<RemoteSuggestionsProviderImpl>( |
| 196 service, pref_service, g_browser_process->GetApplicationLocale(), | 198 service, pref_service, g_browser_process->GetApplicationLocale(), |
| 197 service->category_ranker(), std::move(suggestions_fetcher), | 199 service->category_ranker(), std::move(suggestions_fetcher), |
| 198 base::MakeUnique<ImageFetcherImpl>(base::MakeUnique<ImageDecoderImpl>(), | 200 base::MakeUnique<ImageFetcherImpl>(base::MakeUnique<ImageDecoderImpl>(), |
| 199 request_context.get()), | 201 request_context.get()), |
| 200 base::MakeUnique<ImageDecoderImpl>(), | 202 base::MakeUnique<ImageDecoderImpl>(), |
| 201 base::MakeUnique<RemoteSuggestionsDatabase>(database_dir, task_runner), | 203 base::MakeUnique<RemoteSuggestionsDatabase>(database_dir, task_runner), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ntp_snippets::kForeignSessionsSuggestionsFeature)) { | 348 ntp_snippets::kForeignSessionsSuggestionsFeature)) { |
| 347 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 349 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
| 348 } | 350 } |
| 349 | 351 |
| 350 return service; | 352 return service; |
| 351 | 353 |
| 352 #else | 354 #else |
| 353 return nullptr; | 355 return nullptr; |
| 354 #endif // CONTENT_SUGGESTIONS_ENABLED | 356 #endif // CONTENT_SUGGESTIONS_ENABLED |
| 355 } | 357 } |
| OLD | NEW |