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_MANAGER_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_MANAGER_H_ |
6 #define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_MANAGER_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_MANAGER_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h" | 10 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h" |
11 | 11 |
12 @class CRWJSInjectionReceiver; | 12 @class CRWJSInjectionReceiver; |
13 | 13 |
14 // This class defines the abstract interface for managing JavaScript | 14 // This class defines the abstract interface for managing JavaScript |
15 // Injection into a UIWebView. | 15 // Injection into a UIWebView. |
16 @interface CRWJSInjectionManager : NSObject | 16 @interface CRWJSInjectionManager : NSObject |
17 | 17 |
18 // Designated initializer. Initializes the object with the |receiver|. | 18 // Designated initializer. Initializes the object with the |receiver|. |
19 - (id)initWithReceiver:(CRWJSInjectionReceiver*)receiver; | 19 - (id)initWithReceiver:(CRWJSInjectionReceiver*)receiver; |
20 | 20 |
21 // Returns whether JavaScript has already been injected into the receiver. | 21 // Returns whether JavaScript has already been injected into the receiver. |
22 - (BOOL)hasBeenInjected; | 22 - (BOOL)hasBeenInjected; |
23 | 23 |
24 // Injects JavaScript at |self.scriptPath| into the receiver object if it is | 24 // Injects JavaScript at |self.scriptPath| into the receiver object if it is |
25 // missing. It also injects the dependencies' JavaScript if they are missing. | 25 // missing. It also injects the dependencies' JavaScript if they are missing. |
26 - (void)inject; | 26 - (void)inject; |
27 | 27 |
28 // Evaluate the provided JavaScript asynchronously calling completionHandler | |
29 // after execution. The |completionHandler| can be nil. | |
30 // DEPRECATED. TODO(crbug.com/595761): Remove this API. | |
31 - (void)evaluate:(NSString*)script | |
32 stringResultHandler:(web::JavaScriptCompletion)completionHandler; | |
33 | |
34 // Executes the supplied JavaScript asynchronously. Calls |completionHandler| | 28 // Executes the supplied JavaScript asynchronously. Calls |completionHandler| |
35 // with results of the execution (which may be nil) or an NSError if there is an | 29 // with results of the execution (which may be nil) or an NSError if there is an |
36 // error. The |completionHandler| can be nil. | 30 // error. The |completionHandler| can be nil. |
37 - (void)executeJavaScript:(NSString*)script | 31 - (void)executeJavaScript:(NSString*)script |
38 completionHandler:(web::JavaScriptResultBlock)completionHandler; | 32 completionHandler:(web::JavaScriptResultBlock)completionHandler; |
39 | 33 |
40 @end | 34 @end |
41 | 35 |
42 @interface CRWJSInjectionManager (ProtectedMethods) | 36 @interface CRWJSInjectionManager (ProtectedMethods) |
43 | 37 |
(...skipping 17 matching lines...) Expand all Loading... |
61 // the receiver object. By default this returns the contents of the script file; | 55 // the receiver object. By default this returns the contents of the script file; |
62 // subclasses can override this if they need to get a static script from some | 56 // subclasses can override this if they need to get a static script from some |
63 // other source. | 57 // other source. |
64 // The return value from this method will be cached; if dynamic script content | 58 // The return value from this method will be cached; if dynamic script content |
65 // is necessary, override injectionContent instead. | 59 // is necessary, override injectionContent instead. |
66 - (NSString*)staticInjectionContent; | 60 - (NSString*)staticInjectionContent; |
67 | 61 |
68 @end | 62 @end |
69 | 63 |
70 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_MANAGER_H_ | 64 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_MANAGER_H_ |
OLD | NEW |