| 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 | |
| 211 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts( | 201 const URLPatternSet& ExtensionManagement::GetRuntimeBlockedHosts( |
| 212 const Extension* extension) const { | 202 const Extension* extension) const { |
| 213 auto iter_id = settings_by_id_.find(extension->id()); | 203 auto iter_id = settings_by_id_.find(extension->id()); |
| 214 if (iter_id != settings_by_id_.end()) | 204 if (iter_id != settings_by_id_.end()) |
| 215 return iter_id->second->runtime_blocked_hosts; | 205 return iter_id->second->runtime_blocked_hosts; |
| 216 return default_settings_->runtime_blocked_hosts; | 206 return default_settings_->runtime_blocked_hosts; |
| 217 } | 207 } |
| 218 | 208 |
| 219 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts( | 209 const URLPatternSet& ExtensionManagement::GetRuntimeAllowedHosts( |
| 220 const Extension* extension) const { | 210 const Extension* extension) const { |
| 221 auto iter_id = settings_by_id_.find(extension->id()); | 211 auto iter_id = settings_by_id_.find(extension->id()); |
| 222 if (iter_id != settings_by_id_.end()) | 212 if (iter_id != settings_by_id_.end()) |
| 223 return iter_id->second->runtime_allowed_hosts; | 213 return iter_id->second->runtime_allowed_hosts; |
| 224 return default_settings_->runtime_allowed_hosts; | 214 return default_settings_->runtime_allowed_hosts; |
| 225 } | 215 } |
| 226 | 216 |
| 227 bool ExtensionManagement::UsesDefaultRuntimeHostRestrictions( | 217 bool ExtensionManagement::IsBlockedHost(const Extension* extension, |
| 228 const Extension* extension) const { | 218 const GURL& url) 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 { | |
| 234 auto iter_id = settings_by_id_.find(extension->id()); | 219 auto iter_id = settings_by_id_.find(extension->id()); |
| 235 if (iter_id != settings_by_id_.end()) | 220 if (iter_id != settings_by_id_.end()) |
| 236 return iter_id->second->runtime_blocked_hosts.MatchesURL(url); | 221 return iter_id->second->runtime_blocked_hosts.MatchesURL(url); |
| 237 return default_settings_->runtime_blocked_hosts.MatchesURL(url); | 222 return default_settings_->runtime_blocked_hosts.MatchesURL(url); |
| 238 } | 223 } |
| 239 | 224 |
| 240 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( | 225 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( |
| 241 const Extension* extension) const { | 226 const Extension* extension) const { |
| 242 // Only api permissions are supported currently. | 227 // Only api permissions are supported currently. |
| 243 return std::unique_ptr<const PermissionSet>(new PermissionSet( | 228 return std::unique_ptr<const PermissionSet>(new PermissionSet( |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 content::BrowserContext* context) const { | 537 content::BrowserContext* context) const { |
| 553 return chrome::GetBrowserContextRedirectedInIncognito(context); | 538 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 554 } | 539 } |
| 555 | 540 |
| 556 void ExtensionManagementFactory::RegisterProfilePrefs( | 541 void ExtensionManagementFactory::RegisterProfilePrefs( |
| 557 user_prefs::PrefRegistrySyncable* user_prefs) { | 542 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 558 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); | 543 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); |
| 559 } | 544 } |
| 560 | 545 |
| 561 } // namespace extensions | 546 } // namespace extensions |
| OLD | NEW |