1 // Copyright 2015 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.
5 #include "chrome/browser/media/media_stream_mic_permission_context_factory.h"
7 #include "chrome/browser/media/media_stream_device_permission_context.h"
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 MediaStreamMicPermissionContextFactory::MediaStreamMicPermissionContextFactory()
13 : BrowserContextKeyedServiceFactory(
14 "MediaStreamMicPermissionContext",
15 BrowserContextDependencyManager::GetInstance()) {}
17 MediaStreamMicPermissionContextFactory::
18 ~MediaStreamMicPermissionContextFactory() {}
20 KeyedService
* MediaStreamMicPermissionContextFactory::BuildServiceInstanceFor(
21 content::BrowserContext
* profile
) const {
22 return new MediaStreamDevicePermissionContext(
23 static_cast<Profile
*>(profile
), CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
);
26 content::BrowserContext
*
27 MediaStreamMicPermissionContextFactory::GetBrowserContextToUse(
28 content::BrowserContext
* context
) const {
29 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);
33 MediaStreamMicPermissionContextFactory
*
34 MediaStreamMicPermissionContextFactory::GetInstance() {
35 return base::Singleton
<MediaStreamMicPermissionContextFactory
>::get();
39 MediaStreamDevicePermissionContext
*
40 MediaStreamMicPermissionContextFactory::GetForProfile(Profile
* profile
) {
41 return static_cast<MediaStreamDevicePermissionContext
*>(
42 GetInstance()->GetServiceForBrowserContext(profile
, true));