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/permissions/permission_manager_factory.h"
7 #include "chrome/browser/permissions/permission_context.h"
8 #include "chrome/browser/permissions/permission_manager.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"
15 PermissionManagerFactory::GetForProfile(Profile
* profile
) {
16 return static_cast<PermissionManager
*>(
17 GetInstance()->GetServiceForBrowserContext(profile
, true));
21 PermissionManagerFactory
* PermissionManagerFactory::GetInstance() {
22 return Singleton
<PermissionManagerFactory
>::get();
25 PermissionManagerFactory::PermissionManagerFactory()
26 : BrowserContextKeyedServiceFactory(
27 "PermissionManagerFactory",
28 BrowserContextDependencyManager::GetInstance()) {
29 for (KeyedServiceBaseFactory
* factory
: PermissionContext::GetFactories())
33 PermissionManagerFactory::~PermissionManagerFactory() {
36 KeyedService
* PermissionManagerFactory::BuildServiceInstanceFor(
37 content::BrowserContext
* context
) const {
38 return new PermissionManager(Profile::FromBrowserContext(context
));
41 content::BrowserContext
*
42 PermissionManagerFactory::GetBrowserContextToUse(
43 content::BrowserContext
* context
) const {
44 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);