1 // Copyright 2019 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/bluetooth/bluetooth_chooser_context_factory.h" 6 7 #include "chrome/browser/bluetooth/bluetooth_chooser_context.h" 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.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 13 // static GetInstance()14BluetoothChooserContextFactory* BluetoothChooserContextFactory::GetInstance() { 15 static base::NoDestructor<BluetoothChooserContextFactory> factory; 16 return factory.get(); 17 } 18 19 // static GetForProfile(Profile * profile)20BluetoothChooserContext* BluetoothChooserContextFactory::GetForProfile( 21 Profile* profile) { 22 return static_cast<BluetoothChooserContext*>( 23 GetInstance()->GetServiceForBrowserContext(profile, /*create=*/true)); 24 } 25 BluetoothChooserContextFactory()26BluetoothChooserContextFactory::BluetoothChooserContextFactory() 27 : BrowserContextKeyedServiceFactory( 28 "BluetoothChooserContext", 29 BrowserContextDependencyManager::GetInstance()) { 30 DependsOn(HostContentSettingsMapFactory::GetInstance()); 31 } 32 33 BluetoothChooserContextFactory::~BluetoothChooserContextFactory() = default; 34 BuildServiceInstanceFor(content::BrowserContext * context) const35KeyedService* BluetoothChooserContextFactory::BuildServiceInstanceFor( 36 content::BrowserContext* context) const { 37 return new BluetoothChooserContext(Profile::FromBrowserContext(context)); 38 } 39 GetBrowserContextToUse(content::BrowserContext * context) const40content::BrowserContext* BluetoothChooserContextFactory::GetBrowserContextToUse( 41 content::BrowserContext* context) const { 42 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 43 } 44