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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: URLPatternSets use shared memory for IPC. Default scope patterns sent once per renderer. Created 4 years 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;
87
88 // Is this extension using the default scope for runtime_blocked_hosts and
89 // runtime_allowed_hosts of the ExtensionSettings policy.
90 bool IsRuntimeBlockedAllowedHostsDefault() const;
91
85 // Locks the permissions data to the current thread. We don't do this on 92 // Locks the permissions data to the current thread. We don't do this on
86 // construction, since extensions are initialized across multiple threads. 93 // construction, since extensions are initialized across multiple threads.
87 void BindToCurrentThread() const; 94 void BindToCurrentThread() const;
88 95
89 // Sets the runtime permissions of the given |extension| to |active| and 96 // Sets the runtime permissions of the given |extension| to |active| and
90 // |withheld|. 97 // |withheld|.
91 void SetPermissions(std::unique_ptr<const PermissionSet> active, 98 void SetPermissions(std::unique_ptr<const PermissionSet> active,
92 std::unique_ptr<const PermissionSet> withheld) const; 99 std::unique_ptr<const PermissionSet> withheld) const;
93 100
101 // Sets the runtime policy of the given |extension|.
102 void SetRuntimeBlockedAllowedHosts(
103 const URLPatternSet runtime_blocked_hosts,
104 const URLPatternSet runtime_allowed_hosts,
105 const bool is_default_runtime_blocked_allowed_hosts) const;
106
107 // Sets the default runtime policy.
108 static void SetDefaultRuntimeBlockedAllowedHosts(
109 const URLPatternSet default_runtime_blocked_hosts,
110 const URLPatternSet default_runtime_allowed_hosts);
111
94 // Sets the active permissions, leaving withheld the same. 112 // Sets the active permissions, leaving withheld the same.
95 void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const; 113 void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const;
96 114
97 // Updates the tab-specific permissions of |tab_id| to include those from 115 // Updates the tab-specific permissions of |tab_id| to include those from
98 // |permissions|. 116 // |permissions|.
99 void UpdateTabSpecificPermissions(int tab_id, 117 void UpdateTabSpecificPermissions(int tab_id,
100 const PermissionSet& permissions) const; 118 const PermissionSet& permissions) const;
101 119
102 // Clears the tab-specific permissions of |tab_id|. 120 // Clears the tab-specific permissions of |tab_id|.
103 void ClearTabSpecificPermissions(int tab_id) const; 121 void ClearTabSpecificPermissions(int tab_id) const;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 const PermissionSet& active_permissions() const { 212 const PermissionSet& active_permissions() const {
195 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); 213 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
196 return *active_permissions_unsafe_; 214 return *active_permissions_unsafe_;
197 } 215 }
198 216
199 const PermissionSet& withheld_permissions() const { 217 const PermissionSet& withheld_permissions() const {
200 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); 218 DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
201 return *withheld_permissions_unsafe_; 219 return *withheld_permissions_unsafe_;
202 } 220 }
203 221
222 // Returns list of hosts this extension may not interact with by policy.
223 static const URLPatternSet& default_runtime_blocked_hosts();
224
225 // Returns list of hosts this extension may interact with regardless of
226 // what is defined by runtime_blocked_hosts().
227 static const URLPatternSet& default_runtime_allowed_hosts();
228
229 // Returns list of hosts this extension may not interact with by policy.
230 const URLPatternSet& runtime_blocked_hosts() const;
231
232 // Returns list of hosts this extension may interact with regardless of
233 // what is defined by runtime_blocked_hosts().
234 const URLPatternSet& runtime_allowed_hosts() const;
235
204 #if defined(UNIT_TEST) 236 #if defined(UNIT_TEST)
205 const PermissionSet* GetTabSpecificPermissionsForTesting(int tab_id) const { 237 const PermissionSet* GetTabSpecificPermissionsForTesting(int tab_id) const {
206 base::AutoLock auto_lock(runtime_lock_); 238 base::AutoLock auto_lock(runtime_lock_);
207 return GetTabSpecificPermissions(tab_id); 239 return GetTabSpecificPermissions(tab_id);
208 } 240 }
209 #endif 241 #endif
210 242
211 private: 243 private:
212 // Gets the tab-specific host permissions of |tab_id|, or NULL if there 244 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
213 // aren't any. 245 // aren't any.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // active_permissions() accessor. 280 // active_permissions() accessor.
249 mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_; 281 mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_;
250 282
251 // The permissions the extension requested, but was not granted due because 283 // The permissions the extension requested, but was not granted due because
252 // they are too powerful. This includes things like all_hosts. 284 // they are too powerful. This includes things like all_hosts.
253 // Unsafe indicates that we must lock anytime this is directly accessed. 285 // Unsafe indicates that we must lock anytime this is directly accessed.
254 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe) 286 // Unless you need to change |withheld_permissions_unsafe_|, use the (safe)
255 // withheld_permissions() accessor. 287 // withheld_permissions() accessor.
256 mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_; 288 mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_;
257 289
290 // The list of hosts an extension may not interact with by policy.
291 // Unless you need to change |runtime_blocked_hosts_unsafe_|, use the (safe)
292 // runtime_blocked_hosts() accessor.
293 mutable URLPatternSet runtime_blocked_hosts_unsafe_;
294
295 // The exclusive list of hosts an extension may interact with by policy.
296 // Unless you need to change |runtime_allowed_hosts_unsafe_|, use the (safe)
297 // runtime_allowed_hosts() accessor.
298 mutable URLPatternSet runtime_allowed_hosts_unsafe_;
299
300 // If this extension is using the DefaultRuntimeBlockedAllowedHosts shared by
301 // every extension in the renderer or an extension specific setting held in
302 // RuntimeBlockedAllowedHosts
303 mutable bool is_default_runtime_blocked_allowed_hosts_ = true;
304
258 mutable TabPermissionsMap tab_specific_permissions_; 305 mutable TabPermissionsMap tab_specific_permissions_;
259 306
260 mutable std::unique_ptr<base::ThreadChecker> thread_checker_; 307 mutable std::unique_ptr<base::ThreadChecker> thread_checker_;
261 308
262 DISALLOW_COPY_AND_ASSIGN(PermissionsData); 309 DISALLOW_COPY_AND_ASSIGN(PermissionsData);
263 }; 310 };
264 311
265 } // namespace extensions 312 } // namespace extensions
266 313
267 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ 314 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698