Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/autocomplete/contextual_suggestions_service_factory.h" | |
| 6 | |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 11 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 13 #include "components/omnibox/browser/contextual_suggestions_service.h" | |
| 14 #include "components/signin/core/browser/profile_oauth2_token_service.h" | |
| 15 #include "components/signin/core/browser/signin_manager.h" | |
| 16 | |
| 17 using contextual_suggestions::ContextualSuggestionsService; | |
| 18 | |
| 19 // static | |
| 20 ContextualSuggestionsService* | |
| 21 ContextualSuggestionsServiceFactory::GetForProfile(Profile* profile) { | |
| 22 return static_cast<ContextualSuggestionsService*>( | |
| 23 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
| 24 } | |
| 25 | |
| 26 // static | |
| 27 ContextualSuggestionsServiceFactory* | |
| 28 ContextualSuggestionsServiceFactory::GetInstance() { | |
| 29 return base::Singleton<ContextualSuggestionsServiceFactory>::get(); | |
| 30 } | |
| 31 | |
| 32 KeyedService* ContextualSuggestionsServiceFactory::BuildServiceInstanceFor( | |
| 33 content::BrowserContext* context) const { | |
| 34 Profile* profile = static_cast<Profile*>(context); | |
|
Mark P
2017/07/17 23:36:11
This should be Profile::FromBrowserContext() inste
| |
| 35 SigninManagerBase* signin_manager = | |
| 36 SigninManagerFactory::GetForProfile(profile); | |
| 37 ProfileOAuth2TokenService* token_service = | |
| 38 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | |
| 39 TemplateURLService* template_url_service = | |
| 40 TemplateURLServiceFactory::GetForProfile(profile); | |
| 41 return new ContextualSuggestionsService(signin_manager, token_service, | |
| 42 template_url_service, | |
| 43 profile->GetRequestContext()); | |
| 44 } | |
| 45 | |
| 46 ContextualSuggestionsServiceFactory::ContextualSuggestionsServiceFactory() | |
| 47 : BrowserContextKeyedServiceFactory( | |
| 48 "ContextualSuggestionsService", | |
| 49 BrowserContextDependencyManager::GetInstance()) { | |
| 50 DependsOn(SigninManagerFactory::GetInstance()); | |
| 51 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | |
| 52 DependsOn(TemplateURLServiceFactory::GetInstance()); | |
| 53 } | |
| 54 | |
| 55 ContextualSuggestionsServiceFactory::~ContextualSuggestionsServiceFactory() {} | |
| OLD | NEW |