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

Side by Side Diff: ios/web/web_state/ui/web_view_js_utils.mm

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 #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 17 matching lines...) Expand all
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::StringValue(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::FundamentalValue([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( 41 result.reset(new base::Value(static_cast<bool>([wk_result boolValue])));
42 new base::FundamentalValue(static_cast<bool>([wk_result boolValue])));
43 DCHECK(result->IsType(base::Value::Type::BOOLEAN)); 42 DCHECK(result->IsType(base::Value::Type::BOOLEAN));
44 } else if (result_type == CFNullGetTypeID()) { 43 } else if (result_type == CFNullGetTypeID()) {
45 result = base::Value::CreateNullValue(); 44 result = base::Value::CreateNullValue();
46 DCHECK(result->IsType(base::Value::Type::NONE)); 45 DCHECK(result->IsType(base::Value::Type::NONE));
47 } else if (result_type == CFDictionaryGetTypeID()) { 46 } else if (result_type == CFDictionaryGetTypeID()) {
48 std::unique_ptr<base::DictionaryValue> dictionary = 47 std::unique_ptr<base::DictionaryValue> dictionary =
49 base::MakeUnique<base::DictionaryValue>(); 48 base::MakeUnique<base::DictionaryValue>();
50 for (id key in wk_result) { 49 for (id key in wk_result) {
51 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); 50 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key);
52 const std::string path = base::SysNSStringToUTF8(obj_c_string); 51 const std::string path = base::SysNSStringToUTF8(obj_c_string);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 userInfo:@{NSLocalizedDescriptionKey : error_message}]); 97 userInfo:@{NSLocalizedDescriptionKey : error_message}]);
99 completion_handler(nil, error); 98 completion_handler(nil, error);
100 }); 99 });
101 return; 100 return;
102 } 101 }
103 102
104 [web_view evaluateJavaScript:script completionHandler:completion_handler]; 103 [web_view evaluateJavaScript:script completionHandler:completion_handler];
105 } 104 }
106 105
107 } // namespace web 106 } // namespace web
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc ('k') | ios/web/webui/mojo_facade.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698