OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ |
6 #define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #import "ios/web/public/block_types.h" | 10 #import "ios/web/public/block_types.h" |
11 | 11 |
12 @protocol CRWJSInjectionEvaluator | 12 @protocol CRWJSInjectionEvaluator |
13 | 13 |
14 // Evaluates the supplied JavaScript in the WebView. Calls |completionHandler| | |
15 // with results of the evaluation (which may be nil if the implementing object | |
16 // has no way to run the evaluation or the evaluation returns a nil value) | |
17 // or an NSError if there is an error. The |completionHandler| can be nil. | |
18 // TODO(crbug.com/595761): Change this API to return |id| instead of string. | |
19 - (void)evaluateJavaScript:(NSString*)script | |
20 stringResultHandler:(web::JavaScriptCompletion)handler; | |
21 | |
22 // Executes the supplied JavaScript in the WebView. Calls |completionHandler| | 14 // Executes the supplied JavaScript in the WebView. Calls |completionHandler| |
23 // with results of the execution (which may be nil if the implementing object | 15 // with results of the execution (which may be nil if the implementing object |
24 // has no way to run the execution or the execution returns a nil value) | 16 // has no way to run the execution or the execution returns a nil value) |
25 // or an NSError if there is an error. The |completionHandler| can be nil. | 17 // or an NSError if there is an error. The |completionHandler| can be nil. |
26 - (void)executeJavaScript:(NSString*)script | 18 - (void)executeJavaScript:(NSString*)script |
27 completionHandler:(web::JavaScriptResultBlock)completionHandler; | 19 completionHandler:(web::JavaScriptResultBlock)completionHandler; |
28 | 20 |
29 // Checks to see if the script for a class has been injected into the | 21 // Checks to see if the script for a class has been injected into the |
30 // current page already. | 22 // current page already. |
31 - (BOOL)scriptHasBeenInjectedForClass:(Class)injectionManagerClass; | 23 - (BOOL)scriptHasBeenInjectedForClass:(Class)injectionManagerClass; |
32 | 24 |
33 // Injects the given script into the current page on behalf of | 25 // Injects the given script into the current page on behalf of |
34 // |injectionManagerClass|. This should only be used for injecting | 26 // |injectionManagerClass|. This should only be used for injecting |
35 // the manager's script, and not for evaluating arbitrary JavaScript. | 27 // the manager's script, and not for evaluating arbitrary JavaScript. |
36 - (void)injectScript:(NSString*)script forClass:(Class)injectionManagerClass; | 28 - (void)injectScript:(NSString*)script forClass:(Class)injectionManagerClass; |
37 | 29 |
38 @end | 30 @end |
39 | 31 |
40 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ | 32 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ |
OLD | NEW |