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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // manifest, |apis| and |hosts|. | 287 // manifest, |apis| and |hosts|. |
288 ExtensionPermissionSet(const Extension* extension, | 288 ExtensionPermissionSet(const Extension* extension, |
289 const ExtensionAPIPermissionSet& apis, | 289 const ExtensionAPIPermissionSet& apis, |
290 const URLPatternSet& explicit_hosts); | 290 const URLPatternSet& explicit_hosts); |
291 | 291 |
292 // Creates a new permission set based on the specified data. | 292 // Creates a new permission set based on the specified data. |
293 ExtensionPermissionSet(const ExtensionAPIPermissionSet& apis, | 293 ExtensionPermissionSet(const ExtensionAPIPermissionSet& apis, |
294 const URLPatternSet& explicit_hosts, | 294 const URLPatternSet& explicit_hosts, |
295 const URLPatternSet& scriptable_hosts); | 295 const URLPatternSet& scriptable_hosts); |
296 | 296 |
297 ~ExtensionPermissionSet(); | |
298 | |
299 // Creates a new permission set equal to |set1| - |set2|, passing ownership of | 297 // Creates a new permission set equal to |set1| - |set2|, passing ownership of |
300 // the new set to the caller. | 298 // the new set to the caller. |
301 static ExtensionPermissionSet* CreateDifference( | 299 static ExtensionPermissionSet* CreateDifference( |
302 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); | 300 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); |
303 | 301 |
304 // Creates a new permission set equal to the intersection of |set1| and | 302 // Creates a new permission set equal to the intersection of |set1| and |
305 // |set2|, passing ownership of the new set to the caller. | 303 // |set2|, passing ownership of the new set to the caller. |
306 static ExtensionPermissionSet* CreateIntersection( | 304 static ExtensionPermissionSet* CreateIntersection( |
307 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); | 305 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); |
308 | 306 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 376 |
379 const URLPatternSet& effective_hosts() const { return effective_hosts_; } | 377 const URLPatternSet& effective_hosts() const { return effective_hosts_; } |
380 | 378 |
381 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; } | 379 const URLPatternSet& explicit_hosts() const { return explicit_hosts_; } |
382 | 380 |
383 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; } | 381 const URLPatternSet& scriptable_hosts() const { return scriptable_hosts_; } |
384 | 382 |
385 private: | 383 private: |
386 FRIEND_TEST_ALL_PREFIXES(ExtensionPermissionsTest, | 384 FRIEND_TEST_ALL_PREFIXES(ExtensionPermissionsTest, |
387 HasLessHostPrivilegesThan); | 385 HasLessHostPrivilegesThan); |
| 386 friend class base::RefCountedThreadSafe<ExtensionPermissionSet>; |
388 | 387 |
389 friend class base::RefCountedThreadSafe<ExtensionPermissionSet>; | 388 ~ExtensionPermissionSet(); |
390 | 389 |
391 static std::set<std::string> GetDistinctHosts( | 390 static std::set<std::string> GetDistinctHosts( |
392 const URLPatternSet& host_patterns, | 391 const URLPatternSet& host_patterns, |
393 bool include_rcd, | 392 bool include_rcd, |
394 bool exclude_file_scheme); | 393 bool exclude_file_scheme); |
395 | 394 |
396 // Initializes the set based on |extension|'s manifest data. | 395 // Initializes the set based on |extension|'s manifest data. |
397 void InitImplicitExtensionPermissions(const Extension* extension); | 396 void InitImplicitExtensionPermissions(const Extension* extension); |
398 | 397 |
399 // Initializes the effective host permission based on the data in this set. | 398 // Initializes the effective host permission based on the data in this set. |
(...skipping 22 matching lines...) Expand all Loading... |
422 | 421 |
423 // The list of hosts that can be scripted by content scripts. | 422 // The list of hosts that can be scripted by content scripts. |
424 // TODO(jstritar): Rename to "user_script_hosts_"? | 423 // TODO(jstritar): Rename to "user_script_hosts_"? |
425 URLPatternSet scriptable_hosts_; | 424 URLPatternSet scriptable_hosts_; |
426 | 425 |
427 // The list of hosts this effectively grants access to. | 426 // The list of hosts this effectively grants access to. |
428 URLPatternSet effective_hosts_; | 427 URLPatternSet effective_hosts_; |
429 }; | 428 }; |
430 | 429 |
431 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 430 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
OLD | NEW |