Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: ios/web/public/web_state/js/crw_js_injection_evaluator.h

Issue 790803002: Upstream JavaScript injection for iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web/public/web_state/js/crw_js_injection_evaluator.h
diff --git a/ios/web/public/web_state/js/crw_js_injection_evaluator.h b/ios/web/public/web_state/js/crw_js_injection_evaluator.h
new file mode 100644
index 0000000000000000000000000000000000000000..724f1bdfa061bf2a72418ba559784a14eed525f6
--- /dev/null
+++ b/ios/web/public/web_state/js/crw_js_injection_evaluator.h
@@ -0,0 +1,38 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_
+#define IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_
+
+#import <Foundation/Foundation.h>
+
+// The type of the completion handler block that is called from
+// |evaluateJavaScript:completionHandler|
+namespace web {
+typedef void (^JavaScriptCompletion)(NSString*, NSError*);
+}
+
+@protocol CRWJSInjectionEvaluator
+
+// Evaluates the supplied JavaScript in the WebView. Calls |completionHandler|
+// with results of the evaluation (which may be nil if the implementing object
+// has no way to run the evaluation or the evaluation returns a nil value)
+// or an NSError if there is an error. The |completionHandler| can be nil.
+- (void)evaluateJavaScript:(NSString*)script
+ stringResultHandler:(web::JavaScriptCompletion)handler;
+
+// Checks to see if the script for a class has been injected into the
+// current page already, given the class and the script's presence
+// beacon (a JS object that should exist iff the script has been injected).
+- (BOOL)scriptHasBeenInjectedForClass:(Class)jsInjectionManagerClass
+ presenceBeacon:(NSString*)beacon;
+
+// Injects the given script into the current page on behalf of
+// |jsInjectionManagerClass|. This should only be used for injecting
+// the manager's script, and not for evaluating arbitrary JavaScript.
+- (void)injectScript:(NSString*)script forClass:(Class)jsInjectionManagerClass;
+
+@end
+
+#endif // IOS_WEB_PUBLIC_WEB_STATE_JS_CRW_JS_INJECTION_EVALUATOR_H_
« no previous file with comments | « ios/web/public/web_state/js/crw_js_base_manager.h ('k') | ios/web/public/web_state/js/crw_js_injection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698