// Copyright 2015 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/ntp_snippets/ntp_snippets_service_factory.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/ntp_snippets/ntp_snippets_service.h" #include "content/public/browser/browser_context.h" // static NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() { return base::Singleton::get(); } // static ntp_snippets::NTPSnippetsService* NTPSnippetsServiceFactory::GetForProfile( Profile* profile) { DCHECK(!profile->IsOffTheRecord()); return static_cast( GetInstance()->GetServiceForBrowserContext(profile, true)); } NTPSnippetsServiceFactory::NTPSnippetsServiceFactory() : BrowserContextKeyedServiceFactory( "NTPSnippetsService", BrowserContextDependencyManager::GetInstance()) {} NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {} KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { return new ntp_snippets::NTPSnippetsService( g_browser_process->GetApplicationLocale()); }