Chromium Code Reviews| Index: ios/web/web_state/ui/web_view_js_utils.mm |
| diff --git a/ios/web/web_state/ui/web_view_js_utils.mm b/ios/web/web_state/ui/web_view_js_utils.mm |
| index 48d65aac362036905e388e4e92a6f1bf3284afbb..78ce1d861694ff252cc6eaa73f6282b25d8e678e 100644 |
| --- a/ios/web/web_state/ui/web_view_js_utils.mm |
| +++ b/ios/web/web_state/ui/web_view_js_utils.mm |
| @@ -9,6 +9,7 @@ |
| #include "base/logging.h" |
| #include "base/mac/scoped_nsobject.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "base/values.h" |
| @@ -62,6 +63,16 @@ std::unique_ptr<base::Value> ValueResultFromWKResult(id wk_result) { |
| } else if (result_type == CFNullGetTypeID()) { |
| result = base::Value::CreateNullValue(); |
| DCHECK(result->IsType(base::Value::TYPE_NULL)); |
| + } else if (result_type == CFDictionaryGetTypeID()) { |
| + std::unique_ptr<base::DictionaryValue> dictionary = |
| + base::MakeUnique<base::DictionaryValue>(); |
| + for (id key in wk_result) { |
| + DCHECK([key respondsToSelector:@selector(UTF8String)]); |
| + const std::string& path([key UTF8String]); |
|
Eugene But (OOO till 7-30)
2016/09/09 15:26:21
Please use sys_string_conversions instead of |UTF8
jif-google
2016/09/09 17:54:45
Acknowledged.
Eugene But (OOO till 7-30)
2016/09/09 18:28:57
[key UTF8String] may return nil, which will crash
|
| + dictionary->Set(path, |
| + ValueResultFromWKResult([wk_result objectForKey:key])); |
|
Eugene But (OOO till 7-30)
2016/09/09 15:26:21
This JSON is coming from internet, which means tha
jif-google
2016/09/09 17:54:45
When does the JSON come from the internet?
Eugene But (OOO till 7-30)
2016/09/09 18:28:57
wk_result is the result of script evaluation, for
|
| + } |
| + result = std::move(dictionary); |
| } else { |
| NOTREACHED(); // Convert other types as needed. |
| } |