| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return result; | 48 return result; |
| 49 } | 49 } |
| 50 | 50 |
| 51 CFTypeID result_type = CFGetTypeID(wk_result); | 51 CFTypeID result_type = CFGetTypeID(wk_result); |
| 52 if (result_type == CFStringGetTypeID()) { | 52 if (result_type == CFStringGetTypeID()) { |
| 53 result.reset(new base::StringValue(base::SysNSStringToUTF16(wk_result))); | 53 result.reset(new base::StringValue(base::SysNSStringToUTF16(wk_result))); |
| 54 DCHECK(result->IsType(base::Value::Type::STRING)); | 54 DCHECK(result->IsType(base::Value::Type::STRING)); |
| 55 } else if (result_type == CFNumberGetTypeID()) { | 55 } else if (result_type == CFNumberGetTypeID()) { |
| 56 // Different implementation is here. | 56 // Different implementation is here. |
| 57 if ([wk_result intValue] != [wk_result doubleValue]) { | 57 if ([wk_result intValue] != [wk_result doubleValue]) { |
| 58 result.reset(new base::FundamentalValue([wk_result doubleValue])); | 58 result.reset(new base::Value([wk_result doubleValue])); |
| 59 DCHECK(result->IsType(base::Value::Type::DOUBLE)); | 59 DCHECK(result->IsType(base::Value::Type::DOUBLE)); |
| 60 } else { | 60 } else { |
| 61 result.reset(new base::FundamentalValue([wk_result intValue])); | 61 result.reset(new base::Value([wk_result intValue])); |
| 62 DCHECK(result->IsType(base::Value::Type::INTEGER)); | 62 DCHECK(result->IsType(base::Value::Type::INTEGER)); |
| 63 } | 63 } |
| 64 // End of different implementation. | 64 // End of different implementation. |
| 65 } else if (result_type == CFBooleanGetTypeID()) { | 65 } else if (result_type == CFBooleanGetTypeID()) { |
| 66 result.reset( | 66 result.reset(new base::Value(static_cast<bool>([wk_result boolValue]))); |
| 67 new base::FundamentalValue(static_cast<bool>([wk_result boolValue]))); | |
| 68 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); | 67 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); |
| 69 } else if (result_type == CFNullGetTypeID()) { | 68 } else if (result_type == CFNullGetTypeID()) { |
| 70 result = base::Value::CreateNullValue(); | 69 result = base::Value::CreateNullValue(); |
| 71 DCHECK(result->IsType(base::Value::Type::NONE)); | 70 DCHECK(result->IsType(base::Value::Type::NONE)); |
| 72 } else if (result_type == CFDictionaryGetTypeID()) { | 71 } else if (result_type == CFDictionaryGetTypeID()) { |
| 73 std::unique_ptr<base::DictionaryValue> dictionary = | 72 std::unique_ptr<base::DictionaryValue> dictionary = |
| 74 base::MakeUnique<base::DictionaryValue>(); | 73 base::MakeUnique<base::DictionaryValue>(); |
| 75 for (id key in wk_result) { | 74 for (id key in wk_result) { |
| 76 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); | 75 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); |
| 77 const std::string path = base::SysNSStringToUTF8(obj_c_string); | 76 const std::string path = base::SysNSStringToUTF8(obj_c_string); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 238 } |
| 240 OnDistillationDone(url_, resultValue.get()); | 239 OnDistillationDone(url_, resultValue.get()); |
| 241 } | 240 } |
| 242 | 241 |
| 243 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult( | 242 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult( |
| 244 id wk_result) { | 243 id wk_result) { |
| 245 return ::ValueResultFromScriptResult(wk_result, | 244 return ::ValueResultFromScriptResult(wk_result, |
| 246 kMaximumParsingRecursionDepth); | 245 kMaximumParsingRecursionDepth); |
| 247 } | 246 } |
| 248 } // namespace dom_distiller | 247 } // namespace dom_distiller |
| OLD | NEW |