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

Side by Side Diff: chrome/browser/extensions/extension_management.cc

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Fix effective TLD wildcard bug, move to Leaky LazyInstance in PermissionsData, removed unnecessary … Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/extensions/extension_management.h" 5 #include "chrome/browser/extensions/extension_management.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 // Check whether if in one of them, setting is specified. 205 // Check whether if in one of them, setting is specified.
206 if (iter_id != settings_by_id_.end()) 206 if (iter_id != settings_by_id_.end())
207 return iter_id->second->blocked_permissions; 207 return iter_id->second->blocked_permissions;
208 if (iter_update_url != settings_by_update_url_.end()) 208 if (iter_update_url != settings_by_update_url_.end())
209 return iter_update_url->second->blocked_permissions; 209 return iter_update_url->second->blocked_permissions;
210 // Fall back to the default blocked permissions setting. 210 // Fall back to the default blocked permissions setting.
211 return default_settings_->blocked_permissions; 211 return default_settings_->blocked_permissions;
212 } 212 }
213 213
214 const URLPatternSet& ExtensionManagement::GetDefaultRuntimeBlockedHosts()
215 const {
216 return default_settings_->runtime_blocked_hosts;
217 }
218
219 const URLPatternSet& ExtensionManagement::GetDefaultRuntimeAllowedHosts()
220 const {
221 return default_settings_->runtime_allowed_hosts;
222 }
223
214 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts( 224 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts(
215 const Extension* extension) const { 225 const Extension* extension) const {
216 auto iter_id = settings_by_id_.find(extension->id()); 226 auto iter_id = settings_by_id_.find(extension->id());
217 if (iter_id != settings_by_id_.end()) 227 if (iter_id != settings_by_id_.end())
218 return iter_id->second->runtime_blocked_hosts; 228 return iter_id->second->runtime_blocked_hosts;
219 return default_settings_->runtime_blocked_hosts; 229 return default_settings_->runtime_blocked_hosts;
220 } 230 }
221 231
222 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts( 232 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts(
223 const Extension* extension) const { 233 const Extension* extension) const {
224 auto iter_id = settings_by_id_.find(extension->id()); 234 auto iter_id = settings_by_id_.find(extension->id());
225 if (iter_id != settings_by_id_.end()) 235 if (iter_id != settings_by_id_.end())
226 return iter_id->second->runtime_allowed_hosts; 236 return iter_id->second->runtime_allowed_hosts;
227 return default_settings_->runtime_allowed_hosts; 237 return default_settings_->runtime_allowed_hosts;
228 } 238 }
229 239
230 bool ExtensionManagement::IsBlockedHost(const Extension* extension, 240 bool ExtensionManagement::UsesDefaultRuntimeHostRestrictions(
231 const GURL& url) const { 241 const Extension* extension) const {
242 return (settings_by_id_.find(extension->id()) == settings_by_id_.end());
Devlin 2017/03/29 21:36:49 parens unnecessary
nrpeter 2017/03/30 00:06:05 Done.
243 }
244
245 bool ExtensionManagement::IsRuntimeBlockedHost(const Extension* extension,
246 const GURL& url) const {
232 auto iter_id = settings_by_id_.find(extension->id()); 247 auto iter_id = settings_by_id_.find(extension->id());
233 if (iter_id != settings_by_id_.end()) 248 if (iter_id != settings_by_id_.end())
234 return iter_id->second->runtime_blocked_hosts.MatchesURL(url); 249 return iter_id->second->runtime_blocked_hosts.MatchesURL(url);
235 return default_settings_->runtime_blocked_hosts.MatchesURL(url); 250 return default_settings_->runtime_blocked_hosts.MatchesURL(url);
236 } 251 }
237 252
238 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( 253 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions(
239 const Extension* extension) const { 254 const Extension* extension) const {
240 // Only api permissions are supported currently. 255 // Only api permissions are supported currently.
241 return std::unique_ptr<const PermissionSet>(new PermissionSet( 256 return std::unique_ptr<const PermissionSet>(new PermissionSet(
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 content::BrowserContext* context) const { 536 content::BrowserContext* context) const {
522 return chrome::GetBrowserContextRedirectedInIncognito(context); 537 return chrome::GetBrowserContextRedirectedInIncognito(context);
523 } 538 }
524 539
525 void ExtensionManagementFactory::RegisterProfilePrefs( 540 void ExtensionManagementFactory::RegisterProfilePrefs(
526 user_prefs::PrefRegistrySyncable* user_prefs) { 541 user_prefs::PrefRegistrySyncable* user_prefs) {
527 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); 542 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement);
528 } 543 }
529 544
530 } // namespace extensions 545 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698