OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Returns true if this permission can be added and removed via the | 189 // Returns true if this permission can be added and removed via the |
190 // optional permissions extension API. | 190 // optional permissions extension API. |
191 bool supports_optional() const { | 191 bool supports_optional() const { |
192 return (flags_ & kFlagCannotBeOptional) == 0; | 192 return (flags_ & kFlagCannotBeOptional) == 0; |
193 } | 193 } |
194 | 194 |
195 private: | 195 private: |
196 // Instances should only be constructed from within ExtensionPermissionsInfo. | 196 // Instances should only be constructed from within ExtensionPermissionsInfo. |
197 friend class ExtensionPermissionsInfo; | 197 friend class ExtensionPermissionsInfo; |
198 | 198 |
199 // Register ALL the permissions! | |
200 static void RegisterAllPermissions(ExtensionPermissionsInfo* info); | |
201 | |
202 explicit ExtensionAPIPermission( | 199 explicit ExtensionAPIPermission( |
203 ID id, | 200 ID id, |
204 const char* name, | 201 const char* name, |
205 int l10n_message_id, | 202 int l10n_message_id, |
206 ExtensionPermissionMessage::ID message_id, | 203 ExtensionPermissionMessage::ID message_id, |
207 int flags); | 204 int flags); |
208 | 205 |
| 206 // Register ALL the permissions! |
| 207 static void RegisterAllPermissions(ExtensionPermissionsInfo* info); |
| 208 |
209 ID id_; | 209 ID id_; |
210 const char* name_; | 210 const char* name_; |
211 int flags_; | 211 int flags_; |
212 int l10n_message_id_; | 212 int l10n_message_id_; |
213 ExtensionPermissionMessage::ID message_id_; | 213 ExtensionPermissionMessage::ID message_id_; |
214 }; | 214 }; |
215 | 215 |
216 typedef std::set<ExtensionAPIPermission::ID> ExtensionAPIPermissionSet; | 216 typedef std::set<ExtensionAPIPermission::ID> ExtensionAPIPermissionSet; |
217 | 217 |
218 // Singleton that holds the extension permission instances and provides static | 218 // Singleton that holds the extension permission instances and provides static |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 // Creates a new permission set that has oauth scopes in it. | 301 // Creates a new permission set that has oauth scopes in it. |
302 ExtensionPermissionSet(const ExtensionAPIPermissionSet& apis, | 302 ExtensionPermissionSet(const ExtensionAPIPermissionSet& apis, |
303 const URLPatternSet& explicit_hosts, | 303 const URLPatternSet& explicit_hosts, |
304 const URLPatternSet& scriptable_hosts, | 304 const URLPatternSet& scriptable_hosts, |
305 const ExtensionOAuth2Scopes& scopes); | 305 const ExtensionOAuth2Scopes& scopes); |
306 | 306 |
307 // Creates a new permission set containing only oauth scopes. | 307 // Creates a new permission set containing only oauth scopes. |
308 explicit ExtensionPermissionSet(const ExtensionOAuth2Scopes& scopes); | 308 explicit ExtensionPermissionSet(const ExtensionOAuth2Scopes& scopes); |
309 | 309 |
310 ~ExtensionPermissionSet(); | |
311 | |
312 // Creates a new permission set equal to |set1| - |set2|, passing ownership of | 310 // Creates a new permission set equal to |set1| - |set2|, passing ownership of |
313 // the new set to the caller. | 311 // the new set to the caller. |
314 static ExtensionPermissionSet* CreateDifference( | 312 static ExtensionPermissionSet* CreateDifference( |
315 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); | 313 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); |
316 | 314 |
317 // Creates a new permission set equal to the intersection of |set1| and | 315 // Creates a new permission set equal to the intersection of |set1| and |
318 // |set2|, passing ownership of the new set to the caller. | 316 // |set2|, passing ownership of the new set to the caller. |
319 static ExtensionPermissionSet* CreateIntersection( | 317 static ExtensionPermissionSet* CreateIntersection( |
320 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); | 318 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); |
321 | 319 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 391 |
394 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; } | 392 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; } |
395 | 393 |
396 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; } | 394 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; } |
397 | 395 |
398 const ExtensionOAuth2Scopes& scopes() const { return scopes_; } | 396 const ExtensionOAuth2Scopes& scopes() const { return scopes_; } |
399 | 397 |
400 private: | 398 private: |
401 FRIEND_TEST_ALL_PREFIXES(ExtensionPermissionsTest, | 399 FRIEND_TEST_ALL_PREFIXES(ExtensionPermissionsTest, |
402 HasLessHostPrivilegesThan); | 400 HasLessHostPrivilegesThan); |
| 401 friend class base::RefCountedThreadSafe<ExtensionPermissionSet>; |
403 | 402 |
404 friend class base::RefCountedThreadSafe<ExtensionPermissionSet>; | 403 ~ExtensionPermissionSet(); |
405 | 404 |
406 static std::set<std::string> GetDistinctHosts( | 405 static std::set<std::string> GetDistinctHosts( |
407 const URLPatternSet& host_patterns, | 406 const URLPatternSet& host_patterns, |
408 bool include_rcd, | 407 bool include_rcd, |
409 bool exclude_file_scheme); | 408 bool exclude_file_scheme); |
410 | 409 |
411 // Initializes the set based on |extension|'s manifest data. | 410 // Initializes the set based on |extension|'s manifest data. |
412 void InitImplicitExtensionPermissions(const Extension* extension); | 411 void InitImplicitExtensionPermissions(const Extension* extension); |
413 | 412 |
414 // Initializes the effective host permission based on the data in this set. | 413 // Initializes the effective host permission based on the data in this set. |
(...skipping 29 matching lines...) Expand all Loading... |
444 | 443 |
445 // The list of hosts this effectively grants access to. | 444 // The list of hosts this effectively grants access to. |
446 URLPatternSet effective_hosts_; | 445 URLPatternSet effective_hosts_; |
447 | 446 |
448 // A set of oauth2 scopes that are used by the identity API to create OAuth2 | 447 // A set of oauth2 scopes that are used by the identity API to create OAuth2 |
449 // tokens for accessing the Google Account of the signed-in sync account. | 448 // tokens for accessing the Google Account of the signed-in sync account. |
450 ExtensionOAuth2Scopes scopes_; | 449 ExtensionOAuth2Scopes scopes_; |
451 }; | 450 }; |
452 | 451 |
453 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 452 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
OLD | NEW |