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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 4 years, 1 month 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
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 <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // with the given |extension_id|. 75 // with the given |extension_id|.
76 static bool ShouldSkipPermissionWarnings(const std::string& extension_id); 76 static bool ShouldSkipPermissionWarnings(const std::string& extension_id);
77 77
78 // Returns true if the given |url| is restricted for the given |extension|, 78 // Returns true if the given |url| is restricted for the given |extension|,
79 // as is commonly the case for chrome:// urls. 79 // as is commonly the case for chrome:// urls.
80 // NOTE: You probably want to use CanAccessPage(). 80 // NOTE: You probably want to use CanAccessPage().
81 static bool IsRestrictedUrl(const GURL& document_url, 81 static bool IsRestrictedUrl(const GURL& document_url,
82 const Extension* extension, 82 const Extension* extension,
83 std::string* error); 83 std::string* error);
84 84
85 // Check if a specific URL is blocked by policy from extension use at runtime.
86 bool IsRuntimeBlockedHost(const GURL& url) const;
Devlin 2016/11/23 17:22:56 Why does this need to be public?
nrpeter 2017/01/02 19:57:45 Not all API calls / events that disclose informati
87
85 // Locks the permissions data to the current thread. We don't do this on 88 // Locks the permissions data to the current thread. We don't do this on
86 // construction, since extensions are initialized across multiple threads. 89 // construction, since extensions are initialized across multiple threads.
87 void BindToCurrentThread() const; 90 void BindToCurrentThread() const;
88 91
89 // Sets the runtime permissions of the given |extension| to |active| and 92 // Sets the runtime permissions of the given |extension| to |active| and
90 // |withheld|. 93 // |withheld|.
91 void SetPermissions(std::unique_ptr<const PermissionSet> active, 94 void SetPermissions(std::unique_ptr<const PermissionSet> active,
92 std::unique_ptr<const PermissionSet> withheld) const; 95 std::unique_ptr<const PermissionSet> withheld) const;
93 96
97 // Sets the runtime policy of the given |extension|.
98 void SetRuntimeBlockedAllowedHosts(
99 const URLPatternSet runtime_blocked_hosts,
100 const URLPatternSet runtime_allowed_hosts) const;
101
94 // Sets the active permissions, leaving withheld the same. 102 // Sets the active permissions, leaving withheld the same.
95 void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const; 103 void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const;
96 104
97 // Updates the tab-specific permissions of |tab_id| to include those from 105 // Updates the tab-specific permissions of |tab_id| to include those from
98 // |permissions|. 106 // |permissions|.
99 void UpdateTabSpecificPermissions(int tab_id, 107 void UpdateTabSpecificPermissions(int tab_id,
100 const PermissionSet& permissions) const; 108 const PermissionSet& permissions) const;
101 109
102 // Clears the tab-specific permissions of |tab_id|. 110 // Clears the tab-specific permissions of |tab_id|.
103 void ClearTabSpecificPermissions(int tab_id) const; 111 void ClearTabSpecificPermissions(int tab_id) const;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 const PermissionSet& active_permissions() const { 202 const PermissionSet& active_permissions() const {
195 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); 203 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
196 return *active_permissions_unsafe_; 204 return *active_permissions_unsafe_;
197 } 205 }
198 206
199 const PermissionSet& withheld_permissions() const { 207 const PermissionSet& withheld_permissions() const {
200 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); 208 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
201 return *withheld_permissions_unsafe_; 209 return *withheld_permissions_unsafe_;
202 } 210 }
203 211
212 const URLPatternSet& runtime_blocked_hosts() const {
Devlin 2016/11/23 17:22:56 ditto
nrpeter 2017/01/02 19:57:45 This is used during the renderer_startup_helper to
213 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
214 return runtime_blocked_hosts_unsafe_;
215 }
216
217 const URLPatternSet& runtime_allowed_hosts() const {
218 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
219 return runtime_allowed_hosts_unsafe_;
220 }
221
204 #if defined(UNIT_TEST) 222 #if defined(UNIT_TEST)
205 const PermissionSet* GetTabSpecificPermissionsForTesting(int tab_id) const { 223 const PermissionSet* GetTabSpecificPermissionsForTesting(int tab_id) const {
206 base::AutoLock auto_lock(runtime_lock_); 224 base::AutoLock auto_lock(runtime_lock_);
207 return GetTabSpecificPermissions(tab_id); 225 return GetTabSpecificPermissions(tab_id);
208 } 226 }
209 #endif 227 #endif
210 228
211 private: 229 private:
212 // Gets the tab-specific host permissions of |tab_id|, or NULL if there 230 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
213 // aren't any. 231 // aren't any.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // active_permissions() accessor. 266 // active_permissions() accessor.
249 mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_; 267 mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_;
250 268
251 // The permissions the extension requested, but was not granted due because 269 // The permissions the extension requested, but was not granted due because
252 // they are too powerful. This includes things like all_hosts. 270 // they are too powerful. This includes things like all_hosts.
253 // Unsafe indicates that we must lock anytime this is directly accessed. 271 // Unsafe indicates that we must lock anytime this is directly accessed.
254 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe) 272 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe)
255 // withheld_permissions() accessor. 273 // withheld_permissions() accessor.
256 mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_; 274 mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_;
257 275
276 // The list of hosts an extension may not interact with by policy.
277 // Unless you need to change |runtime_blocked_hosts_unsafe_|, use the (safe)
278 // runtime_blocked_hosts() accessor.
279 mutable URLPatternSet runtime_blocked_hosts_unsafe_;
Devlin 2016/11/23 17:22:56 Do we need this for each extension? It seems like
nrpeter 2017/01/02 19:57:45 Done.
280
281 // The exclusive list of hosts an extension may interact with by policy.
282 // Unless you need to change |runtime_allowed_hosts_unsafe_|, use the (safe)
283 // runtime_allowed_hosts() accessor.
284 mutable URLPatternSet runtime_allowed_hosts_unsafe_;
285
258 mutable TabPermissionsMap tab_specific_permissions_; 286 mutable TabPermissionsMap tab_specific_permissions_;
259 287
260 mutable std::unique_ptr<base::ThreadChecker> thread_checker_; 288 mutable std::unique_ptr<base::ThreadChecker> thread_checker_;
261 289
262 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 290 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
263 }; 291 };
264 292
265 } // namespace extensions 293 } // namespace extensions
266 294
267 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 295 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698