extension_registry_factory.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_registry_factory.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_dependency_manager.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_registry.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extensions_browser_client.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using content::BrowserContext; 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace extensions { 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ExtensionRegistry* ExtensionRegistryFactory::GetForBrowserContext( 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BrowserContext* context) { 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return static_cast<ExtensionRegistry*>( 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetInstance()->GetServiceForBrowserContext(context, true)); 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ExtensionRegistryFactory* ExtensionRegistryFactory::GetInstance() { 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return Singleton<ExtensionRegistryFactory>::get(); 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ExtensionRegistryFactory::ExtensionRegistryFactory() 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : BrowserContextKeyedServiceFactory( 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) "ExtensionRegistry", 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BrowserContextDependencyManager::GetInstance()) { 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // No dependencies on other services. 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ExtensionRegistryFactory::~ExtensionRegistryFactory() {} 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)KeyedService* ExtensionRegistryFactory::BuildServiceInstanceFor( 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::BrowserContext* context) const { 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return new ExtensionRegistry; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)BrowserContext* ExtensionRegistryFactory::GetBrowserContextToUse( 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BrowserContext* context) const { 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Redirected in incognito. 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ExtensionsBrowserClient::Get()->GetOriginalContext(context); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace extensions 48