OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 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_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 // The type of the completion handler block that is called from |
| 11 // |evaluateJavaScript:completionHandler| |
| 12 namespace web { |
| 13 typedef void (^JavaScriptCompletion)(NSString*, NSError*); |
| 14 } |
| 15 |
| 16 @protocol CRWJSInjectionEvaluator |
| 17 |
| 18 // Evaluates the supplied JavaScript in the WebView. Calls |completionHandler| |
| 19 // with results of the evaluation (which may be nil if the implementing object |
| 20 // has no way to run the evaluation or the evaluation returns a nil value) |
| 21 // or an NSError if there is an error. The |completionHandler| can be nil. |
| 22 - (void)evaluateJavaScript:(NSString*)script |
| 23 stringResultHandler:(web::JavaScriptCompletion)handler; |
| 24 |
| 25 // Checks to see if the script for a class has been injected into the |
| 26 // current page already, given the class and the script's presence |
| 27 // beacon (a JS object that should exist iff the script has been injected). |
| 28 - (BOOL)scriptHasBeenInjectedForClass:(Class)jsInjectionManagerClass |
| 29 presenceBeacon:(NSString*)beacon; |
| 30 |
| 31 // Injects the given script into the current page on behalf of |
| 32 // |jsInjectionManagerClass|. This should only be used for injecting |
| 33 // the manager's script, and not for evaluating arbitrary JavaScript. |
| 34 - (void)injectScript:(NSString*)script forClass:(Class)jsInjectionManagerClass; |
| 35 |
| 36 @end |
| 37 |
| 38 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_ |
OLD | NEW |