Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 { |
|
dcheng
2017/02/06 07:05:29
Pass by const reference if it's never null? *shrug
nrpeter
2017/02/06 22:53:15
Everything else in extension_management that passe
dcheng
2017/02/07 07:47:12
I guess I'll defer to devlin on this one, but that
| |
| 242 return (settings_by_id_.find(extension->id()) == settings_by_id_.end()); | |
| 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 Loading... | |
| 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 |
| OLD | NEW |