Index: chrome/browser/search/google_search_provider_service_factory.cc |
diff --git a/chrome/browser/search/google_search_provider_service_factory.cc b/chrome/browser/search/google_search_provider_service_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..980d8156d75ed933efc445a26e0612be9dbcfc8e |
--- /dev/null |
+++ b/chrome/browser/search/google_search_provider_service_factory.cc |
@@ -0,0 +1,41 @@ |
+// Copyright 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/search/google_search_provider_service_factory.h" |
+ |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/search/google_search_provider_service.h" |
+#include "chrome/browser/search_engines/template_url_service_factory.h" |
+#include "components/keyed_service/content/browser_context_dependency_manager.h" |
+#include "content/public/browser/browser_context.h" |
+ |
+// static |
+GoogleSearchProviderService* GoogleSearchProviderServiceFactory::GetForProfile( |
+ Profile* profile) { |
+ return static_cast<GoogleSearchProviderService*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, true)); |
+} |
+ |
+// static |
+GoogleSearchProviderServiceFactory* |
+GoogleSearchProviderServiceFactory::GetInstance() { |
+ return base::Singleton<GoogleSearchProviderServiceFactory>::get(); |
+} |
+ |
+GoogleSearchProviderServiceFactory::GoogleSearchProviderServiceFactory() |
+ : BrowserContextKeyedServiceFactory( |
+ "GoogleSearchProviderService", |
+ BrowserContextDependencyManager::GetInstance()) { |
+ DependsOn(TemplateURLServiceFactory::GetInstance()); |
+} |
+ |
+GoogleSearchProviderServiceFactory::~GoogleSearchProviderServiceFactory() = |
+ default; |
+ |
+KeyedService* GoogleSearchProviderServiceFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* context) const { |
+ Profile* profile = Profile::FromBrowserContext(context); |
+ return new GoogleSearchProviderService( |
+ TemplateURLServiceFactory::GetForProfile(profile)); |
+} |