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
3 // found in the LICENSE file.
5 #include "extensions/common/features/permission_feature.h"
7 #include "extensions/common/permissions/permission_set.h"
8 #include "extensions/common/permissions/permissions_data.h"
10 namespace extensions
{
12 PermissionFeature::PermissionFeature() {
15 PermissionFeature::~PermissionFeature() {
18 Feature::Availability
PermissionFeature::IsAvailableToContext(
19 const Extension
* extension
,
20 Feature::Context context
,
22 Feature::Platform platform
) const {
23 Availability availability
= SimpleFeature::IsAvailableToContext(extension
,
27 if (!availability
.is_available())
30 if (extension
&& !extension
->permissions_data()->HasAPIPermission(name()))
31 return CreateAvailability(NOT_PRESENT
, extension
->GetType());
33 return CreateAvailability(IS_AVAILABLE
);
36 std::string
PermissionFeature::Parse(const base::DictionaryValue
* value
) {
37 std::string error
= SimpleFeature::Parse(value
);
41 if (extension_types()->empty()) {
42 return name() + ": Permission features must specify at least one " +
43 "value for extension_types.";
46 if (value
->HasKey("contexts"))
47 return name() + ": Permission features do not support contexts.";
52 } // namespace extensions