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

Unified Diff: extensions/common/permissions/api_permission_set.h

Issue 795543002: Added PermissionIDSet to APIPermissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions_patch_1_static_initializer_fix
Patch Set: Removed unnecessary constructor and added tests for API permissions Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: extensions/common/permissions/api_permission_set.h
diff --git a/extensions/common/permissions/api_permission_set.h b/extensions/common/permissions/api_permission_set.h
index 64eb7bed0776d6d16dad6c0279d7ebc71361855b..3424975298d527273d2f0d1bb6047173f2cbfb7e 100644
--- a/extensions/common/permissions/api_permission_set.h
+++ b/extensions/common/permissions/api_permission_set.h
@@ -15,8 +15,9 @@ class ListValue;
namespace extensions {
-class Extension;
class APIPermissionSet;
+class Extension;
+class PermissionIDSet;
template<>
struct BaseSetOperatorsTraits<APIPermissionSet> {
@@ -60,6 +61,29 @@ class APIPermissionSet : public BaseSetOperators<APIPermissionSet> {
void AddImpliedPermissions();
};
+// An ID representing a single permission that belongs to an app or extension.
+//
+// Each PermissionID has a required ID to identify the permission. For most
+// permissions, this is all.
Yoyo Zhou 2014/12/11 00:54:11 nit: "this is all" is easy to misread. Maybe "ther
sashab 2014/12/11 04:15:36 Yeah... Couldn't think of a better way to say this
+//
+// Some more complex permissions have a parameter, which acts like an argument
+// for the permission. For example, host permissions might have the ID
+// kReadOnlyHost and the argument 'www.google.com' (the host which is
+// read-only). Parameters are passed to the permission message rules for this
+// permission, so they can affect the displayed message.
+//
+// TODO(sashab): Move this to the same file as PermissionIDSet once that moves
+// to its own file.
+class PermissionID : public std::pair<APIPermission::ID, base::string16> {
+ public:
+ PermissionID(APIPermission::ID id);
+ PermissionID(APIPermission::ID id, const base::string16& parameter);
+ virtual ~PermissionID();
+
+ const APIPermission::ID& id() const { return this->first; }
+ const base::string16& parameter() const { return this->second; }
+};
+
// A set of permissions for an app or extension. Used for passing around groups
// of permissions, such as required or optional permissions. Has convenience
// constructors so that it can be constructed inline.
@@ -83,7 +107,8 @@ class APIPermissionSet : public BaseSetOperators<APIPermissionSet> {
// TODO(sashab): Move this to its own file and rename it to PermissionSet after
// APIPermission is removed, the current PermissionSet is no longer used, and
// APIPermission::ID is the only type of Permission ID.
-typedef std::pair<APIPermission::ID, base::string16> PermissionID;
+// TODO(sashab): Change BaseSetOperators to support storing plain objects
+// instead of pointers and change this to extend BaseSetOperators<PermissionID>.
class PermissionIDSet {
public:
PermissionIDSet();
@@ -100,13 +125,25 @@ class PermissionIDSet {
APIPermission::ID permission_two,
APIPermission::ID permission_three,
APIPermission::ID permission_four);
+ PermissionIDSet(APIPermission::ID permission_one,
+ APIPermission::ID permission_two,
+ APIPermission::ID permission_three,
+ APIPermission::ID permission_four,
+ APIPermission::ID permission_five);
+ PermissionIDSet(APIPermission::ID permission_one,
+ APIPermission::ID permission_two,
+ APIPermission::ID permission_three,
+ APIPermission::ID permission_four,
+ APIPermission::ID permission_five,
+ APIPermission::ID permission_six);
// Adds the given permission, and an optional permission detail, to the set.
- void insert(APIPermission::ID permission);
- void insert(APIPermission::ID permission, base::string16 permission_detail);
+ void insert(APIPermission::ID permission_id);
+ void insert(APIPermission::ID permission_id,
+ base::string16 permission_parameter);
Yoyo Zhou 2014/12/11 00:54:11 nit: Why rename this from detail? "detail" still a
sashab 2014/12/11 04:15:36 'parameter' now matches the name in PermissionID,
private:
- std::set<PermissionID> permissions;
+ std::set<PermissionID> permissions_;
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698