1 // Copyright (c) 2012 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/extensions/api/discovery/suggested_links_registry_factory.h" 6 7 #include "chrome/browser/extensions/api/discovery/suggested_links_registry.h" 8 #include "chrome/browser/extensions/extension_system_factory.h" 9 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/profile.h" 11 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h" 12 13 namespace extensions { 14 15 // static GetForProfile(Profile * profile)16SuggestedLinksRegistry* SuggestedLinksRegistryFactory::GetForProfile( 17 Profile* profile) { 18 return static_cast<SuggestedLinksRegistry*>( 19 GetInstance()->GetServiceForBrowserContext(profile, true)); 20 } 21 22 // static GetInstance()23SuggestedLinksRegistryFactory* SuggestedLinksRegistryFactory::GetInstance() { 24 return Singleton<SuggestedLinksRegistryFactory>::get(); 25 } 26 ServiceIsCreatedWithBrowserContext() const27bool SuggestedLinksRegistryFactory::ServiceIsCreatedWithBrowserContext() const { 28 return true; 29 } 30 SuggestedLinksRegistryFactory()31SuggestedLinksRegistryFactory::SuggestedLinksRegistryFactory() 32 : BrowserContextKeyedServiceFactory( 33 "SuggestedLinksRegistry", 34 BrowserContextDependencyManager::GetInstance()) { 35 DependsOn(ExtensionSystemFactory::GetInstance()); 36 } 37 ~SuggestedLinksRegistryFactory()38SuggestedLinksRegistryFactory::~SuggestedLinksRegistryFactory() { 39 } 40 41 BrowserContextKeyedService* BuildServiceInstanceFor(content::BrowserContext * profile) const42SuggestedLinksRegistryFactory::BuildServiceInstanceFor( 43 content::BrowserContext* profile) const { 44 return new SuggestedLinksRegistry(); 45 } 46 GetBrowserContextToUse(content::BrowserContext * context) const47content::BrowserContext* SuggestedLinksRegistryFactory::GetBrowserContextToUse( 48 content::BrowserContext* context) const { 49 return chrome::GetBrowserContextRedirectedInIncognito(context); 50 } 51 52 } // namespace extensions 53