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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 std::unique_ptr<base::Value> result; | 26 std::unique_ptr<base::Value> result; |
27 | 27 |
28 if (max_depth < 0) { | 28 if (max_depth < 0) { |
29 DLOG(WARNING) << "JS maximum recursion depth exceeded."; | 29 DLOG(WARNING) << "JS maximum recursion depth exceeded."; |
30 return result; | 30 return result; |
31 } | 31 } |
32 | 32 |
33 CFTypeID result_type = CFGetTypeID(wk_result); | 33 CFTypeID result_type = CFGetTypeID(wk_result); |
34 if (result_type == CFStringGetTypeID()) { | 34 if (result_type == CFStringGetTypeID()) { |
35 result.reset(new base::StringValue(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::Value::CreateNullValue(); |
45 DCHECK(result->IsType(base::Value::Type::NONE)); | 45 DCHECK(result->IsType(base::Value::Type::NONE)); |
(...skipping 51 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 |