Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / permissions / permission_manager_factory.cc
blobfc12b7ae03da3cba8c6a5dd1d2dbe942d16cfcdb
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/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/permissions/permission_context.h"
9 #include "chrome/browser/permissions/permission_manager.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 // static
15 PermissionManager*
16 PermissionManagerFactory::GetForProfile(Profile* profile) {
17 return static_cast<PermissionManager*>(
18 GetInstance()->GetServiceForBrowserContext(profile, true));
21 // static
22 PermissionManagerFactory* PermissionManagerFactory::GetInstance() {
23 return base::Singleton<PermissionManagerFactory>::get();
26 PermissionManagerFactory::PermissionManagerFactory()
27 : BrowserContextKeyedServiceFactory(
28 "PermissionManagerFactory",
29 BrowserContextDependencyManager::GetInstance()) {
30 DependsOn(HostContentSettingsMapFactory::GetInstance());
31 for (KeyedServiceBaseFactory* factory : PermissionContext::GetFactories())
32 DependsOn(factory);
35 PermissionManagerFactory::~PermissionManagerFactory() {
38 KeyedService* PermissionManagerFactory::BuildServiceInstanceFor(
39 content::BrowserContext* context) const {
40 return new PermissionManager(Profile::FromBrowserContext(context));
43 content::BrowserContext*
44 PermissionManagerFactory::GetBrowserContextToUse(
45 content::BrowserContext* context) const {
46 return chrome::GetBrowserContextOwnInstanceInIncognito(context);