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

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

Issue 293003008: Make ActiveScriptController use Active Tab-style permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_PERMISSIONS_DATA_H_ 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int tab_id); 83 int tab_id);
84 // Updates the tab-specific permissions of |tab_id| to include those from 84 // Updates the tab-specific permissions of |tab_id| to include those from
85 // |permissions|. 85 // |permissions|.
86 static void UpdateTabSpecificPermissions( 86 static void UpdateTabSpecificPermissions(
87 const Extension* extension, 87 const Extension* extension,
88 int tab_id, 88 int tab_id,
89 scoped_refptr<const PermissionSet> permissions); 89 scoped_refptr<const PermissionSet> permissions);
90 // Clears the tab-specific permissions of |tab_id|. 90 // Clears the tab-specific permissions of |tab_id|.
91 static void ClearTabSpecificPermissions(const Extension* extension, 91 static void ClearTabSpecificPermissions(const Extension* extension,
92 int tab_id); 92 int tab_id);
93 // Returns true if the |extension| has tab-specific permission to operate on
94 // the tab specified by |tab_id| with the given |url|.
95 // Note that if this returns false, it doesn't mean the extension can't run on
96 // the given tab, only that it does not have tab-specific permission to do so.
97 static bool HasTabSpecificPermission(const Extension* extension,
not at google - send to devlin 2014/05/21 20:10:20 this is not something I particularly want to expos
Devlin 2014/05/21 23:16:07 Done.
98 int tab_id,
99 const GURL& url);
93 100
94 // Returns true if the |extension| has the given |permission|. Prefer 101 // Returns true if the |extension| has the given |permission|. Prefer
95 // IsExtensionWithPermissionOrSuggestInConsole when developers may be using an 102 // IsExtensionWithPermissionOrSuggestInConsole when developers may be using an
96 // api that requires a permission they didn't know about, e.g. open web apis. 103 // api that requires a permission they didn't know about, e.g. open web apis.
97 // Note this does not include APIs with no corresponding permission, like 104 // Note this does not include APIs with no corresponding permission, like
98 // "runtime" or "browserAction". 105 // "runtime" or "browserAction".
99 // TODO(mpcomplete): drop the "API" from these names, it's confusing. 106 // TODO(mpcomplete): drop the "API" from these names, it's confusing.
100 static bool HasAPIPermission(const Extension* extension, 107 static bool HasAPIPermission(const Extension* extension,
101 APIPermission::ID permission); 108 APIPermission::ID permission);
102 static bool HasAPIPermission(const Extension* extension, 109 static bool HasAPIPermission(const Extension* extension,
(...skipping 25 matching lines...) Expand all
128 // Whether the |extension| has access to the given |url|. 135 // Whether the |extension| has access to the given |url|.
129 static bool HasHostPermission(const Extension* extension, const GURL& url); 136 static bool HasHostPermission(const Extension* extension, const GURL& url);
130 137
131 // Whether the |extension| has effective access to all hosts. This is true if 138 // Whether the |extension| has effective access to all hosts. This is true if
132 // there is a content script that matches all hosts, if there is a host 139 // there is a content script that matches all hosts, if there is a host
133 // permission grants access to all hosts (like <all_urls>) or an api 140 // permission grants access to all hosts (like <all_urls>) or an api
134 // permission that effectively grants access to all hosts (e.g. proxy, 141 // permission that effectively grants access to all hosts (e.g. proxy,
135 // network, etc.) 142 // network, etc.)
136 static bool HasEffectiveAccessToAllHosts(const Extension* extension); 143 static bool HasEffectiveAccessToAllHosts(const Extension* extension);
137 144
145 // Whether the extension has access to so many hosts that we should treat it
146 // as "all_hosts" for warning purposes.
147 // For example, '*://*.com/*'.
148 static bool HasAccessToMostHosts(const Extension* extension);
not at google - send to devlin 2014/05/21 20:10:20 same comment as the other HasAccessToMostHosts
Devlin 2014/05/21 23:16:07 Done.
149
138 // Returns the full list of permission messages that the given |extension| 150 // Returns the full list of permission messages that the given |extension|
139 // should display at install time. 151 // should display at install time.
140 static PermissionMessages GetPermissionMessages(const Extension* extension); 152 static PermissionMessages GetPermissionMessages(const Extension* extension);
141 // Returns the full list of permission messages that the given |extension| 153 // Returns the full list of permission messages that the given |extension|
142 // should display at install time. The messages are returned as strings 154 // should display at install time. The messages are returned as strings
143 // for convenience. 155 // for convenience.
144 static std::vector<base::string16> GetPermissionMessageStrings( 156 static std::vector<base::string16> GetPermissionMessageStrings(
145 const Extension* extension); 157 const Extension* extension);
146 158
147 // Returns the full list of permission details for messages that the given 159 // Returns the full list of permission details for messages that the given
(...skipping 24 matching lines...) Expand all
172 // Returns true if the |extension| is allowed to obtain the contents of a 184 // Returns true if the |extension| is allowed to obtain the contents of a
173 // page as an image. Since a page may contain sensitive information, this 185 // page as an image. Since a page may contain sensitive information, this
174 // is restricted to the extension's host permissions as well as the 186 // is restricted to the extension's host permissions as well as the
175 // extension page itself. 187 // extension page itself.
176 static bool CanCaptureVisiblePage(const Extension* extension, 188 static bool CanCaptureVisiblePage(const Extension* extension,
177 int tab_id, 189 int tab_id,
178 std::string* error); 190 std::string* error);
179 191
180 // Returns true if the user should be alerted that the |extension| is running 192 // Returns true if the user should be alerted that the |extension| is running
181 // a script. 193 // a script.
182 static bool RequiresActionForScriptExecution(const Extension* extension); 194 static bool RequiresActionForScriptExecution(const Extension* extension,
195 int tab_id,
196 const GURL& document_url);
183 197
184 // Parse the permissions of a given extension in the initialization process. 198 // Parse the permissions of a given extension in the initialization process.
185 bool ParsePermissions(Extension* extension, base::string16* error); 199 bool ParsePermissions(Extension* extension, base::string16* error);
186 200
187 // Ensure manifest handlers provide their custom manifest permissions. 201 // Ensure manifest handlers provide their custom manifest permissions.
188 void InitializeManifestPermissions(Extension* extension); 202 void InitializeManifestPermissions(Extension* extension);
189 203
190 // Finalize permissions after the initialization process completes. 204 // Finalize permissions after the initialization process completes.
191 void FinalizePermissions(Extension* extension); 205 void FinalizePermissions(Extension* extension);
192 206
(...skipping 19 matching lines...) Expand all
212 mutable scoped_refptr<const PermissionSet> active_permissions_; 226 mutable scoped_refptr<const PermissionSet> active_permissions_;
213 227
214 mutable TabPermissionsMap tab_specific_permissions_; 228 mutable TabPermissionsMap tab_specific_permissions_;
215 229
216 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 230 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
217 }; 231 };
218 232
219 } // namespace extensions 233 } // namespace extensions
220 234
221 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 235 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698