| Index: extensions/common/permissions/permissions_data.h
|
| diff --git a/extensions/common/permissions/permissions_data.h b/extensions/common/permissions/permissions_data.h
|
| index ba2f3c3aa54078bbca0e1843e7fc2ec9942e3e70..28007735db98769ede2fceecb0d349edb73bf46d 100644
|
| --- a/extensions/common/permissions/permissions_data.h
|
| +++ b/extensions/common/permissions/permissions_data.h
|
| @@ -43,6 +43,8 @@ class PermissionsData {
|
| // the given page.
|
| };
|
|
|
| + using TabPermissionsMap = std::map<int, scoped_refptr<const PermissionSet>>;
|
| +
|
| // Delegate class to allow different contexts (e.g. browser vs renderer) to
|
| // have control over policy decisions.
|
| class PolicyDelegate {
|
| @@ -115,15 +117,17 @@ class PermissionsData {
|
| APIPermission::ID permission,
|
| const APIPermission::CheckParam* param) const;
|
|
|
| - // TODO(rdevlin.cronin): GetEffectiveHostPermissions(), HasHostPermission(),
|
| - // and HasEffectiveAccessToAllHosts() are just forwards for the active
|
| + // Returns the hosts this extension effectively has access to, including
|
| + // explicit and scriptable hosts, and any hosts on tabs the extension has
|
| + // active tab permissions for.
|
| + URLPatternSet GetEffectiveHostPermissions() const;
|
| +
|
| + // TODO(rdevlin.cronin): HasHostPermission() and
|
| + // HasEffectiveAccessToAllHosts() are just forwards for the active
|
| // permissions. We should either get rid of these, and have callers use
|
| // active_permissions(), or should get rid of active_permissions(), and make
|
| // callers use PermissionsData for everything. We should not do both.
|
|
|
| - // Returns the effective hosts associated with the active permissions.
|
| - const URLPatternSet& GetEffectiveHostPermissions() const;
|
| -
|
| // Whether the extension has access to the given |url|.
|
| bool HasHostPermission(const GURL& url) const;
|
|
|
| @@ -201,16 +205,23 @@ class PermissionsData {
|
| bool CanCaptureVisiblePage(int tab_id, std::string* error) const;
|
|
|
| const scoped_refptr<const PermissionSet>& active_permissions() const {
|
| - // TODO(dcheng): What is the point of this lock?
|
| + // We lock so that we can't also be setting the permissions while returning.
|
| base::AutoLock auto_lock(runtime_lock_);
|
| return active_permissions_unsafe_;
|
| }
|
|
|
| const scoped_refptr<const PermissionSet>& withheld_permissions() const {
|
| - // TODO(dcheng): What is the point of this lock?
|
| + // We lock so that we can't also be setting the permissions while returning.
|
| + base::AutoLock auto_lock(runtime_lock_);
|
| return withheld_permissions_unsafe_;
|
| }
|
|
|
| + const TabPermissionsMap& tab_specific_permissions() const {
|
| + // We lock so that we can't also be setting the permissions while returning.
|
| + base::AutoLock auto_lock(runtime_lock_);
|
| + return tab_specific_permissions_;
|
| + }
|
| +
|
| #if defined(UNIT_TEST)
|
| scoped_refptr<const PermissionSet> GetTabSpecificPermissionsForTesting(
|
| int tab_id) const {
|
| @@ -219,8 +230,6 @@ class PermissionsData {
|
| #endif
|
|
|
| private:
|
| - typedef std::map<int, scoped_refptr<const PermissionSet> > TabPermissionsMap;
|
| -
|
| // Gets the tab-specific host permissions of |tab_id|, or NULL if there
|
| // aren't any.
|
| scoped_refptr<const PermissionSet> GetTabSpecificPermissions(
|
|
|