[ExtensionToolbarMac] Restrict action button drags to the container's bounds
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context_factory.cc
bloba87baa8250e74ed59e0633c3743918acd77c9523
1 // Copyright 2013 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/protected_media_identifier_permission_context_factory.h"
7 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "components/pref_registry/pref_registry_syncable.h"
15 namespace {
17 class Service : public KeyedService {
18 public:
19 explicit Service(Profile* profile) {
20 context_ = new ProtectedMediaIdentifierPermissionContext(profile);
23 ProtectedMediaIdentifierPermissionContext* context() {
24 return context_.get();
27 virtual void Shutdown() override {
28 context()->ShutdownOnUIThread();
31 private:
32 scoped_refptr<ProtectedMediaIdentifierPermissionContext> context_;
34 DISALLOW_COPY_AND_ASSIGN(Service);
37 } // namespace
39 // static
40 ProtectedMediaIdentifierPermissionContext*
41 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
42 Profile* profile) {
43 return static_cast<Service*>(
44 GetInstance()->GetServiceForBrowserContext(profile, true))->context();
47 // static
48 ProtectedMediaIdentifierPermissionContextFactory*
49 ProtectedMediaIdentifierPermissionContextFactory::GetInstance() {
50 return Singleton<
51 ProtectedMediaIdentifierPermissionContextFactory>::get();
54 ProtectedMediaIdentifierPermissionContextFactory::
55 ProtectedMediaIdentifierPermissionContextFactory()
56 : BrowserContextKeyedServiceFactory(
57 "ProtectedMediaIdentifierPermissionContext",
58 BrowserContextDependencyManager::GetInstance()) {
61 ProtectedMediaIdentifierPermissionContextFactory::
62 ~ProtectedMediaIdentifierPermissionContextFactory() {
65 KeyedService*
66 ProtectedMediaIdentifierPermissionContextFactory::BuildServiceInstanceFor(
67 content::BrowserContext* profile) const {
68 return new Service(static_cast<Profile*>(profile));
71 void
72 ProtectedMediaIdentifierPermissionContextFactory::RegisterProfilePrefs(
73 user_prefs::PrefRegistrySyncable* registry) {
74 registry->RegisterBooleanPref(
75 prefs::kProtectedMediaIdentifierEnabled,
76 true,
77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
80 content::BrowserContext*
81 ProtectedMediaIdentifierPermissionContextFactory::GetBrowserContextToUse(
82 content::BrowserContext* context) const {
83 return chrome::GetBrowserContextOwnInstanceInIncognito(context);