15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/profiles/incognito_helpers.h" 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/themes/theme_service_factory.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NTPResourceCache* NTPResourceCacheFactory::GetForProfile(Profile* profile) { 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return static_cast<NTPResourceCache*>( 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GetInstance()->GetServiceForBrowserContext(profile, true)); 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NTPResourceCacheFactory* NTPResourceCacheFactory::GetInstance() { 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return Singleton<NTPResourceCacheFactory>::get(); 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NTPResourceCacheFactory::NTPResourceCacheFactory() 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : BrowserContextKeyedServiceFactory( 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "NTPResourceCache", 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BrowserContextDependencyManager::GetInstance()) { 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(ENABLE_THEMES) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DependsOn(ThemeServiceFactory::GetInstance()); 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NTPResourceCacheFactory::~NTPResourceCacheFactory() {} 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)BrowserContextKeyedService* NTPResourceCacheFactory::BuildServiceInstanceFor( 36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::BrowserContext* profile) const { 37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return new NTPResourceCache(static_cast<Profile*>(profile)); 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 40c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)content::BrowserContext* NTPResourceCacheFactory::GetBrowserContextToUse( 41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::BrowserContext* context) const { 42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return chrome::GetBrowserContextRedirectedInIncognito(context); 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 44