Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / common / features / manifest_feature.cc
blobf169c6a8ac8451a54c7ec378d5db4c19938fbb19
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/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 (value->HasKey("contexts"))
48 return name() + ": Manifest features do not support contexts.";
50 return std::string();
53 } // namespace extensions