Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / extensions / features / manifest_feature.cc
bloba8d6e42a409e99b4f2c172d3522230e89cef6ffc
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"
9 namespace extensions {
11 ManifestFeature::ManifestFeature() {
14 ManifestFeature::~ManifestFeature() {
17 Feature::Availability ManifestFeature::IsAvailableToContext(
18 const Extension* extension,
19 Feature::Context context,
20 const GURL& url,
21 Feature::Platform platform) const {
22 Availability availability = SimpleFeature::IsAvailableToContext(extension,
23 context,
24 url,
25 platform);
26 if (!availability.is_available())
27 return availability;
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);
39 if (!error.empty())
40 return error;
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.";
50 return std::string();
53 } // namespace extensions