Home | History | Annotate | Download | only in discovery
      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
     16 SuggestedLinksRegistry* SuggestedLinksRegistryFactory::GetForProfile(
     17     Profile* profile) {
     18   return static_cast<SuggestedLinksRegistry*>(
     19       GetInstance()->GetServiceForBrowserContext(profile, true));
     20 }
     21 
     22 // static
     23 SuggestedLinksRegistryFactory* SuggestedLinksRegistryFactory::GetInstance() {
     24   return Singleton<SuggestedLinksRegistryFactory>::get();
     25 }
     26 
     27 bool SuggestedLinksRegistryFactory::ServiceIsCreatedWithBrowserContext() const {
     28   return true;
     29 }
     30 
     31 SuggestedLinksRegistryFactory::SuggestedLinksRegistryFactory()
     32     : BrowserContextKeyedServiceFactory(
     33         "SuggestedLinksRegistry",
     34         BrowserContextDependencyManager::GetInstance()) {
     35   DependsOn(ExtensionSystemFactory::GetInstance());
     36 }
     37 
     38 SuggestedLinksRegistryFactory::~SuggestedLinksRegistryFactory() {
     39 }
     40 
     41 BrowserContextKeyedService*
     42 SuggestedLinksRegistryFactory::BuildServiceInstanceFor(
     43     content::BrowserContext* profile) const {
     44   return new SuggestedLinksRegistry();
     45 }
     46 
     47 content::BrowserContext* SuggestedLinksRegistryFactory::GetBrowserContextToUse(
     48     content::BrowserContext* context) const {
     49   return chrome::GetBrowserContextRedirectedInIncognito(context);
     50 }
     51 
     52 }  // namespace extensions
     53