OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/public/test/crw_test_js_injection_receiver.h" | 5 #import "ios/web/public/test/crw_test_js_injection_receiver.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
10 #include "base/ios/weak_nsobject.h" | 10 #include "base/ios/weak_nsobject.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 @implementation CRWTestWKWebViewEvaluator | 23 @implementation CRWTestWKWebViewEvaluator |
24 | 24 |
25 - (instancetype)init { | 25 - (instancetype)init { |
26 if (self = [super init]) { | 26 if (self = [super init]) { |
27 _webView.reset([[WKWebView alloc] init]); | 27 _webView.reset([[WKWebView alloc] init]); |
28 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); | 28 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); |
29 } | 29 } |
30 return self; | 30 return self; |
31 } | 31 } |
32 | 32 |
33 - (void)evaluateJavaScript:(NSString*)script | |
34 stringResultHandler:(web::JavaScriptCompletion)handler { | |
35 web::EvaluateJavaScript(_webView, script, handler); | |
36 } | |
37 | |
38 - (void)executeJavaScript:(NSString*)script | 33 - (void)executeJavaScript:(NSString*)script |
39 completionHandler:(web::JavaScriptResultBlock)completionHandler { | 34 completionHandler:(web::JavaScriptResultBlock)completionHandler { |
40 web::ExecuteJavaScript(_webView, script, completionHandler); | 35 web::ExecuteJavaScript(_webView, script, completionHandler); |
41 } | 36 } |
42 | 37 |
43 - (BOOL)scriptHasBeenInjectedForClass:(Class)injectionManagerClass { | 38 - (BOOL)scriptHasBeenInjectedForClass:(Class)injectionManagerClass { |
44 return [_injectedScriptManagers containsObject:injectionManagerClass]; | 39 return [_injectedScriptManagers containsObject:injectionManagerClass]; |
45 } | 40 } |
46 | 41 |
47 - (void)injectScript:(NSString*)script forClass:(Class)JSInjectionManagerClass { | 42 - (void)injectScript:(NSString*)script forClass:(Class)JSInjectionManagerClass { |
(...skipping 15 matching lines...) Expand all Loading... |
63 | 58 |
64 - (id)init { | 59 - (id)init { |
65 base::scoped_nsobject<CRWTestWKWebViewEvaluator> evaluator( | 60 base::scoped_nsobject<CRWTestWKWebViewEvaluator> evaluator( |
66 [[CRWTestWKWebViewEvaluator alloc] init]); | 61 [[CRWTestWKWebViewEvaluator alloc] init]); |
67 if (self = [super initWithEvaluator:evaluator]) | 62 if (self = [super initWithEvaluator:evaluator]) |
68 evaluator_.swap(evaluator); | 63 evaluator_.swap(evaluator); |
69 return self; | 64 return self; |
70 } | 65 } |
71 | 66 |
72 @end | 67 @end |
OLD | NEW |