| Index: chrome/common/extensions/api/extension_api_feature.cc
|
| diff --git a/chrome/common/extensions/api/extension_api_feature.cc b/chrome/common/extensions/api/extension_api_feature.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b290771cb854b2b2b3b53bac9d2eade235d4076b
|
| --- /dev/null
|
| +++ b/chrome/common/extensions/api/extension_api_feature.cc
|
| @@ -0,0 +1,71 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/common/extensions/api/extension_api_feature.h"
|
| +
|
| +#include "base/values.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +namespace {
|
| +
|
| +const char* kChildKinds[] = {
|
| + "functions",
|
| + "events"
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +ExtensionAPIFeature::ExtensionAPIFeature() {
|
| +}
|
| +
|
| +ExtensionAPIFeature::~ExtensionAPIFeature() {
|
| +}
|
| +
|
| +std::set<std::string>* ExtensionAPIFeature::dependencies() {
|
| + return &dependencies_;
|
| +}
|
| +
|
| +void ExtensionAPIFeature::Parse(const DictionaryValue* schema) {
|
| + Feature::Parse(schema);
|
| +
|
| + ParseSet(schema, "dependencies", &dependencies_);
|
| +
|
| + for (size_t i = 0; i < arraysize(kChildKinds); ++i) {
|
| + ListValue* child_list = NULL;
|
| + schema->GetList(kChildKinds[i], &child_list);
|
| + if (!child_list)
|
| + continue;
|
| +
|
| + for (size_t j = 0; j < child_list->GetSize(); ++j) {
|
| + DictionaryValue* child = NULL;
|
| + CHECK(child_list->GetDictionary(j, &child));
|
| +
|
| + scoped_ptr<ExtensionAPIFeature> child_feature(new ExtensionAPIFeature());
|
| + child_feature->Parse(child);
|
| + if (child_feature->IsEmpty())
|
| + continue; // no need to store no-op features
|
| +
|
| + std::string child_name;
|
| + CHECK(child->GetString("name", &child_name));
|
| + child_feature->set_name(name() + "." + child_name);
|
| + CHECK(child_features_.insert(
|
| + std::make_pair(child_name,
|
| + make_linked_ptr(child_feature.release()))).second);
|
| + }
|
| + }
|
| +}
|
| +
|
| +Feature* ExtensionAPIFeature::GetChild(const std::string& child_name) const {
|
| + ChildFeatureMap::const_iterator iter = child_features_.find(child_name);
|
| + if (iter != child_features_.end()) {
|
| + ExtensionAPIFeature* result = iter->second.get();
|
| + result->dependencies()->insert(std::string("api:") + name());
|
| + return result;
|
| + } else {
|
| + return NULL;
|
| + }
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|