diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/dbus/values_util.cc | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) | |
download | qtwebengine-chromium-ab0a50979b9eb4dfa3320eff7e187e41efedf7a9.tar.gz |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/dbus/values_util.cc')
-rw-r--r-- | chromium/dbus/values_util.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/chromium/dbus/values_util.cc b/chromium/dbus/values_util.cc index 7574f39a643..c27c2723b84 100644 --- a/chromium/dbus/values_util.cc +++ b/chromium/dbus/values_util.cc @@ -77,6 +77,8 @@ std::string GetTypeSignature(const base::Value& value) { return "ay"; case base::Value::TYPE_DICTIONARY: return "a{sv}"; + case base::Value::TYPE_LIST: + return "av"; default: DLOG(ERROR) << "Unexpected type " << value.GetType(); return std::string(); @@ -253,4 +255,53 @@ void AppendBasicTypeValueDataAsVariant(MessageWriter* writer, writer->CloseContainer(&sub_writer); } +void AppendValueData(MessageWriter* writer, const base::Value& value) { + switch (value.GetType()) { + case base::Value::TYPE_DICTIONARY: { + const base::DictionaryValue* dictionary = NULL; + value.GetAsDictionary(&dictionary); + dbus::MessageWriter array_writer(NULL); + writer->OpenArray("{sv}", &array_writer); + for (base::DictionaryValue::Iterator iter(*dictionary); + !iter.IsAtEnd(); iter.Advance()) { + dbus::MessageWriter dict_entry_writer(NULL); + array_writer.OpenDictEntry(&dict_entry_writer); + dict_entry_writer.AppendString(iter.key()); + AppendValueDataAsVariant(&dict_entry_writer, iter.value()); + array_writer.CloseContainer(&dict_entry_writer); + } + writer->CloseContainer(&array_writer); + break; + } + case base::Value::TYPE_LIST: { + const base::ListValue* list = NULL; + value.GetAsList(&list); + dbus::MessageWriter array_writer(NULL); + writer->OpenArray("v", &array_writer); + for (base::ListValue::const_iterator iter = list->begin(); + iter != list->end(); ++iter) { + const base::Value* value = *iter; + AppendValueDataAsVariant(&array_writer, *value); + } + writer->CloseContainer(&array_writer); + break; + } + case base::Value::TYPE_BOOLEAN: + case base::Value::TYPE_INTEGER: + case base::Value::TYPE_DOUBLE: + case base::Value::TYPE_STRING: + AppendBasicTypeValueData(writer, value); + break; + default: + DLOG(ERROR) << "Unexpected type: " << value.GetType(); + } +} + +void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) { + MessageWriter variant_writer(NULL); + writer->OpenVariant(GetTypeSignature(value), &variant_writer); + AppendValueData(&variant_writer, value); + writer->CloseContainer(&variant_writer); +} + } // namespace dbus |