Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/permissions/permission_context.cc

Issue 1207363002: Simplify permission-related code for Web Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/permissions/permission_context.h" 5 #include "chrome/browser/permissions/permission_context.h"
6 6
7 #include "chrome/browser/geolocation/geolocation_permission_context.h" 7 #include "chrome/browser/geolocation/geolocation_permission_context.h"
8 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 8 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
9 #include "chrome/browser/media/midi_permission_context.h" 9 #include "chrome/browser/media/midi_permission_context.h"
10 #include "chrome/browser/media/midi_permission_context_factory.h" 10 #include "chrome/browser/media/midi_permission_context_factory.h"
11 #include "chrome/browser/notifications/desktop_notification_service.h" 11 #include "chrome/browser/notifications/notification_permission_context.h"
12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 12 #include "chrome/browser/notifications/notification_permission_context_factory.h "
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/push_messaging/push_messaging_permission_context.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" 15 #include "chrome/browser/push_messaging/push_messaging_permission_context_factor y.h"
16 #include "content/public/browser/permission_type.h" 16 #include "content/public/browser/permission_type.h"
17 17
18 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 18 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
19 #include "chrome/browser/media/protected_media_identifier_permission_context.h" 19 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
20 #include "chrome/browser/media/protected_media_identifier_permission_context_fac tory.h" 20 #include "chrome/browser/media/protected_media_identifier_permission_context_fac tory.h"
21 #endif 21 #endif
22 22
23 using content::PermissionType; 23 using content::PermissionType;
24 24
25 // static 25 // static
26 PermissionContextBase* PermissionContext::Get(Profile* profile, 26 PermissionContextBase* PermissionContext::Get(Profile* profile,
27 PermissionType permission_type) { 27 PermissionType permission_type) {
28 // NOTE: the factories used in this method have to stay in sync with 28 // NOTE: the factories used in this method have to stay in sync with
29 // ::GetFactories() below. 29 // ::GetFactories() below.
30 switch (permission_type) { 30 switch (permission_type) {
31 case PermissionType::GEOLOCATION: 31 case PermissionType::GEOLOCATION:
32 return GeolocationPermissionContextFactory::GetForProfile(profile); 32 return GeolocationPermissionContextFactory::GetForProfile(profile);
33 case PermissionType::NOTIFICATIONS:
34 return DesktopNotificationServiceFactory::GetForProfile(profile);
35 case PermissionType::MIDI_SYSEX: 33 case PermissionType::MIDI_SYSEX:
36 return MidiPermissionContextFactory::GetForProfile(profile); 34 return MidiPermissionContextFactory::GetForProfile(profile);
35 case PermissionType::NOTIFICATIONS:
36 return NotificationPermissionContextFactory::GetForProfile(profile);
37 case PermissionType::PUSH_MESSAGING: 37 case PermissionType::PUSH_MESSAGING:
38 return PushMessagingPermissionContextFactory::GetForProfile(profile); 38 return PushMessagingPermissionContextFactory::GetForProfile(profile);
39 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 39 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
40 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 40 case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
41 return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( 41 return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
42 profile); 42 profile);
43 #endif 43 #endif
44 default: 44 default:
45 NOTREACHED() << "No PermissionContext associated with " 45 NOTREACHED() << "No PermissionContext associated with "
46 << static_cast<int>(permission_type); 46 << static_cast<int>(permission_type);
47 break; 47 break;
48 } 48 }
49 49
50 return nullptr; 50 return nullptr;
51 } 51 }
52 52
53 // static 53 // static
54 const std::list<KeyedServiceBaseFactory*>& PermissionContext::GetFactories() { 54 const std::list<KeyedServiceBaseFactory*>& PermissionContext::GetFactories() {
55 // NOTE: this list has to stay in sync with the factories used by ::Get(). 55 // NOTE: this list has to stay in sync with the factories used by ::Get().
56 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ()); 56 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ());
57 57
58 if (factories.empty()) { 58 if (factories.empty()) {
59 factories.push_back(GeolocationPermissionContextFactory::GetInstance()); 59 factories.push_back(GeolocationPermissionContextFactory::GetInstance());
60 factories.push_back(DesktopNotificationServiceFactory::GetInstance());
61 factories.push_back(MidiPermissionContextFactory::GetInstance()); 60 factories.push_back(MidiPermissionContextFactory::GetInstance());
61 factories.push_back(NotificationPermissionContextFactory::GetInstance());
62 factories.push_back(PushMessagingPermissionContextFactory::GetInstance()); 62 factories.push_back(PushMessagingPermissionContextFactory::GetInstance());
63 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 63 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
64 factories.push_back( 64 factories.push_back(
65 ProtectedMediaIdentifierPermissionContextFactory::GetInstance()); 65 ProtectedMediaIdentifierPermissionContextFactory::GetInstance());
66 #endif 66 #endif
67 } 67 }
68 68
69 return factories; 69 return factories;
70 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698