blob: 774e3a31fb92d04f8069aadd4de84c96e6680b0e [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/hid/hid_chooser_context_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/hid/hid_chooser_context.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
HidChooserContextFactory* HidChooserContextFactory::GetInstance() {
static base::NoDestructor<HidChooserContextFactory> factory;
return factory.get();
}
// static
HidChooserContext* HidChooserContextFactory::GetForProfile(Profile* profile) {
return static_cast<HidChooserContext*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
HidChooserContextFactory::HidChooserContextFactory()
: BrowserContextKeyedServiceFactory(
"HidChooserContext",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(HostContentSettingsMapFactory::GetInstance());
}
HidChooserContextFactory::~HidChooserContextFactory() = default;
KeyedService* HidChooserContextFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new HidChooserContext(Profile::FromBrowserContext(context));
}
content::BrowserContext* HidChooserContextFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}