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

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

Issue 10692160: Support socket endpoint permissions for AppsV2 Socket API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase and fix a unit test Created 8 years, 4 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_API_PERMISSION_SET_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_SET_H_
7
8 #include <iterator>
9 #include <map>
10
11 #include "chrome/common/extensions/permissions/api_permission.h"
12
13 namespace extensions {
14
15 typedef std::map<APIPermission::ID,
16 scoped_refptr<APIPermissionDetail> > APIPermissionMap;
17
18 class APIPermissionSet {
19 public:
20 class const_iterator :
21 public std::iterator<
22 std::input_iterator_tag,
23 scoped_refptr<APIPermissionDetail> > {
24 public:
25 const_iterator(const APIPermissionMap::const_iterator& it);
26 const_iterator(const const_iterator& ids_it);
27
28 const_iterator& operator++() {
29 ++it_;
30 return *this;
31 }
32
33 const_iterator operator++(int) {
34 const_iterator tmp(it_++);
35 return tmp;
36 }
37
38 bool operator==(const const_iterator& rhs) const {
39 return it_ == rhs.it_;
40 }
41
42 bool operator!=(const const_iterator& rhs) const {
43 return it_ != rhs.it_;
44 }
45
46 const scoped_refptr<APIPermissionDetail>& operator*() const {
47 return it_->second;
48 }
49
50 const scoped_refptr<APIPermissionDetail>& operator->() const {
51 return it_->second;
52 }
53
54 private:
55 APIPermissionMap::const_iterator it_;
56 };
57
58 APIPermissionSet();
59
60 APIPermissionSet(const APIPermissionSet& set);
61
62 ~APIPermissionSet();
63
64 const_iterator begin() const {
65 return const_iterator(map().begin());
66 }
67
68 const_iterator end() const {
69 return map().end();
70 }
71
72 const_iterator find(APIPermission::ID id) const {
73 return map().find(id);
74 }
75
76 const APIPermissionMap& map() const {
77 return map_;
78 }
79
80 APIPermissionMap& map() {
81 return map_;
82 }
83
84 void clear() {
85 map_.clear();
86 }
87
88 size_t count(APIPermission::ID id) const {
89 return map().count(id);
90 }
91
92 bool empty() const {
93 return map().empty();
94 }
95
96 size_t erase(APIPermission::ID id) {
97 return map().erase(id);
98 }
99
100 size_t size() const {
101 return map().size();
102 }
103
104 APIPermissionSet& operator=(const APIPermissionSet& rhs);
105
106 bool operator==(const APIPermissionSet& rhs) const;
107
108 bool operator!=(const APIPermissionSet& rhs) const {
109 return !operator==(rhs);
110 }
111
112 void insert(APIPermission::ID id);
113 void insert(const scoped_refptr<APIPermissionDetail>& detail);
114
115 bool Contains(const APIPermissionSet& rhs) const;
116
117 static void Difference(
118 const APIPermissionSet& set1,
119 const APIPermissionSet& set2,
120 APIPermissionSet* set3);
121
122 static void Intersection(
123 const APIPermissionSet& set1,
124 const APIPermissionSet& set2,
125 APIPermissionSet* set3);
126
127 static void Union(
128 const APIPermissionSet& set1,
129 const APIPermissionSet& set2,
130 APIPermissionSet* set3);
131
132 private:
133 APIPermissionMap map_;
134 };
135
136 } // namespace extensions
137
138 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_SET_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/api_permission.cc ('k') | chrome/common/extensions/permissions/api_permission_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698