OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/content_settings/permission_context.h" |
| 6 |
| 7 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 8 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| 9 #include "chrome/browser/media/midi_permission_context.h" |
| 10 #include "chrome/browser/media/midi_permission_context_factory.h" |
| 11 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" |
| 15 #include "chrome/browser/push_messaging/push_messaging_permission_context_factor
y.h" |
| 16 |
| 17 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 18 #include "chrome/browser/media/protected_media_identifier_permission_context.h" |
| 19 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" |
| 20 #endif |
| 21 |
| 22 // static |
| 23 PermissionContextBase* PermissionContext::Get( |
| 24 Profile* profile, |
| 25 ContentSettingsType content_settings_type) { |
| 26 // NOTE: the factories used in this method have to stay in sync with |
| 27 // ::GetFactories() below. |
| 28 switch (content_settings_type) { |
| 29 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 30 return GeolocationPermissionContextFactory::GetForProfile(profile); |
| 31 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 32 return DesktopNotificationServiceFactory::GetForProfile(profile); |
| 33 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 34 return MidiPermissionContextFactory::GetForProfile(profile); |
| 35 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 36 return PushMessagingPermissionContextFactory::GetForProfile(profile); |
| 37 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 38 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 39 return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( |
| 40 profile); |
| 41 #endif |
| 42 default: |
| 43 NOTREACHED() << "No PermissionContext associated with " |
| 44 << content_settings_type; |
| 45 break; |
| 46 } |
| 47 |
| 48 return nullptr; |
| 49 } |
| 50 |
| 51 // static |
| 52 std::list<KeyedServiceBaseFactory*> PermissionContext::GetFactories() { |
| 53 // NOTE: this list has to stay in sync with the factories used by ::Get(). |
| 54 return { |
| 55 GeolocationPermissionContextFactory::GetInstance(), |
| 56 DesktopNotificationServiceFactory::GetInstance(), |
| 57 MidiPermissionContextFactory::GetInstance(), |
| 58 PushMessagingPermissionContextFactory::GetInstance(), |
| 59 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 60 ProtectedMediaIdentifierPermissionContextFactory::GetInstance(), |
| 61 #endif |
| 62 }; |
| 63 } |
OLD | NEW |