#include "chrome/browser/bluetooth/bluetooth_chooser_context_factory.h"
#include "base/no_destructor.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/permissions/contexts/bluetooth_chooser_context.h"
BluetoothChooserContextFactory* BluetoothChooserContextFactory::GetInstance() {
static base::NoDestructor<BluetoothChooserContextFactory> factory;
return factory.get();
}
permissions::BluetoothChooserContext*
BluetoothChooserContextFactory::GetForProfile(Profile* profile) {
return static_cast<permissions::BluetoothChooserContext*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
permissions::BluetoothChooserContext*
BluetoothChooserContextFactory::GetForProfileIfExists(Profile* profile) {
return static_cast<permissions::BluetoothChooserContext*>(
GetInstance()->GetServiceForBrowserContext(profile, false));
}
BluetoothChooserContextFactory::BluetoothChooserContextFactory()
: ProfileKeyedServiceFactory(
"BluetoothChooserContext",
ProfileSelections::Builder()
.WithRegular(ProfileSelection::kOwnInstance)
.WithGuest(ProfileSelection::kOwnInstance)
.WithAshInternals(ProfileSelection::kOwnInstance)
.Build()) {
DependsOn(HostContentSettingsMapFactory::GetInstance());
}
BluetoothChooserContextFactory::~BluetoothChooserContextFactory() = default;
std::unique_ptr<KeyedService>
BluetoothChooserContextFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const {
return std::make_unique<permissions::BluetoothChooserContext>(context);
}