Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / permissions / permission_context.cc
blob2a4f80605b101a416764e53ef07c5d4170e1ca44
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_context.h"
7 #include "chrome/browser/geolocation/geolocation_permission_context.h"
8 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
9 #include "chrome/browser/media/media_stream_camera_permission_context_factory.h"
10 #include "chrome/browser/media/media_stream_device_permission_context.h"
11 #include "chrome/browser/media/media_stream_mic_permission_context_factory.h"
12 #include "chrome/browser/media/midi_permission_context.h"
13 #include "chrome/browser/media/midi_permission_context_factory.h"
14 #include "chrome/browser/notifications/notification_permission_context.h"
15 #include "chrome/browser/notifications/notification_permission_context_factory.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
18 #include "chrome/browser/push_messaging/push_messaging_permission_context_factory.h"
19 #include "chrome/browser/storage/durable_storage_permission_context.h"
20 #include "chrome/browser/storage/durable_storage_permission_context_factory.h"
21 #include "content/public/browser/permission_type.h"
23 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
24 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
25 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
26 #endif
28 using content::PermissionType;
30 // static
31 PermissionContextBase* PermissionContext::Get(Profile* profile,
32 PermissionType permission_type) {
33 // NOTE: the factories used in this method have to stay in sync with
34 // ::GetFactories() below.
35 switch (permission_type) {
36 case PermissionType::GEOLOCATION:
37 return GeolocationPermissionContextFactory::GetForProfile(profile);
38 case PermissionType::MIDI_SYSEX:
39 return MidiPermissionContextFactory::GetForProfile(profile);
40 case PermissionType::NOTIFICATIONS:
41 return NotificationPermissionContextFactory::GetForProfile(profile);
42 case PermissionType::PUSH_MESSAGING:
43 return PushMessagingPermissionContextFactory::GetForProfile(profile);
44 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
45 case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
46 return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
47 profile);
48 #endif
49 case content::PermissionType::DURABLE_STORAGE:
50 return DurableStoragePermissionContextFactory::GetForProfile(profile);
51 case PermissionType::MIDI:
52 // PermissionType::MIDI is a valid permission but does not have a
53 // permission context. It has a constant value instead.
54 break;
55 case PermissionType::AUDIO_CAPTURE:
56 return MediaStreamMicPermissionContextFactory::GetForProfile(profile);
57 case PermissionType::VIDEO_CAPTURE:
58 return MediaStreamCameraPermissionContextFactory::GetForProfile(profile);
59 default:
60 NOTREACHED() << "No PermissionContext associated with "
61 << static_cast<int>(permission_type);
62 break;
65 return nullptr;
68 // static
69 const std::list<KeyedServiceBaseFactory*>& PermissionContext::GetFactories() {
70 // NOTE: this list has to stay in sync with the factories used by ::Get().
71 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ());
73 if (factories.empty()) {
74 factories.push_back(GeolocationPermissionContextFactory::GetInstance());
75 factories.push_back(MidiPermissionContextFactory::GetInstance());
76 factories.push_back(NotificationPermissionContextFactory::GetInstance());
77 factories.push_back(PushMessagingPermissionContextFactory::GetInstance());
78 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
79 factories.push_back(
80 ProtectedMediaIdentifierPermissionContextFactory::GetInstance());
81 #endif
82 factories.push_back(DurableStoragePermissionContextFactory::GetInstance());
83 factories.push_back(MediaStreamMicPermissionContextFactory::GetInstance());
84 factories.push_back(
85 MediaStreamCameraPermissionContextFactory::GetInstance());
88 return factories;