| Index: chrome/browser/autocomplete/contextual_suggestions_service_factory.cc
|
| diff --git a/chrome/browser/autocomplete/contextual_suggestions_service_factory.cc b/chrome/browser/autocomplete/contextual_suggestions_service_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..49171447aa69a3b85a97585ad803ed9602046758
|
| --- /dev/null
|
| +++ b/chrome/browser/autocomplete/contextual_suggestions_service_factory.cc
|
| @@ -0,0 +1,56 @@
|
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/autocomplete/contextual_suggestions_service_factory.h"
|
| +#include "base/memory/singleton.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/search_engines/template_url_service_factory.h"
|
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| +#include "chrome/browser/signin/signin_manager_factory.h"
|
| +#include "components/contextual_suggestions/contextual_suggestions_service.h"
|
| +#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
| +#include "components/signin/core/browser/profile_oauth2_token_service.h"
|
| +#include "components/signin/core/browser/signin_manager.h"
|
| +
|
| +namespace contextual_suggestions {
|
| +
|
| +// static
|
| +ContextualSuggestionsService*
|
| +ContextualSuggestionsServiceFactory::GetForProfile(Profile* profile) {
|
| + return static_cast<ContextualSuggestionsService*>(
|
| + GetInstance()->GetServiceForBrowserContext(profile, true));
|
| +}
|
| +
|
| +// static
|
| +ContextualSuggestionsServiceFactory*
|
| +ContextualSuggestionsServiceFactory::GetInstance() {
|
| + return base::Singleton<ContextualSuggestionsServiceFactory>::get();
|
| +}
|
| +
|
| +KeyedService* ContextualSuggestionsServiceFactory::BuildServiceInstanceFor(
|
| + content::BrowserContext* context) const {
|
| + Profile* profile = static_cast<Profile*>(context);
|
| + SigninManagerBase* signin_manager =
|
| + SigninManagerFactory::GetForProfile(profile);
|
| + ProfileOAuth2TokenService* token_service =
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(profile);
|
| + return new ContextualSuggestionsService(signin_manager, token_service,
|
| + template_url_service,
|
| + profile->GetRequestContext());
|
| +}
|
| +
|
| +ContextualSuggestionsServiceFactory::ContextualSuggestionsServiceFactory()
|
| + : BrowserContextKeyedServiceFactory(
|
| + "ContextualSuggestionsService",
|
| + BrowserContextDependencyManager::GetInstance()) {
|
| + DependsOn(SigninManagerFactory::GetInstance());
|
| + DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
|
| + DependsOn(TemplateURLServiceFactory::GetInstance());
|
| +}
|
| +
|
| +ContextualSuggestionsServiceFactory::~ContextualSuggestionsServiceFactory() {}
|
| +
|
| +} // namespace contextual_suggestions
|
|
|