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

Unified Diff: extensions/common/permissions/permissions_data.h

Issue 890083002: [Extensions] Propagate activeTab hosts to extension background pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/extension_messages.cc ('k') | extensions/common/permissions/permissions_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « extensions/common/extension_messages.cc ('k') | extensions/common/permissions/permissions_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698