OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web/web_state/ui/web_view_js_utils.h" | 5 #import "ios/web/web_state/ui/web_view_js_utils.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 if (result_type == CFStringGetTypeID()) { | 34 if (result_type == CFStringGetTypeID()) { |
35 result.reset(new base::Value(base::SysNSStringToUTF16(wk_result))); | 35 result.reset(new base::Value(base::SysNSStringToUTF16(wk_result))); |
36 DCHECK(result->IsType(base::Value::Type::STRING)); | 36 DCHECK(result->IsType(base::Value::Type::STRING)); |
37 } else if (result_type == CFNumberGetTypeID()) { | 37 } else if (result_type == CFNumberGetTypeID()) { |
38 result.reset(new base::Value([wk_result doubleValue])); | 38 result.reset(new base::Value([wk_result doubleValue])); |
39 DCHECK(result->IsType(base::Value::Type::DOUBLE)); | 39 DCHECK(result->IsType(base::Value::Type::DOUBLE)); |
40 } else if (result_type == CFBooleanGetTypeID()) { | 40 } else if (result_type == CFBooleanGetTypeID()) { |
41 result.reset(new base::Value(static_cast<bool>([wk_result boolValue]))); | 41 result.reset(new base::Value(static_cast<bool>([wk_result boolValue]))); |
42 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); | 42 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); |
43 } else if (result_type == CFNullGetTypeID()) { | 43 } else if (result_type == CFNullGetTypeID()) { |
44 result = base::Value::CreateNullValue(); | 44 result = base::MakeUnique<base::Value>(); |
45 DCHECK(result->IsType(base::Value::Type::NONE)); | 45 DCHECK(result->IsType(base::Value::Type::NONE)); |
46 } else if (result_type == CFDictionaryGetTypeID()) { | 46 } else if (result_type == CFDictionaryGetTypeID()) { |
47 std::unique_ptr<base::DictionaryValue> dictionary = | 47 std::unique_ptr<base::DictionaryValue> dictionary = |
48 base::MakeUnique<base::DictionaryValue>(); | 48 base::MakeUnique<base::DictionaryValue>(); |
49 for (id key in wk_result) { | 49 for (id key in wk_result) { |
50 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); | 50 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); |
51 const std::string path = base::SysNSStringToUTF8(obj_c_string); | 51 const std::string path = base::SysNSStringToUTF8(obj_c_string); |
52 std::unique_ptr<base::Value> value = | 52 std::unique_ptr<base::Value> value = |
53 ValueResultFromWKResult(wk_result[obj_c_string], max_depth - 1); | 53 ValueResultFromWKResult(wk_result[obj_c_string], max_depth - 1); |
54 if (value) { | 54 if (value) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 userInfo:@{NSLocalizedDescriptionKey : error_message}]); | 97 userInfo:@{NSLocalizedDescriptionKey : error_message}]); |
98 completion_handler(nil, error); | 98 completion_handler(nil, error); |
99 }); | 99 }); |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 [web_view evaluateJavaScript:script completionHandler:completion_handler]; | 103 [web_view evaluateJavaScript:script completionHandler:completion_handler]; |
104 } | 104 } |
105 | 105 |
106 } // namespace web | 106 } // namespace web |
OLD | NEW |