| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 // Check whether if in one of them, setting is specified. | 192 // Check whether if in one of them, setting is specified. |
| 193 if (iter_id != settings_by_id_.end()) | 193 if (iter_id != settings_by_id_.end()) |
| 194 return iter_id->second->blocked_permissions; | 194 return iter_id->second->blocked_permissions; |
| 195 if (iter_update_url != settings_by_update_url_.end()) | 195 if (iter_update_url != settings_by_update_url_.end()) |
| 196 return iter_update_url->second->blocked_permissions; | 196 return iter_update_url->second->blocked_permissions; |
| 197 // Fall back to the default blocked permissions setting. | 197 // Fall back to the default blocked permissions setting. |
| 198 return default_settings_->blocked_permissions; | 198 return default_settings_->blocked_permissions; |
| 199 } | 199 } |
| 200 | 200 |
| 201 const URLPatternSet& ExtensionManagement::GetDefaultRuntimeBlockedHosts() |
| 202 const { |
| 203 return default_settings_->runtime_blocked_hosts; |
| 204 } |
| 205 |
| 206 const URLPatternSet& ExtensionManagement::GetDefaultRuntimeAllowedHosts() |
| 207 const { |
| 208 return default_settings_->runtime_allowed_hosts; |
| 209 } |
| 210 |
| 201 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts( | 211 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts( |
| 202 const Extension* extension) const { | 212 const Extension* extension) const { |
| 203 auto iter_id = settings_by_id_.find(extension->id()); | 213 auto iter_id = settings_by_id_.find(extension->id()); |
| 204 if (iter_id != settings_by_id_.end()) | 214 if (iter_id != settings_by_id_.end()) |
| 205 return iter_id->second->runtime_blocked_hosts; | 215 return iter_id->second->runtime_blocked_hosts; |
| 206 return default_settings_->runtime_blocked_hosts; | 216 return default_settings_->runtime_blocked_hosts; |
| 207 } | 217 } |
| 208 | 218 |
| 209 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts( | 219 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts( |
| 210 const Extension* extension) const { | 220 const Extension* extension) const { |
| 211 auto iter_id = settings_by_id_.find(extension->id()); | 221 auto iter_id = settings_by_id_.find(extension->id()); |
| 212 if (iter_id != settings_by_id_.end()) | 222 if (iter_id != settings_by_id_.end()) |
| 213 return iter_id->second->runtime_allowed_hosts; | 223 return iter_id->second->runtime_allowed_hosts; |
| 214 return default_settings_->runtime_allowed_hosts; | 224 return default_settings_->runtime_allowed_hosts; |
| 215 } | 225 } |
| 216 | 226 |
| 217 bool ExtensionManagement::IsBlockedHost(const Extension* extension, | 227 bool ExtensionManagement::UsesDefaultRuntimeHostRestrictions( |
| 218 const GURL& url) const { | 228 const Extension* extension) const { |
| 229 return settings_by_id_.find(extension->id()) == settings_by_id_.end(); |
| 230 } |
| 231 |
| 232 bool ExtensionManagement::IsRuntimeBlockedHost(const Extension* extension, |
| 233 const GURL& url) const { |
| 219 auto iter_id = settings_by_id_.find(extension->id()); | 234 auto iter_id = settings_by_id_.find(extension->id()); |
| 220 if (iter_id != settings_by_id_.end()) | 235 if (iter_id != settings_by_id_.end()) |
| 221 return iter_id->second->runtime_blocked_hosts.MatchesURL(url); | 236 return iter_id->second->runtime_blocked_hosts.MatchesURL(url); |
| 222 return default_settings_->runtime_blocked_hosts.MatchesURL(url); | 237 return default_settings_->runtime_blocked_hosts.MatchesURL(url); |
| 223 } | 238 } |
| 224 | 239 |
| 225 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( | 240 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( |
| 226 const Extension* extension) const { | 241 const Extension* extension) const { |
| 227 // Only api permissions are supported currently. | 242 // Only api permissions are supported currently. |
| 228 return std::unique_ptr<const PermissionSet>(new PermissionSet( | 243 return std::unique_ptr<const PermissionSet>(new PermissionSet( |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 content::BrowserContext* context) const { | 552 content::BrowserContext* context) const { |
| 538 return chrome::GetBrowserContextRedirectedInIncognito(context); | 553 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 539 } | 554 } |
| 540 | 555 |
| 541 void ExtensionManagementFactory::RegisterProfilePrefs( | 556 void ExtensionManagementFactory::RegisterProfilePrefs( |
| 542 user_prefs::PrefRegistrySyncable* user_prefs) { | 557 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 543 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); | 558 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); |
| 544 } | 559 } |
| 545 | 560 |
| 546 } // namespace extensions | 561 } // namespace extensions |
| OLD | NEW |