| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/permission_feature.h" | 5 #include "chrome/common/extensions/permission_feature.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/extension_permission_set.h" | 7 #include "chrome/common/extensions/extension_permission_set.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 PermissionFeature::PermissionFeature() { | 11 PermissionFeature::PermissionFeature() { |
| 12 } | 12 } |
| 13 | 13 |
| 14 PermissionFeature::~PermissionFeature() { | 14 PermissionFeature::~PermissionFeature() { |
| 15 } | 15 } |
| 16 | 16 |
| 17 Feature::Availability PermissionFeature::IsAvailableToContext( | 17 Feature::Availability PermissionFeature::IsAvailableToContext( |
| 18 const Extension* extension, | 18 const Extension* extension, |
| 19 Feature::Context context, | 19 Feature::Context context, |
| 20 Feature::Platform platform) const { | 20 Feature::Platform platform) const { |
| 21 Availability availability = Feature::IsAvailableToContext(extension, | 21 Availability availability = Feature::IsAvailableToContext(extension, |
| 22 context, | 22 context, |
| 23 platform); | 23 platform); |
| 24 if (availability != IS_AVAILABLE) | 24 if (availability != IS_AVAILABLE) |
| 25 return availability; | 25 return availability; |
| 26 | 26 |
| 27 if (!extension->HasAPIPermission(name())) | 27 // TODO(aa): Lame to check optional permissions too (instead of just currently |
| 28 // active permissions), but schema_generated_bindings.js calls this at |
| 29 // bindings setup time, not call time. So it doesn't react properly to changes |
| 30 // after the bindings are setup. |
| 31 ExtensionAPIPermission* permission = |
| 32 ExtensionPermissionsInfo::GetInstance()->GetByName(name()); |
| 33 if (!permission) |
| 28 return NOT_PRESENT; | 34 return NOT_PRESENT; |
| 29 | 35 |
| 36 if (!extension->required_permission_set()->HasAPIPermission( |
| 37 permission->id()) && |
| 38 !extension->optional_permission_set()->HasAPIPermission( |
| 39 permission->id())) { |
| 40 return NOT_PRESENT; |
| 41 } |
| 42 |
| 30 return IS_AVAILABLE; | 43 return IS_AVAILABLE; |
| 31 } | 44 } |
| 32 | 45 |
| 33 } // namespace | 46 } // namespace |
| OLD | NEW |