Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: components/dom_distiller/ios/distiller_page_ios.mm

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::Value([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(new base::Value(static_cast<bool>([wk_result boolValue]))); 66 result.reset(new base::Value(static_cast<bool>([wk_result boolValue])));
67 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); 67 DCHECK(result->IsType(base::Value::Type::BOOLEAN));
68 } else if (result_type == CFNullGetTypeID()) { 68 } else if (result_type == CFNullGetTypeID()) {
69 result = base::Value::CreateNullValue(); 69 result = base::MakeUnique<base::Value>();
70 DCHECK(result->IsType(base::Value::Type::NONE)); 70 DCHECK(result->IsType(base::Value::Type::NONE));
71 } else if (result_type == CFDictionaryGetTypeID()) { 71 } else if (result_type == CFDictionaryGetTypeID()) {
72 std::unique_ptr<base::DictionaryValue> dictionary = 72 std::unique_ptr<base::DictionaryValue> dictionary =
73 base::MakeUnique<base::DictionaryValue>(); 73 base::MakeUnique<base::DictionaryValue>();
74 for (id key in wk_result) { 74 for (id key in wk_result) {
75 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); 75 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key);
76 const std::string path = base::SysNSStringToUTF8(obj_c_string); 76 const std::string path = base::SysNSStringToUTF8(obj_c_string);
77 std::unique_ptr<base::Value> value = 77 std::unique_ptr<base::Value> value =
78 ValueResultFromScriptResult(wk_result[obj_c_string], max_depth - 1); 78 ValueResultFromScriptResult(wk_result[obj_c_string], max_depth - 1);
79 if (value) { 79 if (value) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 instanceOfClass:[CRWJSInjectionManager class]] 225 instanceOfClass:[CRWJSInjectionManager class]]
226 executeJavaScript:base::SysUTF8ToNSString(script_) 226 executeJavaScript:base::SysUTF8ToNSString(script_)
227 completionHandler:^(id result, NSError* error) { 227 completionHandler:^(id result, NSError* error) {
228 DistillerPageIOS* distiller_page = weak_this.get(); 228 DistillerPageIOS* distiller_page = weak_this.get();
229 if (distiller_page) 229 if (distiller_page)
230 distiller_page->HandleJavaScriptResult(result); 230 distiller_page->HandleJavaScriptResult(result);
231 }]; 231 }];
232 } 232 }
233 233
234 void DistillerPageIOS::HandleJavaScriptResult(id result) { 234 void DistillerPageIOS::HandleJavaScriptResult(id result) {
235 std::unique_ptr<base::Value> resultValue = base::Value::CreateNullValue(); 235 auto resultValue = base::MakeUnique<base::Value>();
236 if (result) { 236 if (result) {
237 resultValue = ValueResultFromScriptResult(result); 237 resultValue = ValueResultFromScriptResult(result);
238 } 238 }
239 OnDistillationDone(url_, resultValue.get()); 239 OnDistillationDone(url_, resultValue.get());
240 } 240 }
241 241
242 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult( 242 std::unique_ptr<base::Value> DistillerPageIOS::ValueResultFromScriptResult(
243 id wk_result) { 243 id wk_result) {
244 return ::ValueResultFromScriptResult(wk_result, 244 return ::ValueResultFromScriptResult(wk_result,
245 kMaximumParsingRecursionDepth); 245 kMaximumParsingRecursionDepth);
246 } 246 }
247 } // namespace dom_distiller 247 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_unittest.cc ('k') | components/history/core/browser/top_sites_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698