OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ |
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ | 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
| 12 #include "base/callback.h" |
12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
13 #include "chrome/common/extensions/permissions/api_permission.h" | 14 #include "chrome/common/extensions/permissions/api_permission.h" |
| 15 #include "chrome/common/extensions/permissions/api_permission_set.h" |
14 #include "chrome/common/extensions/permissions/permission_message.h" | 16 #include "chrome/common/extensions/permissions/permission_message.h" |
15 | 17 |
16 namespace extensions { | 18 namespace extensions { |
17 | 19 |
18 // Singleton that holds the extension permission instances and provides static | 20 // Singleton that holds the extension permission instances and provides static |
19 // methods for accessing them. | 21 // methods for accessing them. |
20 class PermissionsInfo { | 22 class PermissionsInfo { |
21 public: | 23 public: |
22 // Returns a pointer to the singleton instance. | 24 // Returns a pointer to the singleton instance. |
23 static PermissionsInfo* GetInstance(); | 25 static PermissionsInfo* GetInstance(); |
(...skipping 23 matching lines...) Expand all Loading... |
47 | 49 |
48 // Registers an |alias| for a given permission |name|. | 50 // Registers an |alias| for a given permission |name|. |
49 void RegisterAlias(const char* name, const char* alias); | 51 void RegisterAlias(const char* name, const char* alias); |
50 | 52 |
51 // Registers a permission with the specified attributes and flags. | 53 // Registers a permission with the specified attributes and flags. |
52 APIPermission* RegisterPermission( | 54 APIPermission* RegisterPermission( |
53 APIPermission::ID id, | 55 APIPermission::ID id, |
54 const char* name, | 56 const char* name, |
55 int l10n_message_id, | 57 int l10n_message_id, |
56 PermissionMessage::ID message_id, | 58 PermissionMessage::ID message_id, |
57 int flags); | 59 int flags, |
| 60 const APIPermission::DetailConstructor detail_constructor); |
58 | 61 |
59 // Maps permission ids to permissions. | 62 // Maps permission ids to permissions. |
60 typedef std::map<APIPermission::ID, APIPermission*> IDMap; | 63 typedef std::map<APIPermission::ID, APIPermission*> IDMap; |
61 | 64 |
62 // Maps names and aliases to permissions. | 65 // Maps names and aliases to permissions. |
63 typedef std::map<std::string, APIPermission*> NameMap; | 66 typedef std::map<std::string, APIPermission*> NameMap; |
64 | 67 |
65 IDMap id_map_; | 68 IDMap id_map_; |
66 NameMap name_map_; | 69 NameMap name_map_; |
67 | 70 |
68 size_t hosted_app_permission_count_; | 71 size_t hosted_app_permission_count_; |
69 size_t permission_count_; | 72 size_t permission_count_; |
70 | 73 |
71 friend struct DefaultSingletonTraits<PermissionsInfo>; | 74 friend struct DefaultSingletonTraits<PermissionsInfo>; |
72 DISALLOW_COPY_AND_ASSIGN(PermissionsInfo); | 75 DISALLOW_COPY_AND_ASSIGN(PermissionsInfo); |
73 }; | 76 }; |
74 | 77 |
75 } // namespace extensions | 78 } // namespace extensions |
76 | 79 |
77 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ | 80 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_ |
OLD | NEW |