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/image_loader_factory.h" 6 7 #include "chrome/browser/extensions/image_loader.h" 8 #include "chrome/browser/profiles/incognito_helpers.h" 9 #include "chrome/browser/profiles/profile.h" 10 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h" 11 12 namespace extensions { 13 14 // static 15 ImageLoader* ImageLoaderFactory::GetForProfile(Profile* profile) { 16 return static_cast<ImageLoader*>( 17 GetInstance()->GetServiceForBrowserContext(profile, true)); 18 } 19 20 ImageLoaderFactory* ImageLoaderFactory::GetInstance() { 21 return Singleton<ImageLoaderFactory>::get(); 22 } 23 24 ImageLoaderFactory::ImageLoaderFactory() 25 : BrowserContextKeyedServiceFactory( 26 "ImageLoader", 27 BrowserContextDependencyManager::GetInstance()) { 28 } 29 30 ImageLoaderFactory::~ImageLoaderFactory() { 31 } 32 33 BrowserContextKeyedService* ImageLoaderFactory::BuildServiceInstanceFor( 34 content::BrowserContext* profile) const { 35 return new ImageLoader; 36 } 37 38 bool ImageLoaderFactory::ServiceIsCreatedWithBrowserContext() const { 39 return false; 40 } 41 42 content::BrowserContext* ImageLoaderFactory::GetBrowserContextToUse( 43 content::BrowserContext* context) const { 44 return chrome::GetBrowserContextRedirectedInIncognito(context); 45 } 46 47 } // namespace extensions 48