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

Unified Diff: extensions/renderer/argument_spec.cc

Issue 2439263003: [Extensions Binding] Update ArgumentSpec to support dictionary enums (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | extensions/renderer/argument_spec_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/argument_spec.cc
diff --git a/extensions/renderer/argument_spec.cc b/extensions/renderer/argument_spec.cc
index 623f13587a4bd2a353ee27eb0f8a964e940184c5..f79ea8a9107f44cd2d1da2e4a275ba82ba7cac67 100644
--- a/extensions/renderer/argument_spec.cc
+++ b/extensions/renderer/argument_spec.cc
@@ -93,7 +93,13 @@ void ArgumentSpec::InitializeType(const base::DictionaryValue* dict) {
CHECK_GT(size, 0u);
for (size_t i = 0; i < size; ++i) {
std::string enum_value;
- CHECK(enums->GetString(i, &enum_value));
+ // Enum entries come in two versions: a list of possible strings, and
+ // a dictionary with a field 'name'.
+ if (!enums->GetString(i, &enum_value)) {
+ const base::DictionaryValue* enum_value_dictionary = nullptr;
+ CHECK(enums->GetDictionary(i, &enum_value_dictionary));
+ CHECK(enum_value_dictionary->GetString("name", &enum_value));
+ }
enum_values_.insert(std::move(enum_value));
}
}
« no previous file with comments | « no previous file | extensions/renderer/argument_spec_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698