| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ntp_snippets_service_factory.h" | 5 #include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" |
| 7 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/search/suggestions/image_fetcher_impl.h" | 12 #include "chrome/browser/search/suggestions/image_fetcher_impl.h" |
| 12 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 13 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/common/channel_info.h" | 17 #include "chrome/common/channel_info.h" |
| 17 #include "components/browser_sync/browser/profile_sync_service.h" | 18 #include "components/browser_sync/browser/profile_sync_service.h" |
| 18 #include "components/image_fetcher/image_fetcher.h" | 19 #include "components/image_fetcher/image_fetcher.h" |
| 19 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 20 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 21 #include "components/ntp_snippets/ntp_snippets_database.h" |
| 20 #include "components/ntp_snippets/ntp_snippets_fetcher.h" | 22 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
| 21 #include "components/ntp_snippets/ntp_snippets_scheduler.h" | 23 #include "components/ntp_snippets/ntp_snippets_scheduler.h" |
| 22 #include "components/ntp_snippets/ntp_snippets_service.h" | 24 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 23 #include "components/safe_json/safe_json_parser.h" | 25 #include "components/safe_json/safe_json_parser.h" |
| 24 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 26 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 25 #include "components/signin/core/browser/signin_manager.h" | 27 #include "components/signin/core/browser/signin_manager.h" |
| 26 #include "components/version_info/version_info.h" | 28 #include "components/version_info/version_info.h" |
| 27 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 28 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/storage_partition.h" | 31 #include "content/public/browser/storage_partition.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ProfileSyncService* sync_service = | 78 ProfileSyncService* sync_service = |
| 77 ProfileSyncServiceFactory::GetForProfile(profile); | 79 ProfileSyncServiceFactory::GetForProfile(profile); |
| 78 SuggestionsService* suggestions_service = | 80 SuggestionsService* suggestions_service = |
| 79 SuggestionsServiceFactory::GetForProfile(profile); | 81 SuggestionsServiceFactory::GetForProfile(profile); |
| 80 | 82 |
| 81 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; | 83 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; |
| 82 #if defined(OS_ANDROID) | 84 #if defined(OS_ANDROID) |
| 83 scheduler = NTPSnippetsLauncher::Get(); | 85 scheduler = NTPSnippetsLauncher::Get(); |
| 84 #endif // OS_ANDROID | 86 #endif // OS_ANDROID |
| 85 | 87 |
| 88 base::FilePath database_dir( |
| 89 profile->GetPath().Append(FILE_PATH_LITERAL("NTPSnippets"))); |
| 86 scoped_refptr<base::SequencedTaskRunner> task_runner = | 90 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 87 BrowserThread::GetBlockingPool() | 91 BrowserThread::GetBlockingPool() |
| 88 ->GetSequencedTaskRunnerWithShutdownBehavior( | 92 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 89 base::SequencedWorkerPool::GetSequenceToken(), | 93 base::SequencedWorkerPool::GetSequenceToken(), |
| 90 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 94 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 91 | 95 |
| 92 return new ntp_snippets::NTPSnippetsService( | 96 return new ntp_snippets::NTPSnippetsService( |
| 93 profile->GetPrefs(), sync_service, suggestions_service, task_runner, | 97 profile->GetPrefs(), sync_service, suggestions_service, |
| 94 g_browser_process->GetApplicationLocale(), scheduler, | 98 g_browser_process->GetApplicationLocale(), scheduler, |
| 95 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher( | 99 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher( |
| 96 signin_manager, token_service, request_context, | 100 signin_manager, token_service, request_context, |
| 97 base::Bind(&safe_json::SafeJsonParser::Parse), | 101 base::Bind(&safe_json::SafeJsonParser::Parse), |
| 98 chrome::GetChannel() == version_info::Channel::STABLE)), | 102 chrome::GetChannel() == version_info::Channel::STABLE)), |
| 99 base::WrapUnique(new ImageFetcherImpl(request_context.get()))); | 103 base::WrapUnique(new ImageFetcherImpl(request_context.get())), |
| 104 base::WrapUnique( |
| 105 new ntp_snippets::NTPSnippetsDatabase(database_dir, task_runner))); |
| 100 } | 106 } |
| OLD | NEW |