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

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

Issue 2327783002: Fix domdistiller for new JS execution (Closed)
Patch Set: comments test Created 4 years, 3 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DCHECK(result->IsType(base::Value::TYPE_BOOLEAN)); 43 DCHECK(result->IsType(base::Value::TYPE_BOOLEAN));
44 } else if (result_type == CFNullGetTypeID()) { 44 } else if (result_type == CFNullGetTypeID()) {
45 result = base::Value::CreateNullValue(); 45 result = base::Value::CreateNullValue();
46 DCHECK(result->IsType(base::Value::TYPE_NULL)); 46 DCHECK(result->IsType(base::Value::TYPE_NULL));
47 } else if (result_type == CFDictionaryGetTypeID()) { 47 } else if (result_type == CFDictionaryGetTypeID()) {
48 std::unique_ptr<base::DictionaryValue> dictionary = 48 std::unique_ptr<base::DictionaryValue> dictionary =
49 base::MakeUnique<base::DictionaryValue>(); 49 base::MakeUnique<base::DictionaryValue>();
50 for (id key in wk_result) { 50 for (id key in wk_result) {
51 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key); 51 NSString* obj_c_string = base::mac::ObjCCast<NSString>(key);
52 const std::string path = base::SysNSStringToUTF8(obj_c_string); 52 const std::string path = base::SysNSStringToUTF8(obj_c_string);
53 std::unique_ptr<base::Value> value = ValueResultFromWKResult( 53 std::unique_ptr<base::Value> value =
54 [wk_result objectForKey:obj_c_string], max_depth - 1); 54 ValueResultFromWKResult(wk_result[obj_c_string], max_depth - 1);
55 if (value) { 55 if (value) {
56 dictionary->Set(path, std::move(value)); 56 dictionary->Set(path, std::move(value));
57 } 57 }
58 } 58 }
59 result = std::move(dictionary); 59 result = std::move(dictionary);
60 } else if (result_type == CFArrayGetTypeID()) {
61 std::unique_ptr<base::ListValue> list = base::MakeUnique<base::ListValue>();
62 for (id value in wk_result) {
63 list->Append(ValueResultFromWKResult(value, max_depth - 1));
64 }
65 result = std::move(list);
60 } else { 66 } else {
61 NOTREACHED(); // Convert other types as needed. 67 NOTREACHED(); // Convert other types as needed.
62 } 68 }
63 return result; 69 return result;
64 } 70 }
65 71
66 } // namespace 72 } // namespace
67 73
68 namespace web { 74 namespace web {
69 75
(...skipping 18 matching lines...) Expand all
88 userInfo:@{NSLocalizedDescriptionKey : error_message}]); 94 userInfo:@{NSLocalizedDescriptionKey : error_message}]);
89 completion_handler(nil, error); 95 completion_handler(nil, error);
90 }); 96 });
91 return; 97 return;
92 } 98 }
93 99
94 [web_view evaluateJavaScript:script completionHandler:completion_handler]; 100 [web_view evaluateJavaScript:script completionHandler:completion_handler];
95 } 101 }
96 102
97 } // namespace web 103 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698