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 #include "components/dom_distiller/ios/distiller_page_ios.h" | 5 #include "components/dom_distiller/ios/distiller_page_ios.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 std::unique_ptr<base::Value> result; | 39 std::unique_ptr<base::Value> result; |
40 | 40 |
41 if (max_depth < 0) { | 41 if (max_depth < 0) { |
42 DLOG(WARNING) << "JS maximum recursion depth exceeded."; | 42 DLOG(WARNING) << "JS maximum recursion depth exceeded."; |
43 return result; | 43 return result; |
44 } | 44 } |
45 | 45 |
46 CFTypeID result_type = CFGetTypeID(wk_result); | 46 CFTypeID result_type = CFGetTypeID(wk_result); |
47 if (result_type == CFStringGetTypeID()) { | 47 if (result_type == CFStringGetTypeID()) { |
48 result.reset(new base::StringValue(base::SysNSStringToUTF16(wk_result))); | 48 result.reset(new base::StringValue(base::SysNSStringToUTF16(wk_result))); |
49 DCHECK(result->IsType(base::Value::TYPE_STRING)); | 49 DCHECK(result->IsType(base::Value::Type::STRING)); |
50 } else if (result_type == CFNumberGetTypeID()) { | 50 } else if (result_type == CFNumberGetTypeID()) { |
51 // Different implementation is here. | 51 // Different implementation is here. |
52 if ([wk_result intValue] != [wk_result doubleValue]) { | 52 if ([wk_result intValue] != [wk_result doubleValue]) { |
53 result.reset(new base::FundamentalValue([wk_result doubleValue])); | 53 result.reset(new base::FundamentalValue([wk_result doubleValue])); |
54 DCHECK(result->IsType(base::Value::TYPE_DOUBLE)); | 54 DCHECK(result->IsType(base::Value::Type::DOUBLE)); |
55 } else { | 55 } else { |
56 result.reset(new base::FundamentalValue([wk_result intValue])); | 56 result.reset(new base::FundamentalValue([wk_result intValue])); |
57 DCHECK(result->IsType(base::Value::TYPE_INTEGER)); | 57 DCHECK(result->IsType(base::Value::Type::INTEGER)); |
58 } | 58 } |
59 // End of different implementation. | 59 // End of different implementation. |
60 } else if (result_type == CFBooleanGetTypeID()) { | 60 } else if (result_type == CFBooleanGetTypeID()) { |
61 result.reset( | 61 result.reset( |
62 new base::FundamentalValue(static_cast<bool>([wk_result boolValue]))); | 62 new base::FundamentalValue(static_cast<bool>([wk_result boolValue]))); |
63 DCHECK(result->IsType(base::Value::TYPE_BOOLEAN)); | 63 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); |
64 } else if (result_type == CFNullGetTypeID()) { | 64 } else if (result_type == CFNullGetTypeID()) { |
65 result = base::Value::CreateNullValue(); | 65 result = base::Value::CreateNullValue(); |
66 DCHECK(result->IsType(base::Value::TYPE_NULL)); | 66 DCHECK(result->IsType(base::Value::Type::NONE)); |
67 } else if (result_type == CFDictionaryGetTypeID()) { | 67 } else if (result_type == CFDictionaryGetTypeID()) { |
68 std::unique_ptr<base::DictionaryValue> dictionary = | 68 std::unique_ptr<base::DictionaryValue> dictionary = |
69 base::MakeUnique<base::DictionaryValue>(); | 69 base::MakeUnique<base::DictionaryValue>(); |
70 for (id key in wk_result) { | 70 for (id key in wk_result) { |
71 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); | 71 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); |
72 const std::string path = base::SysNSStringToUTF8(obj_c_string); | 72 const std::string path = base::SysNSStringToUTF8(obj_c_string); |
73 std::unique_ptr<base::Value> value = | 73 std::unique_ptr<base::Value> value = |
74 ValueResultFromScriptResult(wk_result[obj_c_string], max_depth - 1); | 74 ValueResultFromScriptResult(wk_result[obj_c_string], max_depth - 1); |
75 if (value) { | 75 if (value) { |
76 dictionary->Set(path, std::move(value)); | 76 dictionary->Set(path, std::move(value)); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 187 } |
188 OnDistillationDone(url_, resultValue.get()); | 188 OnDistillationDone(url_, resultValue.get()); |
189 } | 189 } |
190 | 190 |
191 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult( | 191 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult( |
192 id wk_result) { | 192 id wk_result) { |
193 return ::ValueResultFromScriptResult(wk_result, | 193 return ::ValueResultFromScriptResult(wk_result, |
194 kMaximumParsingRecursionDepth); | 194 kMaximumParsingRecursionDepth); |
195 } | 195 } |
196 } // namespace dom_distiller | 196 } // namespace dom_distiller |
OLD | NEW |