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/ui/global_error/global_error_service_factory.h" 6 7 #include "chrome/browser/profiles/incognito_helpers.h" 8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/ui/global_error/global_error_service.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 12 // static GetForProfile(Profile * profile)13GlobalErrorService* GlobalErrorServiceFactory::GetForProfile(Profile* profile) { 14 return static_cast<GlobalErrorService*>( 15 GetInstance()->GetServiceForBrowserContext(profile, true)); 16 } 17 18 // static GetInstance()19GlobalErrorServiceFactory* GlobalErrorServiceFactory::GetInstance() { 20 return Singleton<GlobalErrorServiceFactory>::get(); 21 } 22 GlobalErrorServiceFactory()23GlobalErrorServiceFactory::GlobalErrorServiceFactory() 24 : BrowserContextKeyedServiceFactory( 25 "GlobalErrorService", 26 BrowserContextDependencyManager::GetInstance()) { 27 } 28 ~GlobalErrorServiceFactory()29GlobalErrorServiceFactory::~GlobalErrorServiceFactory() { 30 } 31 BuildServiceInstanceFor(content::BrowserContext * profile) const32KeyedService* GlobalErrorServiceFactory::BuildServiceInstanceFor( 33 content::BrowserContext* profile) const { 34 return new GlobalErrorService(static_cast<Profile*>(profile)); 35 } 36 GetBrowserContextToUse(content::BrowserContext * context) const37content::BrowserContext* GlobalErrorServiceFactory::GetBrowserContextToUse( 38 content::BrowserContext* context) const { 39 return chrome::GetBrowserContextRedirectedInIncognito(context); 40 } 41