summaryrefslogtreecommitdiffstats
path: root/extensions/common/features/base_feature_provider.cc
diff options
context:
space:
mode:
authorkalman <kalman@chromium.org>2015-01-13 11:01:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-13 19:03:17 +0000
commit1bd5b187a8868df3f0f2998e4ad770fd31c04846 (patch)
treecc5e128917e3e5ff85e81503686e32531408926d /extensions/common/features/base_feature_provider.cc
parent4feef6baa415f8616ad2f93041e3437899996d4b (diff)
downloadchromium_src-1bd5b187a8868df3f0f2998e4ad770fd31c04846.zip
chromium_src-1bd5b187a8868df3f0f2998e4ad770fd31c04846.tar.gz
chromium_src-1bd5b187a8868df3f0f2998e4ad770fd31c04846.tar.bz2
Add a 'nocompile' option to Extension feature files, and annotate all Devtools
APIs with it. Devtools APIs are written by hand and don't need to be compiled (moreover, it crashes when you try). BUG=356133 R=mek@chromium.org Review URL: https://codereview.chromium.org/850603003 Cr-Commit-Position: refs/heads/master@{#311302}
Diffstat (limited to 'extensions/common/features/base_feature_provider.cc')
-rw-r--r--extensions/common/features/base_feature_provider.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc
index 97f87be..9b927cc 100644
--- a/extensions/common/features/base_feature_provider.cc
+++ b/extensions/common/features/base_feature_provider.cc
@@ -17,6 +17,17 @@ namespace extensions {
namespace {
+bool IsNocompile(const base::Value& value) {
+ bool nocompile = false;
+ const base::DictionaryValue* as_dict = nullptr;
+ if (value.GetAsDictionary(&as_dict)) {
+ as_dict->GetBoolean("nocompile", &nocompile);
+ } else {
+ // "nocompile" is not supported for any other feature type.
+ }
+ return nocompile;
+}
+
bool ParseFeature(const base::DictionaryValue* value,
const std::string& name,
SimpleFeature* feature) {
@@ -34,6 +45,10 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
: factory_(factory) {
for (base::DictionaryValue::Iterator iter(root); !iter.IsAtEnd();
iter.Advance()) {
+ if (IsNocompile(iter.value())) {
+ continue;
+ }
+
if (iter.value().GetType() == base::Value::TYPE_DICTIONARY) {
linked_ptr<SimpleFeature> feature((*factory_)());
@@ -50,7 +65,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
std::string parent_name = JoinString(split, '.');
split.pop_back();
if (root.HasKey(parent_name)) {
- const base::DictionaryValue* parent = NULL;
+ const base::DictionaryValue* parent = nullptr;
CHECK(root.GetDictionaryWithoutPathExpansion(parent_name, &parent));
parse_stack.push(std::make_pair(parent_name, parent));
bool no_parent = false;
@@ -135,18 +150,18 @@ Feature* BaseFeatureProvider::GetFeature(const std::string& name) const {
if (iter != features_.end())
return iter->second.get();
else
- return NULL;
+ return nullptr;
}
Feature* BaseFeatureProvider::GetParent(Feature* feature) const {
CHECK(feature);
if (feature->no_parent())
- return NULL;
+ return nullptr;
std::vector<std::string> split;
base::SplitString(feature->name(), '.', &split);
if (split.size() < 2)
- return NULL;
+ return nullptr;
split.pop_back();
return GetFeature(JoinString(split, '.'));
}