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/idle/idle_manager_factory.h" 6 7 #include "chrome/browser/extensions/api/idle/idle_manager.h" 8 #include "chrome/browser/profiles/profile.h" 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" 10 #include "extensions/browser/extension_system_provider.h" 11 #include "extensions/browser/extensions_browser_client.h" 12 13 namespace extensions { 14 15 // static GetForProfile(Profile * profile)16IdleManager* IdleManagerFactory::GetForProfile( 17 Profile* profile) { 18 return static_cast<IdleManager*>( 19 GetInstance()->GetServiceForBrowserContext(profile, true)); 20 } 21 22 // static GetInstance()23IdleManagerFactory* IdleManagerFactory::GetInstance() { 24 return Singleton<IdleManagerFactory>::get(); 25 } 26 IdleManagerFactory()27IdleManagerFactory::IdleManagerFactory() 28 : BrowserContextKeyedServiceFactory( 29 "IdleManager", 30 BrowserContextDependencyManager::GetInstance()) { 31 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 32 } 33 ~IdleManagerFactory()34IdleManagerFactory::~IdleManagerFactory() { 35 } 36 BuildServiceInstanceFor(content::BrowserContext * profile) const37KeyedService* IdleManagerFactory::BuildServiceInstanceFor( 38 content::BrowserContext* profile) const { 39 IdleManager* idle_manager = new IdleManager(static_cast<Profile*>(profile)); 40 idle_manager->Init(); 41 return idle_manager; 42 } 43 GetBrowserContextToUse(content::BrowserContext * context) const44content::BrowserContext* IdleManagerFactory::GetBrowserContextToUse( 45 content::BrowserContext* context) const { 46 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); 47 } 48 ServiceIsCreatedWithBrowserContext() const49bool IdleManagerFactory::ServiceIsCreatedWithBrowserContext() const { 50 return true; 51 } 52 ServiceIsNULLWhileTesting() const53bool IdleManagerFactory::ServiceIsNULLWhileTesting() const { 54 return true; 55 } 56 57 } // namespace extensions 58