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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // Returns the parameters for all PermissionIDs in this set. | 130 // Returns the parameters for all PermissionIDs in this set. |
131 std::vector<base::string16> GetAllPermissionParameters() const; | 131 std::vector<base::string16> GetAllPermissionParameters() const; |
132 | 132 |
133 // Check if the set contains a permission with the given ID. | 133 // Check if the set contains a permission with the given ID. |
134 bool ContainsID(APIPermission::ID permission_id) const; | 134 bool ContainsID(APIPermission::ID permission_id) const; |
135 | 135 |
136 // Check if the set contains permissions with all the given IDs. | 136 // Check if the set contains permissions with all the given IDs. |
137 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; | 137 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; |
138 | 138 |
| 139 // Check if the set contains any permission with one of the given IDs. |
| 140 bool ContainsAnyID(const std::set<APIPermission::ID>& permission_ids) const; |
| 141 |
| 142 // Returns all the permissions in this set with the given ID. |
| 143 PermissionIDSet GetAllPermissionsWithID( |
| 144 APIPermission::ID permission_id) const; |
| 145 |
139 // Returns all the permissions in this set with one of the given IDs. | 146 // Returns all the permissions in this set with one of the given IDs. |
140 PermissionIDSet GetAllPermissionsWithIDs( | 147 PermissionIDSet GetAllPermissionsWithIDs( |
141 const std::set<APIPermission::ID>& permission_ids) const; | 148 const std::set<APIPermission::ID>& permission_ids) const; |
142 | 149 |
143 // Convenience functions for common set operations. | 150 // Convenience functions for common set operations. |
144 bool Includes(const PermissionIDSet& subset) const; | 151 bool Includes(const PermissionIDSet& subset) const; |
145 bool Equals(const PermissionIDSet& set) const; | 152 bool Equals(const PermissionIDSet& set) const; |
146 static PermissionIDSet Difference(const PermissionIDSet& set_1, | 153 static PermissionIDSet Difference(const PermissionIDSet& set_1, |
147 const PermissionIDSet& set_2); | 154 const PermissionIDSet& set_2); |
148 | 155 |
149 size_t size() const; | 156 size_t size() const; |
150 bool empty() const; | 157 bool empty() const; |
151 | 158 |
152 const_iterator begin() const { return permissions_.begin(); } | 159 const_iterator begin() const { return permissions_.begin(); } |
153 const_iterator end() const { return permissions_.end(); } | 160 const_iterator end() const { return permissions_.end(); } |
154 | 161 |
155 private: | 162 private: |
156 PermissionIDSet(const std::set<PermissionID>& permissions); | 163 PermissionIDSet(const std::set<PermissionID>& permissions); |
157 | 164 |
158 std::set<PermissionID> permissions_; | 165 std::set<PermissionID> permissions_; |
159 }; | 166 }; |
160 | 167 |
161 } // namespace extensions | 168 } // namespace extensions |
162 | 169 |
163 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ | 170 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ |
OLD | NEW |