Use string description for unknown types

This commit is contained in:
Cheng Zhao 2016-05-18 16:01:08 +09:00
parent 68cf267b1d
commit 3d0b98c9ca

View file

@ -44,7 +44,7 @@ scoped_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
else else
result->Append(base::Value::CreateNullValue()); result->Append(base::Value::CreateNullValue());
} else { } else {
result->Append(base::Value::CreateNullValue()); result->AppendString(base::SysNSStringToUTF8([value description]));
} }
} }
@ -73,11 +73,8 @@ scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
for (id key in dict) { for (id key in dict) {
std::string str_key; std::string str_key = base::SysNSStringToUTF8(
if ([key isKindOfClass:[NSString class]]) [key isKindOfClass:[NSString class]] ? key : [key description]);
str_key = base::SysNSStringToUTF8(key);
else
str_key = base::SysNSStringToUTF8([NSString stringWithFormat:@"%p", key]);
id value = [dict objectForKey:key]; id value = [dict objectForKey:key];
if ([value isKindOfClass:[NSString class]]) { if ([value isKindOfClass:[NSString class]]) {
@ -109,7 +106,9 @@ scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
result->SetWithoutPathExpansion(str_key, result->SetWithoutPathExpansion(str_key,
base::Value::CreateNullValue()); base::Value::CreateNullValue());
} else { } else {
result->SetWithoutPathExpansion(str_key, base::Value::CreateNullValue()); result->SetStringWithoutPathExpansion(
str_key,
base::SysNSStringToUTF8([value description]));
} }
} }