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

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: Ben's 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Whether the |extension| has access to the given |url|. 128 // Whether the |extension| has access to the given |url|.
129 static bool HasHostPermission(const Extension* extension, const GURL& url); 129 static bool HasHostPermission(const Extension* extension, const GURL& url);
130 130
131 // Whether the |extension| has effective access to all hosts. This is true if 131 // 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 132 // 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 133 // permission grants access to all hosts (like <all_urls>) or an api
134 // permission that effectively grants access to all hosts (e.g. proxy, 134 // permission that effectively grants access to all hosts (e.g. proxy,
135 // network, etc.) 135 // network, etc.)
136 static bool HasEffectiveAccessToAllHosts(const Extension* extension); 136 static bool HasEffectiveAccessToAllHosts(const Extension* extension);
137 137
138 // Whether the extension has access to so many hosts that we should treat it
139 // as "all_hosts" for warning purposes.
140 // For example, '*://*.com/*'.
141 static bool ShouldWarnAllHosts(const Extension* extension);
142
138 // Returns the full list of permission messages that the given |extension| 143 // Returns the full list of permission messages that the given |extension|
139 // should display at install time. 144 // should display at install time.
140 static PermissionMessages GetPermissionMessages(const Extension* extension); 145 static PermissionMessages GetPermissionMessages(const Extension* extension);
141 // Returns the full list of permission messages that the given |extension| 146 // Returns the full list of permission messages that the given |extension|
142 // should display at install time. The messages are returned as strings 147 // should display at install time. The messages are returned as strings
143 // for convenience. 148 // for convenience.
144 static std::vector<base::string16> GetPermissionMessageStrings( 149 static std::vector<base::string16> GetPermissionMessageStrings(
145 const Extension* extension); 150 const Extension* extension);
146 151
147 // Returns the full list of permission details for messages that the given 152 // 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 177 // 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 178 // 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 179 // is restricted to the extension's host permissions as well as the
175 // extension page itself. 180 // extension page itself.
176 static bool CanCaptureVisiblePage(const Extension* extension, 181 static bool CanCaptureVisiblePage(const Extension* extension,
177 int tab_id, 182 int tab_id,
178 std::string* error); 183 std::string* error);
179 184
180 // Returns true if the user should be alerted that the |extension| is running 185 // Returns true if the user should be alerted that the |extension| is running
181 // a script. 186 // a script.
182 static bool RequiresActionForScriptExecution(const Extension* extension); 187 static bool RequiresActionForScriptExecution(const Extension* extension,
188 int tab_id,
189 const GURL& url);
183 190
184 // Parse the permissions of a given extension in the initialization process. 191 // Parse the permissions of a given extension in the initialization process.
185 bool ParsePermissions(Extension* extension, base::string16* error); 192 bool ParsePermissions(Extension* extension, base::string16* error);
186 193
187 // Ensure manifest handlers provide their custom manifest permissions. 194 // Ensure manifest handlers provide their custom manifest permissions.
188 void InitializeManifestPermissions(Extension* extension); 195 void InitializeManifestPermissions(Extension* extension);
189 196
190 // Finalize permissions after the initialization process completes. 197 // Finalize permissions after the initialization process completes.
191 void FinalizePermissions(Extension* extension); 198 void FinalizePermissions(Extension* extension);
192 199
193 private: 200 private:
194 struct InitialPermissions; 201 struct InitialPermissions;
195 typedef std::map<int, scoped_refptr<const PermissionSet> > TabPermissionsMap; 202 typedef std::map<int, scoped_refptr<const PermissionSet> > TabPermissionsMap;
196 203
204 // Returns true if the |extension| has tab-specific permission to operate on
205 // the tab specified by |tab_id| with the given |url|.
206 // Note that if this returns false, it doesn't mean the extension can't run on
207 // the given tab, only that it does not have tab-specific permission to do so.
208 static bool HasTabSpecificScriptPermission(const Extension* extension,
not at google - send to devlin 2014/05/21 23:33:45 well it seems like it can be in an anonymous names
Devlin 2014/05/22 15:52:14 Done.
209 int tab_id,
210 const GURL& url);
211
197 // Temporary permissions during the initialization process; NULL after 212 // Temporary permissions during the initialization process; NULL after
198 // initialization completes. 213 // initialization completes.
199 scoped_ptr<InitialPermissions> initial_required_permissions_; 214 scoped_ptr<InitialPermissions> initial_required_permissions_;
200 scoped_ptr<InitialPermissions> initial_optional_permissions_; 215 scoped_ptr<InitialPermissions> initial_optional_permissions_;
201 216
202 // The set of permissions the extension can request at runtime. 217 // The set of permissions the extension can request at runtime.
203 scoped_refptr<const PermissionSet> optional_permission_set_; 218 scoped_refptr<const PermissionSet> optional_permission_set_;
204 219
205 // The extension's required / default set of permissions. 220 // The extension's required / default set of permissions.
206 scoped_refptr<const PermissionSet> required_permission_set_; 221 scoped_refptr<const PermissionSet> required_permission_set_;
207 222
208 mutable base::Lock runtime_lock_; 223 mutable base::Lock runtime_lock_;
209 224
210 // The permission's which are currently active on the extension during 225 // The permission's which are currently active on the extension during
211 // runtime. 226 // runtime.
212 mutable scoped_refptr<const PermissionSet> active_permissions_; 227 mutable scoped_refptr<const PermissionSet> active_permissions_;
213 228
214 mutable TabPermissionsMap tab_specific_permissions_; 229 mutable TabPermissionsMap tab_specific_permissions_;
215 230
216 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 231 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
217 }; 232 };
218 233
219 } // namespace extensions 234 } // namespace extensions
220 235
221 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 236 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698