Pepper: Fix PPB_TrueTypeFont GetFontsInFamily function.
[chromium-blink-merge.git] / extensions / common / features / permission_feature.cc
blob529ecd1188a836b74bea4945de81a909224645c9
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,
21 const GURL& url,
22 Feature::Platform platform) const {
23 Availability availability = SimpleFeature::IsAvailableToContext(extension,
24 context,
25 url,
26 platform);
27 if (!availability.is_available())
28 return availability;
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);
38 if (!error.empty())
39 return error;
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.";
49 return std::string();
52 } // namespace extensions