| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 14 #include "components/ntp_snippets/ntp_snippets_fetcher.h" | 14 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
| 15 #include "components/ntp_snippets/ntp_snippets_scheduler.h" |
| 15 #include "components/ntp_snippets/ntp_snippets_service.h" | 16 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 17 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 17 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 20 | 21 |
| 22 #if defined(OS_ANDROID) |
| 23 #include "chrome/browser/android/ntp_snippets_launcher.h" |
| 24 #endif // OS_ANDROID |
| 25 |
| 21 using content::BrowserThread; | 26 using content::BrowserThread; |
| 22 | 27 |
| 23 // static | 28 // static |
| 24 NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() { | 29 NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() { |
| 25 return base::Singleton<NTPSnippetsServiceFactory>::get(); | 30 return base::Singleton<NTPSnippetsServiceFactory>::get(); |
| 26 } | 31 } |
| 27 | 32 |
| 28 // static | 33 // static |
| 29 ntp_snippets::NTPSnippetsService* NTPSnippetsServiceFactory::GetForProfile( | 34 ntp_snippets::NTPSnippetsService* NTPSnippetsServiceFactory::GetForProfile( |
| 30 Profile* profile) { | 35 Profile* profile) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 | 47 |
| 43 KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor( | 48 KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor( |
| 44 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
| 45 Profile* profile = Profile::FromBrowserContext(context); | 50 Profile* profile = Profile::FromBrowserContext(context); |
| 46 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); | 51 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
| 47 OAuth2TokenService* token_service = | 52 OAuth2TokenService* token_service = |
| 48 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 53 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 49 scoped_refptr<net::URLRequestContextGetter> request_context = | 54 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 50 context->GetRequestContext(); | 55 context->GetRequestContext(); |
| 51 | 56 |
| 57 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; |
| 58 #if defined(OS_ANDROID) |
| 59 scheduler = NTPSnippetsLauncher::Get(); |
| 60 #endif // OS_ANDROID |
| 61 |
| 52 scoped_refptr<base::SequencedTaskRunner> task_runner = | 62 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 53 BrowserThread::GetBlockingPool() | 63 BrowserThread::GetBlockingPool() |
| 54 ->GetSequencedTaskRunnerWithShutdownBehavior( | 64 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 55 base::SequencedWorkerPool::GetSequenceToken(), | 65 base::SequencedWorkerPool::GetSequenceToken(), |
| 56 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 66 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 57 | 67 |
| 58 return new ntp_snippets::NTPSnippetsService( | 68 return new ntp_snippets::NTPSnippetsService( |
| 59 task_runner, g_browser_process->GetApplicationLocale(), | 69 task_runner, g_browser_process->GetApplicationLocale(), scheduler, |
| 60 make_scoped_ptr(new ntp_snippets::NTPSnippetsFetcher( | 70 make_scoped_ptr(new ntp_snippets::NTPSnippetsFetcher( |
| 61 task_runner, (SigninManagerBase*) signin_manager, token_service, | 71 task_runner, (SigninManagerBase*) signin_manager, token_service, |
| 62 request_context, profile->GetPath()))); | 72 request_context, profile->GetPath()))); |
| 63 } | 73 } |
| OLD | NEW |