| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 // Check whether if in one of them, setting is specified. | 198 // Check whether if in one of them, setting is specified. |
| 199 if (iter_id != settings_by_id_.end()) | 199 if (iter_id != settings_by_id_.end()) |
| 200 return iter_id->second->blocked_permissions; | 200 return iter_id->second->blocked_permissions; |
| 201 if (iter_update_url != settings_by_update_url_.end()) | 201 if (iter_update_url != settings_by_update_url_.end()) |
| 202 return iter_update_url->second->blocked_permissions; | 202 return iter_update_url->second->blocked_permissions; |
| 203 // Fall back to the default blocked permissions setting. | 203 // Fall back to the default blocked permissions setting. |
| 204 return default_settings_->blocked_permissions; | 204 return default_settings_->blocked_permissions; |
| 205 } | 205 } |
| 206 | 206 |
| 207 scoped_refptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( | 207 scoped_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( |
| 208 const Extension* extension) const { | 208 const Extension* extension) const { |
| 209 // Only api permissions are supported currently. | 209 // Only api permissions are supported currently. |
| 210 return scoped_refptr<const PermissionSet>(new PermissionSet( | 210 return scoped_ptr<const PermissionSet>(new PermissionSet( |
| 211 GetBlockedAPIPermissions(extension), ManifestPermissionSet(), | 211 GetBlockedAPIPermissions(extension), ManifestPermissionSet(), |
| 212 URLPatternSet(), URLPatternSet())); | 212 URLPatternSet(), URLPatternSet())); |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool ExtensionManagement::IsPermissionSetAllowed( | 215 bool ExtensionManagement::IsPermissionSetAllowed( |
| 216 const Extension* extension, | 216 const Extension* extension, |
| 217 scoped_refptr<const PermissionSet> perms) const { | 217 const PermissionSet& perms) const { |
| 218 for (const auto& blocked_api : GetBlockedAPIPermissions(extension)) { | 218 for (const auto& blocked_api : GetBlockedAPIPermissions(extension)) { |
| 219 if (perms->HasAPIPermission(blocked_api->id())) | 219 if (perms.HasAPIPermission(blocked_api->id())) |
| 220 return false; | 220 return false; |
| 221 } | 221 } |
| 222 return true; | 222 return true; |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool ExtensionManagement::CheckMinimumVersion( | 225 bool ExtensionManagement::CheckMinimumVersion( |
| 226 const Extension* extension, | 226 const Extension* extension, |
| 227 std::string* required_version) const { | 227 std::string* required_version) const { |
| 228 auto iter = settings_by_id_.find(extension->id()); | 228 auto iter = settings_by_id_.find(extension->id()); |
| 229 // If there are no minimum version required for |extension|, return true. | 229 // If there are no minimum version required for |extension|, return true. |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 content::BrowserContext* context) const { | 490 content::BrowserContext* context) const { |
| 491 return chrome::GetBrowserContextRedirectedInIncognito(context); | 491 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 492 } | 492 } |
| 493 | 493 |
| 494 void ExtensionManagementFactory::RegisterProfilePrefs( | 494 void ExtensionManagementFactory::RegisterProfilePrefs( |
| 495 user_prefs::PrefRegistrySyncable* user_prefs) { | 495 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 496 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); | 496 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace extensions | 499 } // namespace extensions |
| OLD | NEW |