| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/common/features/json_feature_provider.h" | 5 #include "extensions/common/features/json_feature_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <stack> | 9 #include <stack> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } else { | 28 } else { |
| 29 // "nocompile" is not supported for any other feature type. | 29 // "nocompile" is not supported for any other feature type. |
| 30 } | 30 } |
| 31 return nocompile; | 31 return nocompile; |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool ParseFeature(const base::DictionaryValue* value, | 34 bool ParseFeature(const base::DictionaryValue* value, |
| 35 const std::string& name, | 35 const std::string& name, |
| 36 SimpleFeature* feature) { | 36 SimpleFeature* feature) { |
| 37 feature->set_name(name); | 37 feature->set_name(name); |
| 38 std::string error = feature->Parse(value); | 38 feature->Parse(value); |
| 39 if (!error.empty()) | 39 std::string error; |
| 40 bool valid = feature->Validate(&error); |
| 41 if (!valid) |
| 40 LOG(ERROR) << error; | 42 LOG(ERROR) << error; |
| 41 return error.empty(); | 43 return valid; |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 JSONFeatureProvider::JSONFeatureProvider(const base::DictionaryValue& root, | 48 JSONFeatureProvider::JSONFeatureProvider(const base::DictionaryValue& root, |
| 47 FeatureFactory factory) | 49 FeatureFactory factory) |
| 48 : factory_(factory) { | 50 : factory_(factory) { |
| 49 for (base::DictionaryValue::Iterator iter(root); !iter.IsAtEnd(); | 51 for (base::DictionaryValue::Iterator iter(root); !iter.IsAtEnd(); |
| 50 iter.Advance()) { | 52 iter.Advance()) { |
| 51 if (IsNocompile(iter.value())) { | 53 if (IsNocompile(iter.value())) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } else { | 142 } else { |
| 141 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or" | 143 LOG(ERROR) << iter.key() << ": Feature description must be dictionary or" |
| 142 << " list of dictionaries."; | 144 << " list of dictionaries."; |
| 143 } | 145 } |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 | 148 |
| 147 JSONFeatureProvider::~JSONFeatureProvider() {} | 149 JSONFeatureProvider::~JSONFeatureProvider() {} |
| 148 | 150 |
| 149 } // namespace extensions | 151 } // namespace extensions |
| OLD | NEW |