Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: chrome/browser/autocomplete/contextual_suggestions_service_factory.cc

Issue 2965173002: Add ContextualSuggestionsService to Omnibox (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "base/memory/singleton.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search_engines/template_url_service_factory.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "components/contextual_suggestions/contextual_suggestions_service.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 #include "components/signin/core/browser/profile_oauth2_token_service.h"
14 #include "components/signin/core/browser/signin_manager.h"
15
16 using contextual_suggestions::ContextualSuggestionsService;
17
18 // static
19 ContextualSuggestionsService*
20 ContextualSuggestionsServiceFactory::GetForProfile(Profile* profile) {
21 return static_cast<ContextualSuggestionsService*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
23 }
24
25 // static
26 ContextualSuggestionsServiceFactory*
27 ContextualSuggestionsServiceFactory::GetInstance() {
28 return base::Singleton<ContextualSuggestionsServiceFactory>::get();
29 }
30
31 KeyedService* ContextualSuggestionsServiceFactory::BuildServiceInstanceFor(
32 content::BrowserContext* context) const {
33 Profile* profile = static_cast<Profile*>(context);
34 SigninManagerBase* signin_manager =
35 SigninManagerFactory::GetForProfile(profile);
36 ProfileOAuth2TokenService* token_service =
37 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
38 TemplateURLService* template_url_service =
39 TemplateURLServiceFactory::GetForProfile(profile);
40 return new ContextualSuggestionsService(signin_manager, token_service,
41 template_url_service,
42 profile->GetRequestContext());
43 }
44
45 ContextualSuggestionsServiceFactory::ContextualSuggestionsServiceFactory()
46 : BrowserContextKeyedServiceFactory(
47 "ContextualSuggestionsService",
48 BrowserContextDependencyManager::GetInstance()) {
49 DependsOn(SigninManagerFactory::GetInstance());
50 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
51 DependsOn(TemplateURLServiceFactory::GetInstance());
52 }
53
54 ContextualSuggestionsServiceFactory::~ContextualSuggestionsServiceFactory() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698