1 // Copyright 2017 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_WEB_STATE_UI_CRW_CONTEXT_MENU_DELEGATE_H_ 6 #define IOS_WEB_WEB_STATE_UI_CRW_CONTEXT_MENU_DELEGATE_H_ 7 8 #import <WebKit/WebKit.h> 9 10 #import "ios/web/public/ui/context_menu_params.h" 11 12 // Implement this protocol to listen to the custom context menu trigger from 13 // WKWebView. 14 @protocol CRWContextMenuDelegate <NSObject> 15 16 // Called when the custom Context menu recognizer triggers on |webView| by a 17 // long press gesture. The system context menu will be suppressed. 18 - (void)webView:(WKWebView*)webView 19 handleContextMenu:(const web::ContextMenuParams&)params; 20 21 @optional 22 // Called to execute JavaScript in |webView|. The |completionHandler| must be 23 // called with the result of executing |javaScript|. The JavaScript will be 24 // executed directly on |webView| if this method is not implemented. 25 - (void)webView:(WKWebView*)webView 26 executeJavaScript:(NSString*)javaScript 27 completionHandler:(void (^)(id, NSError*))completionHandler; 28 @end 29 30 #endif // IOS_WEB_WEB_STATE_UI_CRW_CONTEXT_MENU_DELEGATE_H_ 31