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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/features/manifest_feature.h"
7 #include "extensions/common/manifest.h"
11 ManifestFeature::ManifestFeature() {
14 ManifestFeature::~ManifestFeature() {
17 Feature::Availability
ManifestFeature::IsAvailableToContext(
18 const Extension
* extension
,
19 Feature::Context context
,
21 Feature::Platform platform
) const {
22 Availability availability
= SimpleFeature::IsAvailableToContext(extension
,
26 if (!availability
.is_available())
29 // We know we can skip manifest()->GetKey() here because we just did the same
30 // validation it would do above.
31 if (extension
&& !extension
->manifest()->value()->HasKey(name()))
32 return CreateAvailability(NOT_PRESENT
, extension
->GetType());
34 return CreateAvailability(IS_AVAILABLE
);
37 std::string
ManifestFeature::Parse(const base::DictionaryValue
* value
) {
38 std::string error
= SimpleFeature::Parse(value
);
42 if (extension_types()->empty()) {
43 return name() + ": Manifest features must specify at least one " +
44 "value for extension_types.";
47 if (!GetContexts()->empty())
48 return name() + ": Manifest features do not support contexts.";
53 } // namespace extensions