Chromium Code Reviews| Index: ios/web/web_state/ui/crw_wk_script_message_router.h |
| diff --git a/ios/web/web_state/ui/crw_wk_script_message_router.h b/ios/web/web_state/ui/crw_wk_script_message_router.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..04955d1aa3f88ef886daf9e9a34db8acdc451ff4 |
| --- /dev/null |
| +++ b/ios/web/web_state/ui/crw_wk_script_message_router.h |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 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_WEB_STATE_UI_CRW_WK_SCRIPT_MESSAGE_ROUTER_H_ |
|
Eugene But (OOO till 7-30)
2015/03/30 05:03:58
Optional: I think I can remove this class at all v
stuartmorgan
2015/03/30 14:17:57
Done.
|
| +#define IOS_WEB_WEB_STATE_UI_CRW_WK_SCRIPT_MESSAGE_ROUTER_H_ |
| + |
| +#import <WebKit/WebKit.h> |
| + |
| +// WKUserContentController wrapper that allows adding multiple message handlers |
| +// for the same message name. CRWWKScriptMessageRouter will route the messages |
| +// from the underlying user content controller to a designated reciever by |
| +// matching the message's name and webView. |
| +@interface CRWWKScriptMessageRouter : NSObject |
| + |
| +// Underlying WKUserContentController. |
| +@property(nonatomic, readonly) WKUserContentController* userContentController; |
| + |
| +// Designated initializer. |userContentController| must not be nil. |
| +- (instancetype)initWithUserContentController: |
| + (WKUserContentController*)userContentController; |
| + |
| +// Sets a script message handler. Multiple message handlers can be added for |
| +// the same message name and long as |webView| are different. Setting |handler| |
| +// for the same |name| and |webView| pair is an error. |handler| will be called |
| +// if WKScriptMessage sent by WKUserContentController will match both the |name| |
| +// and the |webView|. |
| +- (void)setScriptMessageHandler:(void(^)(WKScriptMessage*))handler |
| + name:(NSString*)messageName |
| + webView:(WKWebView*)webView; |
| + |
| +// Removes a specific message handler. |
| +- (void)removeScriptMessageHandlerForName:(NSString*)messageName |
| + webView:(WKWebView*)webView; |
| + |
| +// Removes all message handlers for the given |webView|. |
| +- (void)removeAllScriptMessageHandlersForWebView:(WKWebView*)webView; |
| + |
| +@end |
| + |
| +#endif // IOS_WEB_WEB_STATE_UI_CRW_WK_SCRIPT_MESSAGE_ROUTER_H_ |