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

Side by Side Diff: chrome/common/extensions/permissions/permissions_info.h

Issue 10675007: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_
7 #pragma once
8
9 #include <map>
10 #include <set>
11 #include <string>
12
13 #include "base/memory/singleton.h"
14 #include "chrome/common/extensions/permissions/api_permission.h"
15 #include "chrome/common/extensions/permissions/permission_message.h"
16
17 namespace extensions {
18
19 // Singleton that holds the extension permission instances and provides static
20 // methods for accessing them.
21 class PermissionsInfo {
22 public:
23 // Returns a pointer to the singleton instance.
24 static PermissionsInfo* GetInstance();
25
26 // Returns the permission with the given |id|, and NULL if it doesn't exist.
27 APIPermission* GetByID(APIPermission::ID id);
28
29 // Returns the permission with the given |name|, and NULL if none
30 // exists.
31 APIPermission* GetByName(const std::string& name);
32
33 // Returns a set containing all valid api permission ids.
34 APIPermissionSet GetAll();
35
36 // Converts all the permission names in |permission_names| to permission ids.
37 APIPermissionSet GetAllByName(
38 const std::set<std::string>& permission_names);
39
40 // Gets the total number of API permissions.
41 size_t get_permission_count() { return permission_count_; }
42
43 private:
44 friend class APIPermission;
45
46 ~PermissionsInfo();
47 PermissionsInfo();
48
49 // Registers an |alias| for a given permission |name|.
50 void RegisterAlias(const char* name, const char* alias);
51
52 // Registers a permission with the specified attributes and flags.
53 APIPermission* RegisterPermission(
54 APIPermission::ID id,
55 const char* name,
56 int l10n_message_id,
57 PermissionMessage::ID message_id,
58 int flags);
59
60 // Maps permission ids to permissions.
61 typedef std::map<APIPermission::ID, APIPermission*> IDMap;
62
63 // Maps names and aliases to permissions.
64 typedef std::map<std::string, APIPermission*> NameMap;
65
66 IDMap id_map_;
67 NameMap name_map_;
68
69 size_t hosted_app_permission_count_;
70 size_t permission_count_;
71
72 friend struct DefaultSingletonTraits<PermissionsInfo>;
73 DISALLOW_COPY_AND_ASSIGN(PermissionsInfo);
74 };
75
76 } // namespace extensions
77
78 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSIONS_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698