Enable _api_features.json to block APIs from service worker contexts.
[chromium-blink-merge.git] / chrome / common / extensions / features / api_feature.cc
blobedb9317b840f8eff3a55bbe3fe236f4e224f2f52
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/api_feature.h"
7 namespace extensions {
9 APIFeature::APIFeature()
10 : internal_(false), blocked_in_service_worker_(false) {}
12 APIFeature::~APIFeature() {
15 bool APIFeature::IsInternal() const {
16 return internal_;
19 bool APIFeature::IsBlockedInServiceWorker() const {
20 return blocked_in_service_worker_;
23 std::string APIFeature::Parse(const base::DictionaryValue* value) {
24 std::string error = SimpleFeature::Parse(value);
25 if (!error.empty())
26 return error;
28 value->GetBoolean("internal", &internal_);
29 value->GetBoolean("blocked_in_service_worker", &blocked_in_service_worker_);
31 if (GetContexts()->empty())
32 return name() + ": API features must specify at least one context.";
34 return std::string();
37 } // namespace extensions