| 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); |
| 119 PermissionIDSet(const PermissionIDSet& other); | 120 PermissionIDSet(const PermissionIDSet& other); |
| 120 virtual ~PermissionIDSet(); | 121 virtual ~PermissionIDSet(); |
| 121 | 122 |
| 122 // Adds the given permission, and an optional parameter, to the set. | 123 // Adds the given permission, and an optional parameter, to the set. |
| 123 void insert(APIPermission::ID permission_id); | 124 void insert(APIPermission::ID permission_id); |
| 124 void insert(APIPermission::ID permission_id, | 125 void insert(APIPermission::ID permission_id, |
| 125 const base::string16& permission_parameter); | 126 const base::string16& permission_parameter); |
| 126 void InsertAll(const PermissionIDSet& permission_set); | 127 void InsertAll(const PermissionIDSet& permission_set); |
| 127 | 128 |
| 128 // Erases all permissions with the given id. | 129 // Erases all permissions with the given id. |
| 129 void erase(APIPermission::ID permission_id); | 130 void erase(APIPermission::ID permission_id); |
| 130 | 131 |
| 131 // Returns the parameters for all PermissionIDs in this set. | 132 // Returns the parameters for all PermissionIDs in this set. |
| 132 std::vector<base::string16> GetAllPermissionParameters() const; | 133 std::vector<base::string16> GetAllPermissionParameters() const; |
| 133 | 134 |
| 134 // Check if the set contains a permission with the given ID. | 135 // Check if the set contains a permission with the given ID. |
| 136 bool ContainsID(PermissionID permission_id) const; |
| 135 bool ContainsID(APIPermission::ID permission_id) const; | 137 bool ContainsID(APIPermission::ID permission_id) const; |
| 136 | 138 |
| 137 // Check if the set contains permissions with all the given IDs. | 139 // Check if the set contains permissions with all the given IDs. |
| 138 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; | 140 bool ContainsAllIDs(const std::set<APIPermission::ID>& permission_ids) const; |
| 139 | 141 |
| 140 // Check if the set contains any permission with one of the given IDs. | 142 // Check if the set contains any permission with one of the given IDs. |
| 141 bool ContainsAnyID(const std::set<APIPermission::ID>& permission_ids) const; | 143 bool ContainsAnyID(const std::set<APIPermission::ID>& permission_ids) const; |
| 144 bool ContainsAnyID(const PermissionIDSet& other) const; |
| 142 | 145 |
| 143 // Returns all the permissions in this set with the given ID. | 146 // Returns all the permissions in this set with the given ID. |
| 144 PermissionIDSet GetAllPermissionsWithID( | 147 PermissionIDSet GetAllPermissionsWithID( |
| 145 APIPermission::ID permission_id) const; | 148 APIPermission::ID permission_id) const; |
| 146 | 149 |
| 147 // Returns all the permissions in this set with one of the given IDs. | 150 // Returns all the permissions in this set with one of the given IDs. |
| 148 PermissionIDSet GetAllPermissionsWithIDs( | 151 PermissionIDSet GetAllPermissionsWithIDs( |
| 149 const std::set<APIPermission::ID>& permission_ids) const; | 152 const std::set<APIPermission::ID>& permission_ids) const; |
| 150 | 153 |
| 151 // Convenience functions for common set operations. | 154 // Convenience functions for common set operations. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 162 | 165 |
| 163 private: | 166 private: |
| 164 explicit PermissionIDSet(const std::set<PermissionID>& permissions); | 167 explicit PermissionIDSet(const std::set<PermissionID>& permissions); |
| 165 | 168 |
| 166 std::set<PermissionID> permissions_; | 169 std::set<PermissionID> permissions_; |
| 167 }; | 170 }; |
| 168 | 171 |
| 169 } // namespace extensions | 172 } // namespace extensions |
| 170 | 173 |
| 171 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ | 174 #endif // EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_SET_H_ |
| OLD | NEW |