| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ |
| 6 #define EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // base::ASCIIToUTF16("http://www.google.com")); | 109 // base::ASCIIToUTF16("http://www.google.com")); |
| 110 // | 110 // |
| 111 // TODO(sashab): Move this to its own file and rename it to PermissionSet after | 111 // TODO(sashab): Move this to its own file and rename it to PermissionSet after |
| 112 // APIPermission is removed, the current PermissionSet is no longer used, and | 112 // APIPermission is removed, the current PermissionSet is no longer used, and |
| 113 // APIPermission::ID is the only type of Permission ID. | 113 // APIPermission::ID is the only type of Permission ID. |
| 114 class PermissionIDSet { | 114 class PermissionIDSet { |
| 115 public: | 115 public: |
| 116 using const_iterator = std::set<PermissionID>::const_iterator; | 116 using const_iterator = std::set<PermissionID>::const_iterator; |
| 117 | 117 |
| 118 PermissionIDSet(); | 118 PermissionIDSet(); |
| 119 PermissionIDSet(std::initializer_list<APIPermission::ID> permissions); | |
| 120 PermissionIDSet(const PermissionIDSet& other); | 119 PermissionIDSet(const PermissionIDSet& other); |
| 121 virtual ~PermissionIDSet(); | 120 virtual ~PermissionIDSet(); |
| 122 | 121 |
| 123 // Adds the given permission, and an optional parameter, to the set. | 122 // Adds the given permission, and an optional parameter, to the set. |
| 124 void insert(APIPermission::ID permission_id); | 123 void insert(APIPermission::ID permission_id); |
| 125 void insert(APIPermission::ID permission_id, | 124 void insert(APIPermission::ID permission_id, |
| 126 const base::string16& permission_parameter); | 125 const base::string16& permission_parameter); |
| 127 void InsertAll(const PermissionIDSet& permission_set); | 126 void InsertAll(const PermissionIDSet& permission_set); |
| 128 | 127 |
| 129 // Erases all permissions with the given id. | 128 // Erases all permissions with the given id. |
| 130 void erase(APIPermission::ID permission_id); | 129 void erase(APIPermission::ID permission_id); |
| 131 | 130 |
| 132 // Returns the parameters for all PermissionIDs in this set. | 131 // Returns the parameters for all PermissionIDs in this set. |
| 133 std::vector<base::string16> GetAllPermissionParameters() const; | 132 std::vector<base::string16> GetAllPermissionParameters() const; |
| 134 | 133 |
| 135 // Check if the set contains a permission with the given ID. | 134 // Check if the set contains a permission with the given ID. |
| 136 bool ContainsID(PermissionID permission_id) const; | |
| 137 bool ContainsID(APIPermission::ID permission_id) const; | 135 bool ContainsID(APIPermission::ID permission_id) const; |
| 138 | 136 |
| 139 // Check if the set contains permissions with all the given IDs. | 137 // Check if the set contains permissions with all the given IDs. |
| 140 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; | 138 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; |
| 141 | 139 |
| 142 // Check if the set contains any permission with one of the given IDs. | 140 // Check if the set contains any permission with one of the given IDs. |
| 143 bool ContainsAnyID(const std::set<APIPermission::ID>& permission_ids) const; | 141 bool ContainsAnyID(const std::set<APIPermission::ID>& permission_ids) const; |
| 144 bool ContainsAnyID(const PermissionIDSet& other) const; | |
| 145 | 142 |
| 146 // Returns all the permissions in this set with the given ID. | 143 // Returns all the permissions in this set with the given ID. |
| 147 PermissionIDSet GetAllPermissionsWithID( | 144 PermissionIDSet GetAllPermissionsWithID( |
| 148 APIPermission::ID permission_id) const; | 145 APIPermission::ID permission_id) const; |
| 149 | 146 |
| 150 // Returns all the permissions in this set with one of the given IDs. | 147 // Returns all the permissions in this set with one of the given IDs. |
| 151 PermissionIDSet GetAllPermissionsWithIDs( | 148 PermissionIDSet GetAllPermissionsWithIDs( |
| 152 const std::set<APIPermission::ID>& permission_ids) const; | 149 const std::set<APIPermission::ID>& permission_ids) const; |
| 153 | 150 |
| 154 // Convenience functions for common set operations. | 151 // Convenience functions for common set operations. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 | 162 |
| 166 private: | 163 private: |
| 167 explicit PermissionIDSet(const std::set<PermissionID>& permissions); | 164 explicit PermissionIDSet(const std::set<PermissionID>& permissions); |
| 168 | 165 |
| 169 std::set<PermissionID> permissions_; | 166 std::set<PermissionID> permissions_; |
| 170 }; | 167 }; |
| 171 | 168 |
| 172 } // namespace extensions | 169 } // namespace extensions |
| 173 | 170 |
| 174 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ | 171 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ |
| OLD | NEW |