Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: extensions/common/features/base_feature_provider.cc

Issue 850603003: Add a 'nocompile' option to Extension feature files, and annotate all Devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/bindings/nocompile/page.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/base_feature_provider.cc
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc
index 97f87bedb34f278dc732cb4b1fb6fdf8ff09b888..9b927ccdf8d061ec41a6ef1d7938eb440e8fa401 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, '.'));
}
« no previous file with comments | « chrome/test/data/extensions/api_test/bindings/nocompile/page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698