1 // Copyright 2020 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/permissions/last_tab_standing_tracker_factory.h" 6 7 #include "base/memory/singleton.h" 8 #include "chrome/browser/permissions/last_tab_standing_tracker.h" 9 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/profile.h" 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" 12 GetForBrowserContext(content::BrowserContext * browser_context)13LastTabStandingTracker* LastTabStandingTrackerFactory::GetForBrowserContext( 14 content::BrowserContext* browser_context) { 15 return static_cast<LastTabStandingTracker*>( 16 GetInstance()->GetServiceForBrowserContext(browser_context, true)); 17 } 18 GetInstance()19LastTabStandingTrackerFactory* LastTabStandingTrackerFactory::GetInstance() { 20 return base::Singleton<LastTabStandingTrackerFactory>::get(); 21 } 22 LastTabStandingTrackerFactory()23LastTabStandingTrackerFactory::LastTabStandingTrackerFactory() 24 : BrowserContextKeyedServiceFactory( 25 "LastTabStandingTrackerKeyedService", 26 BrowserContextDependencyManager::GetInstance()) {} 27 28 LastTabStandingTrackerFactory::~LastTabStandingTrackerFactory() = default; 29 ServiceIsCreatedWithBrowserContext() const30bool LastTabStandingTrackerFactory::ServiceIsCreatedWithBrowserContext() const { 31 return true; 32 } 33 BuildServiceInstanceFor(content::BrowserContext * context) const34KeyedService* LastTabStandingTrackerFactory::BuildServiceInstanceFor( 35 content::BrowserContext* context) const { 36 return new LastTabStandingTracker(); 37 } 38 GetBrowserContextToUse(content::BrowserContext * context) const39content::BrowserContext* LastTabStandingTrackerFactory::GetBrowserContextToUse( 40 content::BrowserContext* context) const { 41 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 42 } 43