Index: extensions/common/api/declarative/declarative_manifest_data.cc |
diff --git a/extensions/common/api/declarative/declarative_manifest_data.cc b/extensions/common/api/declarative/declarative_manifest_data.cc |
index 97bc5ebca369466171dc955444cddd31c4990215..cdea2f219d8760419ae7b68230034af51ec2f29e 100644 |
--- a/extensions/common/api/declarative/declarative_manifest_data.cc |
+++ b/extensions/common/api/declarative/declarative_manifest_data.cc |
@@ -18,20 +18,6 @@ namespace extensions { |
namespace { |
-const char* ValueTypeToString(const base::Value* value) { |
- const base::Value::Type type = value->GetType(); |
- static const char* strings[] = {"null", |
- "boolean", |
- "integer", |
- "double", |
- "string", |
- "binary", |
- "dictionary", |
- "list"}; |
- CHECK(static_cast<size_t>(type) < arraysize(strings)); |
- return strings[type]; |
-} |
- |
class ErrorBuilder { |
public: |
explicit ErrorBuilder(base::string16* error) : error_(error) {} |
@@ -61,12 +47,12 @@ class ErrorBuilder { |
bool ConvertManifestRule(const linked_ptr<DeclarativeManifestData::Rule>& rule, |
ErrorBuilder* error_builder) { |
auto convert_list = |
- [error_builder](std::vector<std::unique_ptr<base::Value>>& list) { |
+ [error_builder](const std::vector<std::unique_ptr<base::Value>>& list) { |
for (const std::unique_ptr<base::Value>& value : list) { |
base::DictionaryValue* dictionary = nullptr; |
if (!value->GetAsDictionary(&dictionary)) { |
error_builder->Append("expected dictionary, got %s", |
- ValueTypeToString(value.get())); |
+ base::Value::GetTypeName(value->GetType())); |
return false; |
} |
std::string type; |
@@ -139,19 +125,20 @@ std::unique_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue( |
const base::ListValue* list = nullptr; |
if (!value.GetAsList(&list)) { |
error_builder.Append("'event_rules' expected list, got %s", |
- ValueTypeToString(&value)); |
+ base::Value::GetTypeName(value.GetType())); |
return std::unique_ptr<DeclarativeManifestData>(); |
} |
for (size_t i = 0; i < list->GetSize(); ++i) { |
const base::DictionaryValue* dict = nullptr; |
if (!list->GetDictionary(i, &dict)) { |
pneubeck (no reviews)
2016/07/14 18:51:37
this whole block is rather confusing.
maybe change
Lei Zhang
2016/07/15 01:27:18
Sure. You are absolutely right, the else case can'
|
- const base::Value* value = nullptr; |
- if (list->Get(i, &value)) |
+ const base::Value* dict_value = nullptr; |
+ if (list->Get(i, &dict_value)) { |
error_builder.Append("expected dictionary, got %s", |
- ValueTypeToString(value)); |
- else |
+ base::Value::GetTypeName(dict_value->GetType())); |
+ } else { |
error_builder.Append("expected dictionary"); |
+ } |
return std::unique_ptr<DeclarativeManifestData>(); |
} |
std::string event; |