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

Side by Side Diff: extensions/common/permissions/permission_set.h

Issue 51433002: Enable permission warnings from ManifestHandlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 7 years, 1 month 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
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_PERMISSION_SET_H_ 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_SET_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_SET_H_ 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_SET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 14 matching lines...) Expand all
25 // The PermissionSet is an immutable class that encapsulates an 25 // The PermissionSet is an immutable class that encapsulates an
26 // extension's permissions. The class exposes set operations for combining and 26 // extension's permissions. The class exposes set operations for combining and
27 // manipulating the permissions. 27 // manipulating the permissions.
28 class PermissionSet 28 class PermissionSet
29 : public base::RefCountedThreadSafe<PermissionSet> { 29 : public base::RefCountedThreadSafe<PermissionSet> {
30 public: 30 public:
31 // Creates an empty permission set (e.g. default permissions). 31 // Creates an empty permission set (e.g. default permissions).
32 PermissionSet(); 32 PermissionSet();
33 33
34 // Creates a new permission set based on the specified data: the API 34 // Creates a new permission set based on the specified data: the API
35 // permissions, host permissions, and scriptable hosts. The effective hosts 35 // permissions, manifest key permissions, host permissions, and scriptable
36 // of the newly created permission set will be inferred from the given 36 // hosts. The effective hosts of the newly created permission set will be
37 // host permissions. 37 // inferred from the given host permissions.
38 PermissionSet(const APIPermissionSet& apis, 38 PermissionSet(const APIPermissionSet& apis,
39 const ManifestPermissionSet& manifest_permissions,
39 const URLPatternSet& explicit_hosts, 40 const URLPatternSet& explicit_hosts,
40 const URLPatternSet& scriptable_hosts); 41 const URLPatternSet& scriptable_hosts);
41 42
42 // Creates a new permission set equal to |set1| - |set2|, passing ownership of 43 // Creates a new permission set equal to |set1| - |set2|, passing ownership of
43 // the new set to the caller. 44 // the new set to the caller.
44 static PermissionSet* CreateDifference( 45 static PermissionSet* CreateDifference(
45 const PermissionSet* set1, const PermissionSet* set2); 46 const PermissionSet* set1, const PermissionSet* set2);
46 47
47 // Creates a new permission set equal to the intersection of |set1| and 48 // Creates a new permission set equal to the intersection of |set1| and
48 // |set2|, passing ownership of the new set to the caller. 49 // |set2|, passing ownership of the new set to the caller.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 // Returns true if this permission set includes effective access to |url|. 97 // Returns true if this permission set includes effective access to |url|.
97 bool HasEffectiveAccessToURL(const GURL& url) const; 98 bool HasEffectiveAccessToURL(const GURL& url) const;
98 99
99 // Returns true if this permission set effectively represents full access 100 // Returns true if this permission set effectively represents full access
100 // (e.g. native code). 101 // (e.g. native code).
101 bool HasEffectiveFullAccess() const; 102 bool HasEffectiveFullAccess() const;
102 103
103 const APIPermissionSet& apis() const { return apis_; } 104 const APIPermissionSet& apis() const { return apis_; }
104 105
106 const ManifestPermissionSet& manifest_permissions() const {
107 return manifest_permissions_;
108 }
109
105 const URLPatternSet& effective_hosts() const { return effective_hosts_; } 110 const URLPatternSet& effective_hosts() const { return effective_hosts_; }
106 111
107 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; } 112 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; }
108 113
109 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; } 114 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; }
110 115
111 private: 116 private:
112 FRIEND_TEST_ALL_PREFIXES(PermissionsTest, GetWarningMessages_AudioVideo); 117 FRIEND_TEST_ALL_PREFIXES(PermissionsTest, GetWarningMessages_AudioVideo);
113 friend class base::RefCountedThreadSafe<PermissionSet>; 118 friend class base::RefCountedThreadSafe<PermissionSet>;
114 119
115 ~PermissionSet(); 120 ~PermissionSet();
116 121
117 void AddAPIPermission(APIPermission::ID id); 122 void AddAPIPermission(APIPermission::ID id);
118 123
119 // Adds permissions implied independently of other context. 124 // Adds permissions implied independently of other context.
120 void InitImplicitPermissions(); 125 void InitImplicitPermissions();
121 126
122 // Initializes the effective host permission based on the data in this set. 127 // Initializes the effective host permission based on the data in this set.
123 void InitEffectiveHosts(); 128 void InitEffectiveHosts();
124 129
125 // The api list is used when deciding if an extension can access certain 130 // The api list is used when deciding if an extension can access certain
126 // extension APIs and features. 131 // extension APIs and features.
127 APIPermissionSet apis_; 132 APIPermissionSet apis_;
128 133
134 // The manifest key permission list is used when deciding if an extension
135 // can access certain extension APIs and features.
136 ManifestPermissionSet manifest_permissions_;
137
129 // The list of hosts that can be accessed directly from the extension. 138 // The list of hosts that can be accessed directly from the extension.
130 // TODO(jstritar): Rename to "hosts_"? 139 // TODO(jstritar): Rename to "hosts_"?
131 URLPatternSet explicit_hosts_; 140 URLPatternSet explicit_hosts_;
132 141
133 // The list of hosts that can be scripted by content scripts. 142 // The list of hosts that can be scripted by content scripts.
134 // TODO(jstritar): Rename to "user_script_hosts_"? 143 // TODO(jstritar): Rename to "user_script_hosts_"?
135 URLPatternSet scriptable_hosts_; 144 URLPatternSet scriptable_hosts_;
136 145
137 // The list of hosts this effectively grants access to. 146 // The list of hosts this effectively grants access to.
138 URLPatternSet effective_hosts_; 147 URLPatternSet effective_hosts_;
139 }; 148 };
140 149
141 } // namespace extensions 150 } // namespace extensions
142 151
143 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_SET_H_ 152 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698