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