QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / ios / web / public / web_state / js / crw_js_injection_evaluator.h
blob3264b03fcd98afc4f0e8d9a5b6413bcc47be6ffa
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.
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_
8 #import <Foundation/Foundation.h>
10 #include "ios/web/public/web_view_type.h"
12 // The type of the completion handler block that is called from
13 // |evaluateJavaScript:completionHandler|
14 namespace web {
15 typedef void (^JavaScriptCompletion)(NSString*, NSError*);
18 @protocol CRWJSInjectionEvaluator
20 // Evaluates the supplied JavaScript in the WebView. Calls |completionHandler|
21 // with results of the evaluation (which may be nil if the implementing object
22 // has no way to run the evaluation or the evaluation returns a nil value)
23 // or an NSError if there is an error. The |completionHandler| can be nil.
24 - (void)evaluateJavaScript:(NSString*)script
25 stringResultHandler:(web::JavaScriptCompletion)handler;
27 // Checks to see if the script for a class has been injected into the
28 // current page already, given the class and the script's presence
29 // beacon (a JS object that should exist iff the script has been injected).
30 - (BOOL)scriptHasBeenInjectedForClass:(Class)jsInjectionManagerClass
31 presenceBeacon:(NSString*)beacon;
33 // Injects the given script into the current page on behalf of
34 // |jsInjectionManagerClass|. This should only be used for injecting
35 // the manager's script, and not for evaluating arbitrary JavaScript.
36 - (void)injectScript:(NSString*)script forClass:(Class)jsInjectionManagerClass;
38 // Returns type of web view used for evaluation. Must not change for the
39 // lifetime of the object.
40 - (web::WebViewType)webViewType;
42 @end
44 #endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_